Reading in Values through Venapp

Use this forum to post Vensim related questions.
Post Reply
Pruyn
Senior Member
Posts: 80
Joined: Fri Mar 05, 2004 2:34 pm

Reading in Values through Venapp

Post by Pruyn »

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
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

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.
Pruyn
Senior Member
Posts: 80
Joined: Fri Mar 05, 2004 2:34 pm

Post by Pruyn »

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).
Administrator
Super Administrator
Posts: 4588
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

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.
Pruyn
Senior Member
Posts: 80
Joined: Fri Mar 05, 2004 2:34 pm

Post by Pruyn »

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.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

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).
Attachments
test.vcd
(401 Bytes) Downloaded 358 times
Pruyn
Senior Member
Posts: 80
Joined: Fri Mar 05, 2004 2:34 pm

Post by Pruyn »

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
Attachments
MBG.vcd
(6.25 KiB) Downloaded 385 times
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

this looks like it should work if you select the default settings - but not if you change anything. The CHGFile needs to be set before entering the ADMIN screen - I would recommend putting that command on the opening screen just after the SHOWWARNING command.
Pruyn
Senior Member
Posts: 80
Joined: Fri Mar 05, 2004 2:34 pm

Post by Pruyn »

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
Attachments

[The extension vdi has been deactivated and can no longer be displayed.]

bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

If you could put up (or email me) a complete project that demonstrates the problem - doesn't need to be the real model or data clearly - I would be happy to take a look at it. There is nothing obviously wrong.
Pruyn
Senior Member
Posts: 80
Joined: Fri Mar 05, 2004 2:34 pm

Post by Pruyn »

I hope to find some time to try and replicate the behaviour in another way.
I could sent you my project, but it wouldn't work, since the odbc connection is made with a MySQL server that doesn't allow logins from outside the university.
Pruyn
Senior Member
Posts: 80
Joined: Fri Mar 05, 2004 2:34 pm

Post by Pruyn »

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
Attachments
MBG.vcd
(2.88 KiB) Downloaded 364 times
Post Reply