Page 1 of 1

Clarification of the purpose of vensim_continue_simulation

Posted: Wed Apr 20, 2016 4:50 am
by pbreach
I'm trying to use a combination of vensim_start_simulation, vensim_continue_simulation, vensim_finish_simulation if a loop for which the simulation is carried out bit by bit returning control to the user after a given number of time steps.

The pseudo-code looks something like this:

Code: Select all

for i in 1:step:100
    #Here is where the user is given control before the simulation of a given time step is carried out
    vensim_start_simulation(0, 2, 1)
    vensim_continue_simulation(step)
    vensim_finish_simulation()
If I were to print the value of the current model time in my program for a value of step=10, I would expect to see the following output:

0
10
20
30
40
50
60
70
80
90

In my program it appears as though the step value is being ignored as I get the following (the .vpm is set for a time step of 1 minute):

0
1
2
3
4
5
6
7
8
9

Can anyone tell me what seems to be the problem here? The program is written in Python. In case it is relevant here is how this result was obtained:

Code: Select all

model = venpy.load("../models/coffee_cup.vpm")

model.cmd("SIMULATE>RUNNAME|Test")

model.cmd("MENU>GAME|O")

for _ in range(0, 100, 10):
    print(model['Time'])
    model.dll.vensim_start_simulation(0, 2, 1)
    model.dll.vensim_continue_simulation(10)
    model.dll.vensim_finish_simulation()

Re: Clarification of the purpose of vensim_continue_simulati

Posted: Thu Apr 21, 2016 9:30 am
by Administrator
I think we'll remove the vensim_start_sim etc functions soon as they don't really work well.

Use venapp commands instead when running a game. The following should work ok (VBA code).

nResult = vensim_command("SPECIAL>LOADMODEL|coffee_cup.vpm")
nResult = vensim_command("SIMULATE>RUNNAME|Test")
result = vensim_command("MENU>GAME|O")
result = vensim_command("GAME>GAMEINTERVAL|2")

For i = 0 To 100

nResult = vensim_command("GAME>GAMEON")
nResult = vensim_get_val("time", varval)

Next i

Re: Clarification of the purpose of vensim_continue_simulati

Posted: Fri Apr 22, 2016 2:55 am
by pbreach
Thank you for your prompt reply. The code is working now! One last question though. Does the value set to GAMEINTERVAL represent the number of time steps or the length of time between giving control back to the user? I am thinking of the case where the TIME STEP != 1. I've been looking through the Venapp documentation, and it only says, "Sets the interval that will be covered by each GAME>GAMEON command."

Re: Clarification of the purpose of vensim_continue_simulati

Posted: Fri Apr 22, 2016 11:57 am
by Administrator
GAMEINTERVAL represents the length of time to elapse before giving control back to the user.