SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Use this forum to post Vensim related questions.
Post Reply
eis
Junior Member
Posts: 11
Joined: Mon Feb 25, 2019 9:37 am
Vensim version: DSS

SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Post by eis »

Hello,
I am new to Vensim and try to run Vensim 5.11A from a Windows7 command line:

Code: Select all

vensim.exe treez.cmd
Content of treez.cmd (Please allow to attach *.cmd files and *.dat files to the ticket):

Code: Select all

SPECIAL>NOINTERACTION
SPECIAL>LOADMODEL|treez.mdl
SIMULATE>SETVAL|CarFlow=4
MENU>RUN|o
MENU>VDF2DAT|treez.vdf|treez.dat|treez.lst
MENU>EXIT
The command file treez.cms should:

* load my model treez.mdl,
* set the value of a variable "CarFlow" to 4
* run the simulation
* write the calculated values of CarStock to result file treez.dat

However, the variable CarFlow does not seem to change.
It's value is always 1 as defined in the original treez.mdl file.
Therefore, the last calculated value of CarStock is 100 instead of 400.

=>How do I have to adapt my model or command file to correctly set the variable value?

Do I have to use a different type of variable? Do I need to execute an additional command?

The files treez.mdl, treez.vdf and treez.lst are attached.


I also tried to only use the first three lines of the command file...

Code: Select all

SPECIAL>NOINTERACTION
SPECIAL>LOADMODEL|treez.mdl
SIMULATE>SETVAL|CarFlow=4
... I would expect that I can see a value of 4 for the CarFlow Variable
in the Vensim User Interface but it is 1.
Attachments
treez.vdf
(4.39 KiB) Downloaded 164 times
treez.mdl
(1.53 KiB) Downloaded 167 times
treez.lst
(8 Bytes) Downloaded 167 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Post by Administrator »

Do you actually run the model as well? Your CMD file does not show a line such as
MENU>RUN|o
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
eis
Junior Member
Posts: 11
Joined: Mon Feb 25, 2019 9:37 am
Vensim version: DSS

Re: SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Post by eis »

Maybe I don't understand your question. The run command is on line 4 of the first cmd file example. My second example does not include the run command on purpose.
eis
Junior Member
Posts: 11
Joined: Mon Feb 25, 2019 9:37 am
Vensim version: DSS

Re: SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Post by eis »

Since I can not edit the orginal post (?!)... here is a screenshot of the treez model as comment:
download/file.php?id=2845
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Post by Administrator »

There is no cmd file, what happens if you run

Code: Select all

SPECIAL>NOINTERACTION
SPECIAL>LOADMODEL|treez.mdl
SIMULATE>SETVAL|CarFlow=4
MENU>RUN|o
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
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Post by Administrator »

Ahh, sorry, I misread your original post.

Try this,

Code: Select all

SPECIAL>NOINTERACTION
SPECIAL>LOADMODEL|treez.mdl
SIMULATE>SETVAL|CarFlow=4
SIMULATE>RUNNAME|treez.vdf
MENU>RUN|o
MENU>VDF2DAT|treez.vdf|treez.dat|treez.lst
MENU>EXIT
My guess is that the default run name is "current.vdf", so running VDF2DAT on treez.vdf will not give the changes.
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
eis
Junior Member
Posts: 11
Joined: Mon Feb 25, 2019 9:37 am
Vensim version: DSS

Re: SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Post by eis »

Running the whole command file works now. The last written value in the treez.dat file is 400.
Thanks a lot!

Is it also possible to reflect the change of the variable values in the GUI, so I can
manually check the values?

If I remove the exit line, I would expect to be able to inspect the altered equations but
the GUI seems to always show the original ones.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Post by Administrator »

SIMULATE>SETVAL will only override the value in the model (it will not change it permanently).

Best practice would be to set it to zero in the model, and use a CIN file to hold your constants.
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
eis
Junior Member
Posts: 11
Joined: Mon Feb 25, 2019 9:37 am
Vensim version: DSS

Re: SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Post by eis »

Code: Select all

SPECIAL>NOINTERACTION
SPECIAL>LOADMODEL|treez.mdl
SIMULATE>READCIN|treez.cin
SIMULATE>RUNNAME|treez.vdf
MENU>RUN|o
MENU>VDF2DAT|treez.vdf|treez.dat|treez.lst
neither reflects the changes in the GUI. Nevertheless, it is good to know about the
cin option to write several variable values in a file and separate them from the rest
of the command file. Thanks again.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Post by Administrator »

It will never change the model itself (what you see in the GUI).

Best practice is to keep model and data/constants separate.
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
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: SIMULATE>SETVAL does not change variable value when running vensim with command file?!

Post by tomfid »

If you really want to ensure separation, you can set the model value to :NA: - that way the model will generate errors or na values if the .cin file does not populate the constant.

I usually have a usable default value in the equation, and use .cin files for experiments or scenarios.
Post Reply