iode.Simulation.model_simulate_SCC

Simulation.model_simulate_SCC(from_period: str | Period, to_period: str | Period, pre_name: str = '_PRE', inter_name: str = '_INTER', post_name: str = '_POST', quiet: bool = False) bool[source]

Simulates a model previously decomposed into Strongly Connex Components (SCC) and reordered. It is intended to be called after the method Simulation.model_calculate_SCC().

To improve performance at simulation start-up, the simulation process has been divided into 2 stages. The first only deals with model reordering (see method Simulation.model_calculate_SCC()), the second with simulation (see method Simulation.model_simulate()).

Parameters:
from_periodstr or Period

The starting period for the simulation.

to_periodstr or Period

The ending period for the simulation.

pre_namestr, optional

Name of the list representing the pre-recursive equations. Default to “_PRE”.

inter_namestr, optional

Name of the list representing the interdependent equations. Default to “_INTER”.

post_namestr, optional

Name of the list representing the post-recursive equations. Default to “_POST”.

quietbool, optional

If True, the simulation will not display log messages. Default to False.

Returns:
bool

True if the simulation was successful, False otherwise.

Examples

>>> from iode import SAMPLE_DATA_DIR, equations, identities, lists, scalars, variables 
>>> from iode import Simulation
>>> equations.load(f"{SAMPLE_DATA_DIR}/fun.eqs")
Loading .../fun.eqs
274 objects loaded 
>>> identities.load(f"{SAMPLE_DATA_DIR}/fun.idt")
Loading .../fun.idt
48 objects loaded 
>>> lists.load(f"{SAMPLE_DATA_DIR}/fun.lst")
Loading .../fun.lst
17 objects loaded 
>>> scalars.load(f"{SAMPLE_DATA_DIR}/fun.scl")
Loading .../fun.scl
161 objects loaded 
>>> variables.load(f"{SAMPLE_DATA_DIR}/fun.var")
Loading .../fun.var
394 objects loaded
>>> simu = Simulation()

Step 1 - Compute the Strongly Connex Components (SCC) decomposition

>>> success = simu.model_calculate_SCC(10)
Pseudo-linking equations ....
Calculating SCC...
Calculating SCC... -> #PRE 31 - #INTER 204 - #POST 39
Reordering interdependent block...
Reordering interdependent block...
>>> success
True
>>> lists["_PRE"]
['BRUGP', 'DTH1C', 'EX', 'ITCEE', ..., 'ZZF_', 'DTH1', 'PME', 'PMS', 'PMT']
>>> len(lists["_PRE"])
31
>>> lists["_INTER"]
['PMAB', 'PXAB', 'ULCP', 'SSH3P', ..., 'YSSG', 'WCF_', 'ITEP', 'EXC', 'ITT']
>>> len(lists["_INTER"])
204
>>> lists["_POST"]
['IFU', 'SSHFF', 'PBBP', 'OCUF', ..., 'GAP', 'FLGR', 'FLF', 'DPUU', 'BENEF']
>>> len(lists["_POST"])
39

Step 2 - Simulate the model based on the 3 lists _PRE, _INTER and _POST

>>> # 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"]
Workspace: Variables
nb variables: 1
filename: ...fun.var
description: Modèle fun - Simulation 1
sample: 2000Y1:2015Y1
mode: LEVEL

name        2000Y1  2001Y1  2002Y1  ...  2013Y1  2014Y1  2015Y1
UY            0.00    0.00    0.00  ...    0.00    0.00    0.00

>>> # endogenous variable
>>> identities["XNATY"]
Identity('grt NATY')
>>> variables["XNATY", "2000Y1:2015Y1"]
Workspace: Variables
nb variables: 1
filename: ...fun.var
description: Modèle fun - Simulation 1
sample: 2000Y1:2015Y1
mode: LEVEL

 name       2000Y1  2001Y1  2002Y1  ...  2013Y1  2014Y1  2015Y1
XNATY         0.22    0.70    0.40  ...   -0.20   -0.20   -0.20
>>> success = simu.model_simulate_SCC("2000Y1", "2015Y1")
Linking equations ....
2000Y1: 1 iters - error =   0.3155 - cpu=...ms
2000Y1: 2 iters - error =    1.953 - cpu=...ms
2000Y1: 3 iters - error =   0.2335 - cpu=...ms
...
2015Y1: 10 iters - error =  0.01144 - cpu=...ms
2015Y1: 11 iters - error = 0.006679 - cpu=...ms
2015Y1: 12 iters - error = 0.0003485 - cpu=...ms
>>> success
True
>>> variables["UY", "2000Y1:2015Y1"]
Workspace: Variables
nb variables: 1
filename: ...fun.var
description: Modèle fun - Simulation 1
sample: 2000Y1:2015Y1
mode: LEVEL

name        2000Y1  2001Y1  2002Y1  ...  2013Y1  2014Y1  2015Y1
UY          624.18  645.05  661.58  ...  549.26  533.49  525.29