Reading in Values through Venapp
Reading in Values through Venapp
I'm using a .vdi file to read in changes form a database over ODBC. In Vensim the file works flawless, so I don't expect any problems there. When I try to apply the file with Venapp and for a game, at least the data series are not read. I use the following lines:
BUTTON,"Play the game (Keep the Original Settings)",50,47,45,,C,Pp,"SIMULATE>RUNNAME|MBG",STARTNEWGAME
:SCREEN STARTNEWGAME
COMMAND,,,,,,,,"GAME>GAMEINTERVAL|Gaming Interval"
COMMAND,,,,,,,,"SIMULATE>READCIN|mbg_start.vdi"
COMMAND,,,,,,,,"MENU>GAME|O"
CLOSESCREEN,"",0,0,0,0,,,,PLAY
The vensim window tells me the changes are read. Next it tells me data serie not read out for xxx and perhaps others. Could it be the combination of READCIN and GAME (READGIN will not work, hence READCIN)
If I use simulation control and put the vdi file as the change file, it also doesn't work. This time the data series are read, but the constants and lookups are not read.
The only time Venapp will run the game is when I do both (the READCIN and make it the change file). The only problem then is the script is executed 3 times, to me thats a big waste of time.
Jeroen
BUTTON,"Play the game (Keep the Original Settings)",50,47,45,,C,Pp,"SIMULATE>RUNNAME|MBG",STARTNEWGAME
:SCREEN STARTNEWGAME
COMMAND,,,,,,,,"GAME>GAMEINTERVAL|Gaming Interval"
COMMAND,,,,,,,,"SIMULATE>READCIN|mbg_start.vdi"
COMMAND,,,,,,,,"MENU>GAME|O"
CLOSESCREEN,"",0,0,0,0,,,,PLAY
The vensim window tells me the changes are read. Next it tells me data serie not read out for xxx and perhaps others. Could it be the combination of READCIN and GAME (READGIN will not work, hence READCIN)
If I use simulation control and put the vdi file as the change file, it also doesn't work. This time the data series are read, but the constants and lookups are not read.
The only time Venapp will run the game is when I do both (the READCIN and make it the change file). The only problem then is the script is executed 3 times, to me thats a big waste of time.
Jeroen
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
when using ODBC inputs you should use
SIMULATE>CHGFILE|file.vdi
before any setval commands or the menu>game command. Vensim will have to execute the .vdi script once to read constants and again on every GAME>GAMEON command to read the data (atually Vensim only executes the relevant portion of the script so it is not really that slow).
I will need to take a look to see if something is going wrong here - you READCIN should not be necessary with the .vdi file specified and READGIN should also work once the MENU>GAME command is executed.
SIMULATE>CHGFILE|file.vdi
before any setval commands or the menu>game command. Vensim will have to execute the .vdi script once to read constants and again on every GAME>GAMEON command to read the data (atually Vensim only executes the relevant portion of the script so it is not really that slow).
I will need to take a look to see if something is going wrong here - you READCIN should not be necessary with the .vdi file specified and READGIN should also work once the MENU>GAME command is executed.
I changed readcin to chgfile, but it had no effect.
I'm trying to read constants, lookups and datasets all in the same script, could that pose a problem? Although I don't really see how, since everything works fine if I use it directly in Vensim (game or simulation).
I use a different vdi, for the game steps (only containing the data series, but this part works fine).
I'm trying to read constants, lookups and datasets all in the same script, could that pose a problem? Although I don't really see how, since everything works fine if I use it directly in Vensim (game or simulation).
I use a different vdi, for the game steps (only containing the data series, but this part works fine).
-
- Super Administrator
- Posts: 4827
- Joined: Wed Mar 05, 2003 3:10 am
Hi Jeroen,
Bob is away this week.
I suspect that you can only have one .vdi file. I looked at the Vensim help system,
http://www.vensim.com/documentation/html/25300.htm, that indicates to me that only one file is allowed.
If only one was allowed, it would explain why the other .vdi file used during gaming is working as expected.
I could be wrong though, hopefully Bob will get back with an answer by the end of the weekend.
Tony.
Bob is away this week.
I suspect that you can only have one .vdi file. I looked at the Vensim help system,
http://www.vensim.com/documentation/html/25300.htm, that indicates to me that only one file is allowed.
If only one was allowed, it would explain why the other .vdi file used during gaming is working as expected.
I could be wrong though, hopefully Bob will get back with an answer by the end of the weekend.
Tony.
FYI
I tried the
SIMULATE>CHGFILE|file.vdi
But it would not load data series.
I am using only one file.vdi, but for some reason I have to put it as a change file in the simulation control box and load it through venapp as I described in my first post.
If I look at the output screen the same file is loaded three times. This makes sense, since when you put a script in the simulation control box, but start simulation through the normal menu, it will be loaded two times (Don't ask me why). The third time comes from the venapp. In my opinion the venapp readout should be enough, but somehow it isn't.
I tried the
SIMULATE>CHGFILE|file.vdi
But it would not load data series.
I am using only one file.vdi, but for some reason I have to put it as a change file in the simulation control box and load it through venapp as I described in my first post.
If I look at the output screen the same file is loaded three times. This makes sense, since when you put a script in the simulation control box, but start simulation through the normal menu, it will be loaded two times (Don't ask me why). The third time comes from the venapp. In my opinion the venapp readout should be enough, but somehow it isn't.
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
I just tried this and I don't understand why you are having a problem. The attached venapp works with the odbctest model that comes with Vensim (open this model first)
when SIMULATE>CHGFILE| is given the model will not start gaming because of the missing data. When the change file is specified the model will start gaming, and as gaming advances the data will be reread (It will also try to rearead constants but that will just throw up a warning).
when SIMULATE>CHGFILE| is given the model will not start gaming because of the missing data. When the change file is specified the model will start gaming, and as gaming advances the data will be reread (It will also try to rearead constants but that will just throw up a warning).
- Attachments
-
- test.vcd
- (401 Bytes) Downloaded 837 times
I don't know what is wrong, but this works exactly as you would expect. I tried the same for my model and I get the following error:
ERROR: Floating point error computing - Volume of Parcel in Hall[Yard1,PFHall,Ship1] - at time = 0.000000.
Trying to save the results anyway
This is the result of not overwriting a constant => division by zero.
I posted the vcd file, maybe you could check if I perhaps make another mistake?
Jeroen
ERROR: Floating point error computing - Volume of Parcel in Hall[Yard1,PFHall,Ship1] - at time = 0.000000.
Trying to save the results anyway
This is the result of not overwriting a constant => division by zero.
I posted the vcd file, maybe you could check if I perhaps make another mistake?
Jeroen
- Attachments
-
- MBG.vcd
- (6.25 KiB) Downloaded 810 times
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
It took a while to try the solution (busy with another project), but even if I put the line after the showwarnings statement, I still get the same results; read out of the data-series, no overwriting of constants and lookups.
I added my .vdi-file, maybe there is a problem there?
Jeroen
I added my .vdi-file, maybe there is a problem there?
Jeroen
- Attachments
-
[The extension vdi has been deactivated and can no longer be displayed.]
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
While working on a smaller model, I found the cause of my problems. Using your test.vcd
If I used chgfile, the data-series were giving me troubles. If I used the readcin, the constants and lookups, were giving me trouble. Somehow, the model wanted the two data-types to be separated. Data-series, where only read-out when the game was initialised, while the rest was changed at the command time.
Although I still don't know why, this was what pointed me to a solution. I now use 2 separate vdi-files. One for the data-series (which is also used each next game step) and one for the rest. This works fine now and there is no need to read-out the same vdi 2 or 3 times as was the case.
Somehow the combination of running my model with venapp and using a (large) mysql database has trouble separating these two data types.
Jeroen
I attached the vcd-script of my solution
If I used chgfile, the data-series were giving me troubles. If I used the readcin, the constants and lookups, were giving me trouble. Somehow, the model wanted the two data-types to be separated. Data-series, where only read-out when the game was initialised, while the rest was changed at the command time.
Although I still don't know why, this was what pointed me to a solution. I now use 2 separate vdi-files. One for the data-series (which is also used each next game step) and one for the rest. This works fine now and there is no need to read-out the same vdi 2 or 3 times as was the case.
Somehow the combination of running my model with venapp and using a (large) mysql database has trouble separating these two data types.
Jeroen
I attached the vcd-script of my solution
- Attachments
-
- MBG.vcd
- (2.88 KiB) Downloaded 793 times