Please enable JavaScript to view this site.

Vensim Help

It is possible and very fast to use SyntheSim in the full Vensim DLL (SyntheSim is not available in the minimal DLL).  To do this issue a command to start SyntheSim.  You will probably also usually want to turn off  automatic simulation whenever a changes is made.  For example, consider the following simple sensitivity simulation using SyntheSim:

Dim varvals(200) As Single

Dim timevals(200) As Single

result = vensim_command("MENU>SYNTHESIM|O")

If result = 0 Then Exit Sub

result = vensim_command("SYNTHESIM>AUTO|0")

result = vensim_get_data("", "Population", "", varvals(1), timevals(1), 200) 

For initpop = 1 To 9

 num$ = initpop

 SETVAL$ = "SIMULATE>SETVAL|population initial=" + num$ + "E9"

 result = vensim_command(SETVAL$)

 vensim_command ("SYNTHESIM>GO|0")

 result = vensim_get_data("", "Population", "", varvals(1), timevals(1), 200)

 Next initpop

vensim_command ("SPECIAL>STOPSIM")

The first call to vensim_get_data is used to signal Vensim that it should be ready to return values for the variable "Population."  By turning AUTO off we can set multiple parameters without having Vensim initiate a simulation.  We then call SYNTHESIM>GO|0 telling Vensim to simulation, but not write the results.  This is very fast.  The call to vensim_get_data then fetches the values from memory.  Finally we close the process with SPECIAL>STOPSIM to close down SyntheSim.  This frees up resources and is good practice.