flixopt.features
This module contains the features of the flixopt framework. Features extend the functionality of Elements.
Attributes
Classes
InvestmentModel
InvestmentModel(model: FlowSystemModel, label_of_element: str, parameters: InvestParameters, label_of_model: str | None = None)
Bases: Submodel
This feature model is used to model the investment of a variable. It applies the corresponding bounds to the variable and the on/off state of the variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
FlowSystemModel
|
The optimization model instance |
required |
label_of_element
|
str
|
The label of the parent (Element). Used to construct the full label of the model. |
required |
parameters
|
InvestParameters
|
The parameters of the feature model. |
required |
label_of_model
|
str | None
|
The label of the model. This is needed to construct the full label of the model. |
None
|
Attributes
all_submodels
property
Get all submodels including nested ones recursively.
variables_direct
property
Variables of the model, excluding those of sub-models
constraints_direct
property
Constraints of the model, excluding those of sub-models
constraints
property
All constraints of the model, including those of all sub-models
variables
property
All variables of the model, including those of all sub-models
Functions
add_submodels
Register a sub-model with the model
add_variables
Create and register a variable in one step
add_constraints
Create and register a constraint in one step
register_variable
Register a variable with the model
register_constraint
Register a constraint with the model
OnOffModel
OnOffModel(model: FlowSystemModel, label_of_element: str, parameters: OnOffParameters, on_variable: Variable, previous_states: TemporalData | None, label_of_model: str | None = None)
Bases: Submodel
OnOff model using factory patterns
This feature model is used to model the on/off state of flow_rate(s). It does not matter of the flow_rates are bounded by a size variable or by a hard bound. THe used bound here is the absolute highest/lowest bound!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
FlowSystemModel
|
The optimization model instance |
required |
label_of_element
|
str
|
The label of the parent (Element). Used to construct the full label of the model. |
required |
parameters
|
OnOffParameters
|
The parameters of the feature model. |
required |
on_variable
|
Variable
|
The variable that determines the on state |
required |
previous_states
|
TemporalData | None
|
The previous flow_rates |
required |
label_of_model
|
str | None
|
The label of the model. This is needed to construct the full label of the model. |
None
|
Attributes
consecutive_off_hours
property
Consecutive off hours variable
all_submodels
property
Get all submodels including nested ones recursively.
variables_direct
property
Variables of the model, excluding those of sub-models
constraints_direct
property
Constraints of the model, excluding those of sub-models
constraints
property
All constraints of the model, including those of all sub-models
variables
property
All variables of the model, including those of all sub-models
Functions
add_submodels
Register a sub-model with the model
add_variables
Create and register a variable in one step
add_constraints
Create and register a constraint in one step
register_variable
Register a variable with the model
register_constraint
Register a constraint with the model
PieceModel
PieceModel(model: FlowSystemModel, label_of_element: str, label_of_model: str, dims: FlowSystemDimensions | None)
Bases: Submodel
Class for modeling a linear piece of one or more variables in parallel
Attributes
all_submodels
property
Get all submodels including nested ones recursively.
variables_direct
property
Variables of the model, excluding those of sub-models
constraints_direct
property
Constraints of the model, excluding those of sub-models
constraints
property
All constraints of the model, including those of all sub-models
variables
property
All variables of the model, including those of all sub-models
Functions
add_submodels
Register a sub-model with the model
add_variables
Create and register a variable in one step
add_constraints
Create and register a constraint in one step
register_variable
Register a variable with the model
register_constraint
Register a constraint with the model
PiecewiseModel
PiecewiseModel(model: FlowSystemModel, label_of_element: str, label_of_model: str, piecewise_variables: dict[str, Piecewise], zero_point: bool | Variable | None, dims: FlowSystemDimensions | None)
Bases: Submodel
Modeling a Piecewise relation between miultiple variables. The relation is defined by a list of Pieces, which are assigned to the variables. Each Piece is a tuple of (start, end).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
FlowSystemModel
|
The FlowSystemModel that is used to create the model. |
required |
label_of_element
|
str
|
The label of the parent (Element). Used to construct the full label of the model. |
required |
label_of_model
|
str
|
The label of the model. Used to construct the full label of the model. |
required |
piecewise_variables
|
dict[str, Piecewise]
|
The variables to which the Pieces are assigned. |
required |
zero_point
|
bool | Variable | None
|
A variable that can be used to define a zero point for the Piecewise relation. If None or False, no zero point is defined. |
required |
dims
|
FlowSystemDimensions | None
|
The dimensions used for variable creation. If None, all dimensions are used. |
required |
Attributes
all_submodels
property
Get all submodels including nested ones recursively.
variables_direct
property
Variables of the model, excluding those of sub-models
constraints_direct
property
Constraints of the model, excluding those of sub-models
constraints
property
All constraints of the model, including those of all sub-models
variables
property
All variables of the model, including those of all sub-models
Functions
add_submodels
Register a sub-model with the model
add_variables
Create and register a variable in one step
add_constraints
Create and register a constraint in one step
register_variable
Register a variable with the model
register_constraint
Register a constraint with the model
ShareAllocationModel
ShareAllocationModel(model: FlowSystemModel, dims: list[FlowSystemDimensions], label_of_element: str | None = None, label_of_model: str | None = None, total_max: Scalar | None = None, total_min: Scalar | None = None, max_per_hour: TemporalData | None = None, min_per_hour: TemporalData | None = None)
Bases: Submodel
Attributes
all_submodels
property
Get all submodels including nested ones recursively.
variables_direct
property
Variables of the model, excluding those of sub-models
constraints_direct
property
Constraints of the model, excluding those of sub-models
constraints
property
All constraints of the model, including those of all sub-models
variables
property
All variables of the model, including those of all sub-models
Functions
add_share
Add a share to the share allocation model. If the share already exists, the expression is added to the existing share. The expression is added to the right hand side (rhs) of the constraint. The variable representing the total share is on the left hand side (lhs) of the constraint. var_total = sum(expressions)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the share. |
required |
expression
|
LinearExpression
|
The expression of the share. Added to the right hand side of the constraint. |
required |
dims
|
list[FlowSystemDimensions] | None
|
The dimensions of the share. Defaults to all dimensions. Dims are ordered automatically |
None
|
add_submodels
Register a sub-model with the model
add_variables
Create and register a variable in one step
add_constraints
Create and register a constraint in one step
register_variable
Register a variable with the model
register_constraint
Register a constraint with the model