zen_garden.postprocess.postprocess

Class is defining the postprocessing of the results. The class takes as inputs the optimization problem (model) and the system configurations (system). The class contains methods to read the results and save them in a result dictionary (resultDict).

Classes

Postprocess(optimization_setup, scenarios, ...)

Class is defining the postprocessing of the results.

class zen_garden.postprocess.postprocess.Postprocess(optimization_setup: OptimizationSetup, scenarios, model_name, subfolder=None, scenario_name=None, param_map=None)

Class is defining the postprocessing of the results.

__init__(optimization_setup: OptimizationSetup, scenarios, model_name, subfolder=None, scenario_name=None, param_map=None)

Postprocessing of the results of the optimization.

Parameters:
  • model – optimization model

  • model_name – The name of the model used to name the output folder

  • subfolder – The subfolder used for the results

  • scenario_name – The name of the current scenario

  • param_map – A dictionary mapping the parameters to the scenario names

flatten_dict(dictionary)

Creates a copy of the dictionary where all numpy arrays are recursively flattened to lists such that it can be saved as json file.

Parameters:

dictionary – The input dictionary

Returns:

A copy of the dictionary containing lists instead of arrays

get_index_list(doc)

Get index list from docstring.

Parameters:

doc – docstring

Returns:

index list

get_time_steps_year2operation()

Returns a HDF5-Serializable version of the dict_time_steps_year2operation dictionary.

get_time_steps_year2storage()

Returns a HDF5-Serializable version of the dict_time_steps_year2storage dictionary.

save_analysis()

Saves the analysis dict as json.

save_benchmarking_data()

Saves the benchmarking data to a json file.

save_duals()

Saves the dual variable values to a h5 file.

save_param()

Saves the Param values to a json file which can then be post-processed immediately or loaded and postprocessed at some other time.

save_param_map()

Saves the param_map dict as yaml.

save_reduced_costs()

Saves the reduced cost values of variables to a h5 file.

save_scenarios()

Saves the scenario dict as json.

save_sequence_time_steps(scenario=None)

Saves the dict_all_sequence_time_steps dict as json.

Parameters:

scenario – name of scenario for which results are postprocessed

save_sets()

Saves the Set values to a json file which can then be post-processed immediately or loaded and postprocessed at some other time.

save_solver()

Saves the solver dict as json.

save_system()

Saves the system dict as json.

save_unit_definitions()

Saves the user-defined units as txt.

save_var()

Saves the variable values to a json file which can then be post-processed immediately or loaded and postprocessed at some other time.

write_file(name, dictionary, format=None, mode='w')

Writes the dictionary to file as json, if compression attribute is True, the serialized json is compressed and saved as binary file.

Parameters:
  • name – Filename without extension

  • dictionary – The dictionary to save

  • format – Force the format to use, if None use output_format attribute of instance

  • mode – Writing mode for python file. The two options are ‘w’ and ‘a’. The former create a new file while the latter will append to an existing file. Appending files is currently only supported for h5 files.