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

Stopping policy #36

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Stopping policy #36

wants to merge 14 commits into from

Conversation

boazbk
Copy link

@boazbk boazbk commented Aug 20, 2020

This pull request makes edits to run_tti_sim in sim_loop.py to add support for stopping the simulation early, for example when a sufficiently large outbreak is detected that the mitigation is "outside the model". It also adds support for logging the history and for suppressing print statements.

Suppressing print statements is via a parameter verbose - True (default) means print statement are printed as currently, False means they are suppressed.

I didn't want to change the return value of the function, so am achieving logging by taking as a parameter a dictionary history. If this parameter is None then no logging takes place. Otherwise, at each time t the loop runs, we store in history[t] a dictionary containing the current parameters of the model, as well as testing outcomes.

It is easy (one line of code) to transform the resulting dictionary into a pandas DataFrame, but I didn't want to add a dependency to this module.

Stopping early is is achieved by adding a parameter stopping_policy that is a function taking the model and the history and returning True to stop and False otherwise.

@mihaibanciu
Copy link

mihaibanciu commented Aug 20, 2020

Just a quick note that setting the parameter print_interval=0 inside run() also suppresses the regular printouts. This is not available inside run_tti_sim?

@boazbk
Copy link
Author

boazbk commented Aug 20, 2020

At least from a quick search I don't see a print_interval in sim_loops.py. run also has a verbose parameter that run_tti_sim is missing. At the moment what I implemented is a simple True/False verbose.

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.

None yet

2 participants