Setting constants in different runs in Venapp

Use this forum to post Vensim related questions.
Post Reply
Hossein
Member
Posts: 48
Joined: Thu Sep 15, 2016 7:50 am
Vensim version: DSS

Setting constants in different runs in Venapp

Post by Hossein »

Dear Tom/Administrator,

I was wondering if there is any way in Venapp that keeps the constants' value fixed in different runs? I mean if I change the value of a constant at run1, for starting the run2 the constant value will be back to its default value; while I would like to do all of my runs with the latest value I specified. I would appreciate if you could help.
e.g.
default value: 2000
value in run1: 2500
value in run2: 2000

With best regards,
Hossein
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Setting constants in different runs in Venapp

Post by Administrator »

Do you have a button that runs the simulation?

Assuming you have, add the following command before it
SIMULATE>WRITECIN|temp.cin

And add this after it,
SIMULATE>READCIN|temp.cin

This creates a file called temp.cin which includes all the constants you've set. It's saved before you run, and loaded immediately when the run is complete.

So your command on the button would now look something like
SIMULATE>WRITECIN|temp.cin&MENU>RUN|o&SIMULATE>READCIN|temp.cin
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Hossein
Member
Posts: 48
Joined: Thu Sep 15, 2016 7:50 am
Vensim version: DSS

Re: Setting constants in different runs in Venapp

Post by Hossein »

Dear Administrator,

Thank you so much for replying. I have the following commands in a BUTTON. I added the commands you said, however, it does not work and again back to the default value. I have a constant "start of the project" in my model that its default value is 2016 but I would like to run it as 2018 in any run by clicking the button. Could you please help that is the line of the command (WRITECIN and READCIN) are correct?

BUTTON,"Simulate model",35,70,30,8,,,
"SIMULATE>SETVAL|"Truck-Shovel system"=1
&SIMULATE>SETVAL|"FIPCC system"=0
&SIMULATE>SETVAL|"SFIPCC system"=0
&SIMULATE>SETVAL|"SMIPCC system"=0
&SIMULATE>SETVAL|"FMIPCC system"=0
&SIMULATE>RUNNAME|Truck-Shovel
&SIMULATE>WRITECIN|temp.cin
&MENU>RUN|O
&SIMULATE>READCIN|temp.cin
&SIMULATE>SENSSAVELIST|TESES Indexes.lst
&SIMULATE>SENSITIVITY|TESES Indexes.vsc
&SIMULATE>RUNNAME|SA Truck-Shovel
&MENU>RUN_SENSITIVITY|O
&MENU>SENS2TAB|SA Truck-Shovel.vdf|SA Truck-Shovel.tab|*
&SPECIAL>MESSAGE|||Run completed!",
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Setting constants in different runs in Venapp

Post by Administrator »

That looks like it should work.

You might also need to load the CIN file after the sensitivity run is complete,

...
...
&MENU>RUN|O
&SIMULATE>READCIN|temp.cin
&SIMULATE>SENSSAVELIST|TESES Indexes.lst
&SIMULATE>SENSITIVITY|TESES Indexes.vsc
&SIMULATE>RUNNAME|SA Truck-Shovel
&MENU>RUN_SENSITIVITY|O
&SIMULATE>READCIN|temp.cin
&MENU>SENS2TAB|SA Truck-Shovel.vdf|SA Truck-Shovel.tab|*
&SPECIAL>MESSAGE|||Run completed!",
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Hossein
Member
Posts: 48
Joined: Thu Sep 15, 2016 7:50 am
Vensim version: DSS

Re: Setting constants in different runs in Venapp

Post by Hossein »

Dear Administrator,

Thank you for your help. I could resolve the problem by putting a "save changes" button in my "input menu" and reading it before simulation. However, these changes are saved in a ".cin" file and they are not shown in my "input menu" in the "modify a variable value" box (please see the attached picture). Is there any way that these changes also can be shown in the variable value box?
Attachments
Untitled.png
Untitled.png (64.51 KiB) Viewed 4197 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Setting constants in different runs in Venapp

Post by Administrator »

Are you loading the CIN file before showing that screen?

If yes, you might also need to refresh the values,
http://www.vensim.com/documentation/ind ... ?25480.htm
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Hossein
Member
Posts: 48
Joined: Thu Sep 15, 2016 7:50 am
Vensim version: DSS

Re: Setting constants in different runs in Venapp

Post by Hossein »

No, the steps from entering inputs to simulation is as follows:
1- Entering values in the input screen
2- pushing the "save changes" button (SIMULATE>WRITECIN|temp.cin)
3- reading the CIN file (SIMULATE>READCIN|temp.cin)
4- pushing the "simulation" button
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Setting constants in different runs in Venapp

Post by Administrator »

Can you upload or email (vensim@vensim.com) the venapp and model and I'll take a look?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Hossein
Member
Posts: 48
Joined: Thu Sep 15, 2016 7:50 am
Vensim version: DSS

Re: Setting constants in different runs in Venapp

Post by Hossein »

Sure. I will email it to you.

Thanks
Hossein
Member
Posts: 48
Joined: Thu Sep 15, 2016 7:50 am
Vensim version: DSS

Re: Setting constants in different runs in Venapp

Post by Hossein »

Dear Administrator,

I could resolve the problem by putting SPECIAL>RESETINPUT after loading the CIN file :)

Thanks for your help
Post Reply