SimulationBuilder

class openfisca_core.simulation_builder.SimulationBuilder[source]
build_default_simulation(tax_benefit_system, count=1, **kwargs)[source]
Build a simulation where:
  • 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_from_dict(tax_benefit_system, input_dict, default_period=None, **kwargs)[source]

Build a simulation from input_dict

This method uses build_from_entities if entities are fully specified, or build_from_variables if not.

Parameters:
  • input_dict (dict) – A dict represeting the input of the simulation
  • default_period – If provided, inputs variables without an explicit period will be set for default_period
  • kwargs – Same keywords argument than the Simulation constructor
Returns:

A Simulation

build_from_entities(tax_benefit_system, input_dict, default_period=None, **kwargs)[source]

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_from_variables(tax_benefit_system, input_dict, default_period=None, **kwargs)[source]

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}}
    )
explicit_singular_entities(tax_benefit_system, input_dict)[source]

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']}}