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
Mathematical model implementation for investment decisions.
Creates optimization variables and constraints for investment sizing decisions, supporting both binary and continuous sizing with comprehensive effect modeling.
Mathematical Formulation
See https://flixopt.github.io/flixopt/latest/user-guide/mathematical-notation/features/InvestParameters/
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
StatusModel ¶
StatusModel(model: FlowSystemModel, label_of_element: str, parameters: StatusParameters, status: Variable, previous_status: DataArray | None, label_of_model: str | None = None)
Bases: Submodel
Mathematical model implementation for binary status.
Creates optimization variables and constraints for binary status modeling, state transitions, duration tracking, and operational effects.
Mathematical Formulation
See https://flixopt.github.io/flixopt/latest/user-guide/mathematical-notation/features/StatusParameters/
This feature model is used to model the status (active/inactive) state of flow_rate(s). It does not matter if 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 | StatusParameters | The parameters of the feature model. | required |
status | Variable | The variable that determines the active state | required |
previous_status | DataArray | 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¶
inactive property ¶
Binary inactive state variable.
Note
Only created when downtime tracking is enabled (min_downtime or max_downtime set). For general use, prefer the expression 1 - status instead of this 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: Collection[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: Collection[FlowSystemDimensions] | None)
Bases: Submodel
Mathematical model implementation for piecewise linear approximations.
Creates optimization variables and constraints for piecewise linear relationships, including lambda variables, piece activation binaries, and coupling constraints.
Mathematical Formulation
See https://flixopt.github.io/flixopt/latest/user-guide/mathematical-notation/features/Piecewise/
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 | Collection[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
PiecewiseEffectsModel ¶
PiecewiseEffectsModel(model: FlowSystemModel, label_of_element: str, label_of_model: str, piecewise_origin: tuple[str, Piecewise], piecewise_shares: dict[str, Piecewise], zero_point: bool | Variable | 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_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: Numeric_PS | None = None, total_min: Numeric_PS | None = None, max_per_hour: Numeric_TPS | None = None, min_per_hour: Numeric_TPS | 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