Goals/Commonalities between Operational Model and specl:
A functional operational model (for water supply or other simulation), requires only a method of sharing model state.
state allows calculations to be done on any publicly modifiable state variable
Supporting routines need only a way to read & write to state.
Tightly coupled supporting modules should write to state at the end of every timestep, and read from state after executing coupled operational models.
Ultimately, a robust and flexible data structure is the key component.
hsp2 special operations also requires the ability to share state, and thus, theoretically, methods of state sharing developed in this operational model could facilitate the implementation of special actions in hsp2.
Added bonus to read and write from timeseries.
Data Structures
state_ix: Dict that holds numeric state values. It is a flattened, integer keyed, version of hdf5.
dict_ix is integer keyed Dict to store values of array/matrix objects.
ex 1: lookup tables holding monthly consumptive use coefficients
ex 2: the simtimer containing the entire set of time values available in the simulation: year, month, day, hour, modays, etc, keyed on step
ts_ix - Dict of timeseries data (TBD: may be redundant to dict_ix, given that all ts data can be keyed via an hdf5 path)
model_object_cache - Dict of objects, only used in parsing and setup, not numpy/numba compatible
state_paths is flattened, string keyed, version of hdf5. Its keys are full path to hdf5 STATE, and its values point to the key for use in all other runtime Dicts
Design Requirements/Challenges of Implementation
Object Orientation - the current implementation uses the term classes in 2 ways.
Conceptually: as the numba compiler make it difficult (impossible?) to pass in dynamic lists of classes of a multiple types. Thus, classes are simulated via the functions that are called to execute them, but do not have any actual type of class in the numba code.
Handlers: the handlers that load dynamic model operations elements (parsed from JSON or created manually), and convert into sets of ordered and linked executable model opcodes.
Key primitive objects
ModelObject: the base class type, can have inputs, and component/child objects, but does not possess any calculations of its own.
Equation: equation operations amongst data inputs.
DataMatrix: provide 1-D and 2-D list lookups with exact key matching or multiple modes of interpolation
Model Links
Inputs: Objects can have links to any state variable via inputs.
if a variable is named as an input without a full state path, the model class functions search in this order:
children; grand-children are not searched, however, if a direct child has an established input of a matching named variable from a grandchild, this link will be returned.
siblings
parent
grandparent
ModelLinkage: a specific link from one state variable to another
ModelBroadcast: A general data sharing/linkage framework that establishes data "channels" with 1 or more values in it
broadcast objects: allows objects to make data available to any other objects, and register objects that allow many objects to funnel data into a variety of variable slots, additively i.e. if 3 objects push data to a single register, the state value of the rgister at the end of a timestep is val1 + val2 + val3
SimTimer
Tokenization
used to provide pseudo "class" support
entire model domain is passed in via integer keyed IDs in Dict called op_tokens
integer key
all tokens are integers that reference either class-specific option values OR memory locations in state_ix
Integration
routines that integrate with the operational model must know how to transfer data into an out of the state_ix Dict
Info
hcds
develop-specact
: https://github.com/respec/HSPsquared/tree/develop-specactGoals
hsp2
special operations also requires the ability to share state, and thus, theoretically, methods of state sharing developed in this operational model could facilitate the implementation of special actions inhsp2
.state_ix
: Dict that holds numeric state values. It is a flattened, integer keyed, version ofhdf5
.dict_ix
is integer keyed Dict to store values of array/matrix objects.step
ts_ix
- Dict of timeseries data (TBD: may be redundant todict_ix
, given that all ts data can be keyed via an hdf5 path)model_object_cache
- Dict of objects, only used in parsing and setup, notnumpy/numba
compatiblestate_paths
is flattened, string keyed, version ofhdf5
. Its keys are full path to hdf5STATE
, and its values point to the key for use in all other runtime Dictsnumba
code.op_tokens
state_ix
state_ix
Dicthydr()
Next Steps: