Dump solph model (with solution) into file and store it from file


Does anyone know if it is possible to dump oemof.solph model (om) with solutions into a file and store it from file like for solph energy system? (es.dump(om, file_path), es.store(file_path))

Indeed, I tried to dump solph om into file using pickle, dill without success. I got the following error: TypeError: can’t pickle dict_keys objects.

Thanks in advance.

Long Lê

Hi @vlle,

As you might know, the typical workflow is to to store the results in the energy system:

energy_system.results['main'] = processing.results(model)
energy_system.results['main'] = views.convert_keys_to_strings(energy_system.results['main'])
energy_system.results['meta'] = processing.meta_results(model)
energy_system.dump(DUMP_PATH, "file.oemof")

Note the function convert_keys_to_strings(args). I guess that’s where the magic happens that is needed to use pickle.

Thank you very much @pschoen for your answer.

Text and images licensed under CC BY 4.0Data licensed under CC0 1.0Code licensed under MITSite terms of serviceOpenmod mailing listOpenmod wiki.