flixopt.aggregation
This module contains the Aggregation functionality for the flixopt framework. Through this, aggregating TimeSeriesData is possible.
Attributes
Classes
Aggregation
Aggregation(original_data: DataFrame, hours_per_time_step: Scalar, hours_per_period: Scalar, nr_of_periods: int = 8, weights: Dict[str, float] = None, time_series_for_high_peaks: List[str] = None, time_series_for_low_peaks: List[str] = None)
aggregation organizing class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
original_data
|
DataFrame
|
The original data to aggregate |
required |
hours_per_time_step
|
Scalar
|
The duration of each timestep in hours. |
required |
hours_per_period
|
Scalar
|
The duration of each period in hours. |
required |
nr_of_periods
|
int
|
The number of typical periods to use in the aggregation. |
8
|
weights
|
Dict[str, float]
|
The weights for aggregation. If None, all time series are equally weighted. |
None
|
time_series_for_high_peaks
|
List[str]
|
List of time series to use for explicitly selecting periods with high values. |
None
|
time_series_for_low_peaks
|
List[str]
|
List of time series to use for explicitly selecting periods with low values. |
None
|
Functions
get_cluster_indices
Generates a dictionary that maps each cluster to a list of index vectors representing the time steps assigned to that cluster for each period.
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, List[ndarray]]
|
{cluster_0: [index_vector_3, index_vector_7, ...], cluster_1: [index_vector_1], ...} |
get_equation_indices
Generates pairs of indices for the equations by comparing index vectors of the same cluster.
If skip_first_index_of_period
is True, the first index of each period is skipped.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
skip_first_index_of_period
|
bool
|
Whether to include or skip the first index of each period. |
True
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, ndarray]
|
Tuple[np.ndarray, np.ndarray]: Two arrays of indices. |
AggregationParameters
AggregationParameters(hours_per_period: float, nr_of_periods: int, fix_storage_flows: bool, aggregate_data_and_fix_non_binary_vars: bool, percentage_of_period_freedom: float = 0, penalty_of_period_freedom: float = 0, time_series_for_high_peaks: List[TimeSeriesData] = None, time_series_for_low_peaks: List[TimeSeriesData] = None)
Initializes aggregation parameters for time series data
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hours_per_period
|
float
|
Duration of each period in hours. |
required |
nr_of_periods
|
int
|
Number of typical periods to use in the aggregation. |
required |
fix_storage_flows
|
bool
|
Whether to aggregate storage flows (load/unload); if other flows are fixed, fixing storage flows is usually not required. |
required |
aggregate_data_and_fix_non_binary_vars
|
bool
|
Whether to aggregate all time series data, which allows to fix all time series variables (like flow_rate), or only fix binary variables. If False non time_series data is changed!! If True, the mathematical Problem is simplified even further. |
required |
percentage_of_period_freedom
|
float
|
Specifies the maximum percentage (0–100) of binary values within each period that can deviate as "free variables", chosen by the solver (default is 0). This allows binary variables to be 'partly equated' between aggregated periods. |
0
|
penalty_of_period_freedom
|
float
|
The penalty associated with each "free variable"; defaults to 0. Added to Penalty |
0
|
time_series_for_high_peaks
|
List[TimeSeriesData]
|
List of TimeSeriesData to use for explicitly selecting periods with high values. |
None
|
time_series_for_low_peaks
|
List[TimeSeriesData]
|
List of TimeSeriesData to use for explicitly selecting periods with low values. |
None
|
Functions
AggregationModel
AggregationModel(model: SystemModel, aggregation_parameters: AggregationParameters, flow_system: FlowSystem, aggregation_data: Aggregation, components_to_clusterize: Optional[List[Component]])
Bases: Model
The AggregationModel holds equations and variables related to the Aggregation of a FLowSystem. It creates Equations that equates indices of variables, and introduces penalties related to binary variables, that escape the equation to their related binaries in other periods
Modeling-Element for "index-equating"-equations
Attributes
Functions
add
add(item: Union[Variable, Constraint, Model], short_name: Optional[str] = None) -> Union[linopy.Variable, linopy.Constraint, Model]
Add a variable, constraint or sub-model to the model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
Union[Variable, Constraint, Model]
|
The variable, constraint or sub-model to add to the model |
required |
short_name
|
Optional[str]
|
The short name of the variable, constraint or sub-model. If not provided, the full name is used. |
None
|