Simulation generator

openfisca_core.scripts.simulation_generator.make_simulation(tax_benefit_system, nb_persons, nb_groups, **kwargs)[source]

Generate a simulation containing nb_persons persons spread in nb_groups groups.

Example: >>> from openfisca_core.scripts.simulation_generator import make_simulation >>> from openfisca_france import CountryTaxBenefitSystem >>> tbs = CountryTaxBenefitSystem() >>> simulation = make_simulation( … tbs, 400, 100 … ) # Create a simulation with 400 persons, spread among 100 families >>> simulation.calculate(“revenu_disponible”, 2017)

openfisca_core.scripts.simulation_generator.randomly_init_variable(simulation, variable_name, period, max_value, condition=None)[source]

Initialise a variable with random values (from 0 to max_value) for the given period. If a condition vector is provided, only set the value of persons or groups for which condition is True.

Example: >>> from openfisca_core.scripts.simulation_generator import ( … make_simulation, … randomly_init_variable, … ) >>> from openfisca_france import CountryTaxBenefitSystem >>> tbs = CountryTaxBenefitSystem() >>> simulation = make_simulation( … tbs, 400, 100 … ) # Create a simulation with 400 persons, spread among 100 families >>> randomly_init_variable( … simulation, … “salaire_net”, … 2017, … max_value=50000, … condition=simulation.persons.has_role(simulation.famille.DEMANDEUR), … ) # Randomly set a salaire_net for all persons between 0 and 50000? >>> simulation.calculate(“revenu_disponible”, 2017)

Return type:

None