odys.optimization.variable_owner¶
Internal implementation detail. VariableOwner holds the typed decision variables of a formulation or an objective term, and refuses a second add_variables, so a problem is built into one model only.
The decision variables of one part of the model, created once and typed.
VariableOwner
¶
Bases: ABC, Generic[VariablesT]
A part of the model that holds its decision variables in a typed, frozen variables object.
The variables are created once, in add_variables, and belong to that one
model: a second add_variables raises, so a problem is built into one model only.
Entity formulations and objective terms with variables both use it. List it
before the formulation base class, whose add_variables adds nothing.
Source code in src/odys/optimization/variable_owner.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
variables
property
¶
add_variables(model)
¶
Add the decision variables to the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The linopy model to add the variables to. |
required |
Raises:
| Type | Description |
|---|---|
OdysError
|
If the variables were already added to a model; build a new problem for each model. |
Source code in src/odys/optimization/variable_owner.py
37 38 39 40 41 42 43 44 45 46 47 48 49 | |