nismod/smif

DecisionModule does not accumulate state

Closed this issue · 2 comments

We are dealing with system state in an inconsistent manner, which means that while pre-specified planning decisions are included in every year of the state file, outputs from previous years of a decision module are not rewritten to a state file.

Solutions:

TLDR; either write separately and read in a bundle, or read separately and write in a bundle;

  1. only write pre-specified planning in base timestep state file and accumulate state through successive years for each decision iteration/timestep path followed, rewriting only the current decisions in each state file, reading them all in through the data_handle.get_state method
  2. the statefile in each timestep holds the complete history, so only the most recent statefile is needed to see a history of all the interventions that took place in a particular timestep/iteration path.

In chat with Tom:

  • data_handle.get_state should read state from three sources - initial conditions, pre-specified planning and decision_module decisions
  • decision module needs to read the state in the previous year (consisting of only available interventions and accumulated from the base year) and write state for the current decision timestep

Methods to tidy up include:

data_layer/*/*_data_store.py

  • read_strategy_interventions
  • read_initial_conditions

data_layer/store.py

  • read_strategies
  • read_all_initial_conditions
  • read_strategy_interventions

decisions/decision.py

  1. Strip out all concept of multiple strategies and pre-specified planning - both initial conditions and pre-specified planning can be handled using the existing concept of state. They should be read in and filtered by the get_state method for the current timestep.
    • this may require interventions to drop lifetime attribute, and the state to be pre-computed so that an intervention is present in the state for each timestep during its lifetime
  2. Decision module creates a register of available interventions. These should contain the set of interventions minus the subset of interventions installed in pre-specified and initial condition states.
  3. Decision module requires access to previous timestep/iteration state. (#334)
  4. DecisionManager get_and_save_decisions writes state for the current timestep which excludes pre-specified and initial_conditions