iode.Simulation.model_simulate

Simulation.model_simulate(self, from_period: str | Period, to_period: str | Period, list_eqs: str | List[str] = None)

Run the simulation of a model for a given sample.

To simulate a model, all equations of the model must have been loaded or created. In addition, all the variables and scalars used in the model equations must have been loaded or created. Values of exogenous variables and of scalar cannot be \(NA\) (Not Available) over the simulation sample.

Parameters:
from_periodstr or Period

The starting period for the simulation.

to_periodstr or Period

The ending period for the simulation.

list_eqsstr or list(str), optional

List of equations representing the model. Default to empty (all equations).

Examples

>>> from iode import SAMPLE_DATA_DIR, equations, identities, lists, scalars, variables 
>>> from iode import Simulation
>>> equations.load(f"{SAMPLE_DATA_DIR}/fun.eqs")
>>> identities.load(f"{SAMPLE_DATA_DIR}/fun.idt")
>>> lists.load(f"{SAMPLE_DATA_DIR}/fun.lst")
>>> scalars.load(f"{SAMPLE_DATA_DIR}/fun.scl")
>>> variables.load(f"{SAMPLE_DATA_DIR}/fun.var")
>>> # exogeneous variable 
>>> equations["UY"].lec
'UY := NATY-NDOMY-NIY-NGY-(EFXY-EFMY)-NFY'
>>> # reset values
>>> variables["UY", "2000Y1:2015Y1"] = 0.0
>>> variables["UY", "2000Y1:2015Y1"]    
[0.0, 0.0, ..., 0.0, 0.0]
>>> # endogenous variable
>>> identities["XNATY"]
'grt NATY'
>>> variables["XNATY", "2000Y1:2015Y1"]     
[0.22, 0.699999988079071, 0.4, 0.7, ..., -0.20000000298023224, -0.20000000298023224]
>>> # simulate the model (no reordering)
>>> simu = Simulation()
>>> simu.model_simulate("2000Y1", "2015Y1")
>>> variables["UY", "2000Y1:2015Y1"]    
[624.1781881798956, 645.0542977503601, 661.6074127102179, ..., 525.1258272992568]