Represents a simulation, and handles the calculation logic
Return the value of variable_name
for period
, if this value is alreay in the cache (if it has been set as an input or previously calculated).
Unlike calculate()
, this method does not trigger calculations and does not use any formula.
There are count
persons
There are count
instances of each group entity, containing one person
Every person has, in each entity, the first role
Build a simulation from input_dict
This method uses build_from_entities
if entities are fully specified, or build_from_variables
if not.
input_dict (dict) – A dict represeting the input of the simulation
Build a simulation from a Python dict input_dict
fully specifying entities.
Examples:
>>> simulation_builder.build_from_entities({
'persons': {'Javier': { 'salary': {'2018-11': 2000}}},
'households': {'household': {'parents': ['Javier']}}
})
Build a simulation from a Python dict input_dict
describing variables values without expliciting entities.
This method uses build_default_simulation
to infer an entity structure
Example:
>>> simulation_builder.build_from_variables(
{'salary': {'2016-10': 12000}}
)
Preprocess input_dict
to explicit entities defined using the single-entity shortcut
Example:
>>> simulation_builder.explicit_singular_entities(
{'persons': {'Javier': {}, }, 'household': {'parents': ['Javier']}}
)
>>> {'persons': {'Javier': {}}, 'households': {'household': {'parents': ['Javier']}}