deflex.DeflexScenario.dump

DeflexScenario.dump(filename)

Store a solved scenario class into the binary pickle format.

The file will be stored with the suffix .dflx. If the given filename does not contain the suffix, it will be added to the filename.

It is possible to restore the dump but it is not possible to compute a restored dump. Unsolved scenarios should be stored in the xlsx or csv format.

>>> import os
>>> import deflex as dflx
>>> fn = dflx.fetch_test_files("de02_no-heat_csv")
>>> sc = dflx.create_scenario(fn, "csv")
>>> sc.results is None
True
>>> sc.compute()  # doctest: +ELLIPSIS
Welcome to the CBC MILP ...
>>> fn_dump = fn.replace("_csv", ".dflx")
>>> os.path.basename(fn_dump)
'de02_no-heat.dflx'
>>> sc.dump(fn_dump)
>>> os.path.isfile(fn_dump)
True
>>> sc2 = dflx.restore_scenario(fn_dump)
>>> type(sc2)
<class 'deflex.scenario.DeflexScenario'>
>>> sc2.results.keys()
['Problem', 'Solver', 'Solution', 'Main', 'Param', 'Meta']
>>> os.remove(fn_dump)