Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add load_pickle mode and create_pickle_in_report option #205

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

stefansc1
Copy link
Collaborator

Implements #116

Requires dill, as standard pickle can't handle parametrized Trip.consumption.calculate_consumption.interpol_function

@stefansc1 stefansc1 requested a review from j-brendel July 31, 2024 10:40

mode = ["load_pickle"]

Instead of simulating given scenario, read in pickle file instead. Needs the `load_pickle` option to point to a pickle file. If the `load_pickle` option is set, `load_pickle` must be the first mode. However, this mode may come in later in the mode chain again, reloading schedule and scenario from file. Options in config file that are stored in schedule are ignored.
Copy link
Collaborator

@PaulScheerRLI PaulScheerRLI Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of simulating ("a" or "the") given scenario.

Suggestion for the rest, with more focus on what the mode does
"Instead of generating a scenario based on file for trip, vehicle and station data, a previously simulated scenario is loaded. This scenario already contains results. Modes can be chained after load_pickle in the usual fashion. Multiple "load_pickle" modes per chain are allowed....

Copy link
Collaborator

@PaulScheerRLI PaulScheerRLI Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# However, cost parameters are supposed to be mutable after loading from pickle
should be mentioned as well

# Pickle current schedule and scenario during report mode
# create_pickle_in_report = false
# Load this pickle file, expects load_pickle as first mode
# load_pickle = "example.pkl"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make verbose that its a path. for me "load_pickle" reads like a bool

Comment on lines +28 to +31
if isinstance(args.mode, list):
first_mode = args.mode[0]
else:
first_mode = args.mode
Copy link
Collaborator

@PaulScheerRLI PaulScheerRLI Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we cast to list?
calling a single mode = [load_pickle]
or mode = load_pickle
would only load the schedule in memory and then quit, right? in other words it should be enforced it is a list with at least one element following. but this is again not the job of simulate.
args loading should check that multiple modes are given or running the simulation has basically no use. I dont see the use in backwards compatibility at this point, since a single mode does not really produce any useful output anymore @j-brendel

its also a duplication of simulate.py 98ff
how about moving the cast of simulate.py to previous args handling. then modes_simulation() can skip it as well as simulate

Comment on lines +28 to +36
if isinstance(args.mode, list):
first_mode = args.mode[0]
else:
first_mode = args.mode
assert first_mode == "load_pickle", "Load pickle: first mode must be load_pickle"
# schedule and scenario read out from pickle file in first mode
# DataContainer is part of schedule
schedule = None
scenario = "pickle" # must not be None
Copy link
Collaborator

@PaulScheerRLI PaulScheerRLI Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the above change i would like

assert args.mode[0] == "load_pickle"
schedule, scenario = load_pickle(None, None, args=args)
args.mode = args.mode[1:]

i really dislike changing type of scenario, even for just a short while.

Copy link
Collaborator

@PaulScheerRLI PaulScheerRLI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please consider my suggestions.
Also dev must be merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants