zen_garden.optimization_setup

Class defining the optimization model.

The class takes as inputs the properties of the optimization problem. The properties are saved in the dictionaries analysis and system which are passed to the class. After initializing the model, the class adds carriers and technologies to the model and returns it. The class also includes a method to solve the optimization problem.

Classes

OptimizationSetup(config, scenario_dict, ...)

Class defining the optimization model.

class zen_garden.optimization_setup.OptimizationSetup(config, scenario_dict: dict, input_data_checks)

Class defining the optimization model.

The class takes as inputs the properties of the optimization problem. The properties are saved in the dictionaries analysis and system which are passed to the class. After initializing the model, the class adds carriers and technologies to the model and returns it. The class also includes a method to solve the optimization problem.

__init__(config, scenario_dict: dict, input_data_checks)

Setup optimization of the energy system.

This function sets up the optimization process for the energy system using the provided configuration, scenario data, and input data checks.

Parameters:
  • config (Config) – Config object used to extract the analysis, system, and solver dictionaries.

  • scenario_dict (dict) – Dictionary defining the scenario, including data such as resources, demand, etc.

  • input_data_checks (InputDataChecks) – Input data checks object to verify the integrity of the input data.

add_carbon_emission_cumulative(decision_horizon)

Adds current emissions to existing emissions.

This function adds carbon emissions from the current optimization step to the existing carbon emissions.

Parameters:

decision_horizon (list or int) – A list of the years to transfer emissions to existing emissions.

Returns:

None

add_element(element_class, name)

Add an element to the element_dict with the class labels as key.

Parameters:
  • element_class – Class of the element

  • name – Name of the element

add_elements()

Set up the parameters, variables and constraints of the carriers.

add_folder_paths(set_name, path, subsets=None)

Add file paths of element to paths dictionary.

Parameters:
  • set_name – name of set

  • path – path to folder

  • subsets – list of subsets

add_new_capacity_addition(decision_horizon)

Adds the newly built capacity to the existing capacity.

This function adds installed capacities from the current optimization step to existing capacities in the model. It also adds costs from the installed capacities to existing capacity investment. Capacity values whose magnitude is below that specified by the solver setting “rounding_decimal_points_capacity” are set to zero.

Parameters:

decision_horizon (list or int) – A list of the years to transfer installed capacities to existing capacities.

Returns:

None

add_results_of_optimization_step(step_horizon)

Adds capacity additions and carbon emissions to the next optimization step.

This function takes the capacity additions and carbon emissions of the current optimization step and adds them to the existing capacity and existing emissions of the next optimization step. Values from the currently simulated year are added as existing capacities and emissions for future steps.

Parameters:

step_horizon (int) – The year index of the current optimization step. In myopic foresight, capacities and emissions from this step are added to existing capacities and emissions.

Returns:

None

append_attribute_of_element_to_dict(element, attribute_name, dict_of_attributes, dict_of_units, capacity_type=None)

Get attribute values of all elements in this class.

Parameters:
  • element – element of class

  • attribute_name (str) – str name of attribute

  • dict_of_attributes (dict) – dict of attribute values

  • capacity_type – capacity type for which attribute extracted. If None, not listed in key

  • dict_of_attributes – returns dict of attribute values

check_for_subindex(component_data, custom_set)

Check if the custom_set can be a subindex of component_data.

returns subindexed component_data.

Parameters:
  • component_data – extracted data as pd.Series

  • custom_set – custom set as subindex of component_data

Returns:

component_data: extracted subindexed data as pd.Series

construct_optimization_problem()

Constructs the optimization problem.

create_paths()

This method creates a dictionary with the paths of the data split by carriers, networks, technologies.

get_all_elements(cls)

Get all elements of the class in the energy system.

get_all_names_of_elements(cls)

Get all names of elements in class.

Parameters:

cls – class of the elements to return

Returns:

names_of_elements: list of elements in this class

get_attribute_of_all_elements(cls, attribute_name: str, capacity_types=False, return_attribute_is_series=False)

Get attribute values of all elements in a class.

Parameters:
  • cls – class of the elements to return

  • attribute_name (str) – name of attribute

  • capacity_types (boolean) – if attributes extracted for all capacity types

  • return_attribute_is_series (boolean) – if information on attribute type is returned

  • dict_of_attributes (dict) – dict of attribute values

  • attribute_is_series – return information on attribute type

get_attribute_of_specific_element(cls, element_name: str, attribute_name: str)

Get attribute of specific element in class.

Parameters:
  • cls – class of the elements to return

  • element_name – str name of element

  • attribute_name – str name of attribute

Returns:

attribute_value: value of attribute

get_class_set_of_element(element_name: str, klass)

Returns the set of all elements in the class of the element.

Parameters:
  • element_name – name of element

  • klass – class of the elements to return

Returns:

class_set: set of all elements in the class of the element

get_decision_horizon(step_horizon)

Return the decision horizon.

Returns the decision horizon for the optimization step, i.e., the time steps for which the decisions are saved.

Parameters:

step_horizon – step of the rolling horizon

Returns:

decision_horizon: list of time steps in the decision horizon

get_element(cls, name: str)

Get single element in class by name.

Parameters:
  • name – name of element

  • cls – class of the elements to return

Returns:

element: return element whose name is matched

get_element_class(name: str)

Get element class by name. If not an element class, return None.

Parameters:

name – name of element class

Returns:

element_class: return element whose name is matched

get_optimization_horizon()

Returns list of optimization horizon steps.

initialize_component(calling_class, component_name, index_names=None, set_time_steps=None, capacity_types=False)

Initialize a modeling component by extracting the stored input data.

Parameters:
  • calling_class – class from where the method is called

  • component_name – name of modeling component

  • index_names – names of index sets, only if calling_class is not EnergySystem

  • set_time_steps – time steps, only if calling_class is EnergySystem

  • capacity_types – boolean if extracted for capacities

  • component_data – data to initialize the component

overwrite_time_indices(step_horizon)

Select subset of time indices, matching the step horizon.

Parameters:

step_horizon – step of the rolling horizon

read_input_csv()

Read the input and conducts the time series aggregation.

set_base_configuration(scenario='', elements=None)

Set base configuration.

Parameters:
  • scenario – name of base scenario

  • elements – elements in base configuration

solve()

Create model instance by assigning parameter values and initializing sets.

write_IIS(scenario='')

Write an ILP file to print the IIS if infeasible and using Gurobi.