Please enable JavaScript to view this site.

Vensim Help

Navigation: Reference Guide > DSS Supplement > Compiled Simulations

Details of the Compilation Process

Scroll Prev Top Next More

Vensim performs compiled simulations by creating a Dynamic Link Library (sim.dll that contains the computer code necessary to execute the model equations.  Vensim maintains control of the simulation, calling this DLL to compute model values.  The DLL, in turn, calls Vensim to evaluate the different functions used.

When you ask to have a compiled simulation performed, Vensim orders the model's equations and then creates a C language file mdl.c for these equations.  The file contains eight functions:

mdl_desc returns a description of the model.
comp_rate computes the rates of changes for the levels.
comp_delay computes the inputs to delays.
init_time initializes to begin a simulation.
init_tstep initializes TIME_STEP before beginning a simulation.
comp_init computes the initial values of all Levels.  Auxiliaries needed to initialize the Levels are also computed.
comp_reinit computes the initial values of all equations using the REINITIAL function.
comp_aux computes the values of all Auxiliaries, given the values of all the Levels.

Vensim calls mdl_desc to verify the source of the model, init_time to find the starting Time, init_tstep to find the initial value of TIME_STEP, comp_init to initialize levels and then performs the simulation by calling comp_aux and comp_rate and performing integration steps.  comp_reinit is only called during resume.

The separate init_tstep is used because TIME_STEP can be input as an exogenous driver, and this requires a value for time.  Since TIME_STEP is usually a constant, init_tstep is most commonly an empty function.  Depending on what you have in the model some of the other functions may also be empty.

Because models can be quite large, Vensim breaks up the functions into smaller components. This make it much faster to compile larger models. If you look at mdl.c you will see that comp_aux simply calls one or more mdl_funcn() functions. To control the size of these function use the "Variable count for function breaks in mdl.c" setting in th Advanced tab of the Global Option Settings dialog (Tools>Options).

Having written the file mdl.c, Vensim invokes the batch file mdl.bat located in the compiled simulation directory (mdl.bat is discussed further below).  This batch file is executed in a DOS style console window aht should appear and disappear by itself. If there are any errors encountered while compiling the error messages will go to this window and it will pause waiting for a keystroke to close.  See Compile Errors below for what to do next.