Changing FINAL TIME in a command file and other problems

Use this forum to post Vensim related questions.
Post Reply
billh
Member
Posts: 45
Joined: Tue Jan 10, 2017 11:48 pm
Vensim version: DSS

Changing FINAL TIME in a command file and other problems

Post by billh »

I'm using command scripts (http://www.vensim.com/documentation/ind ... ?25670.htm) for the first time, and I've got two questions. The attached model shows what I mean.

First, the model is set up to run 144 hours--6 days. If you run that from Vensim, you can see "flow per hour" marking off each AM time. "marker" stays at 1.

If I run

Code: Select all

"c:/Program Files (x86)/Vensim/vensim.exe" cft1.cmd 
from Cygwin bash, where cft1.cmd looks like

Code: Select all

SPECIAL>NOINTERACTION
SPECIAL>LOADMODEL|Changing FINAL TIME.mdl
SIMULATE>RUNNAME|extendfinaltime
MENU>RUN|O
MENU>VDF2CSV|extendfinaltime.vdf|extendfinaltime.CSV|extentfinaltime.lst|*
MENU>EXIT
I get Vensim to open a "Save backup as new file" file search box, with Save as type set to Vensim Models and the existing model name filled in. If I click Save, something happens, Vensim closes, and there's no apparent change to the directory.

What am I doing wrong?

Second, I tried cft2.cmd, instead:
SPECIAL>NOINTERACTION
SPECIAL>LOADMODEL|Changing FINAL TIME.mdl
SIMULATE>SETVAL|FINAL TIME=168
SIMULATE>RUNNAME|extendfinaltime
MENU>RUN|O
MENU>VDF2CSV|extendfinaltime.vdf|extendfinaltime.CSV|extentfinaltime.lst|*|0|168
MENU>EXIT
My intent was that the third line would change the End Time for this run, so graphs and tables would show results for 168 hours, and the next-to-the-last line would change FINAL TIME to 168, so the simulation would run that long.

This time, the same thing happens, and I also get a binary Changing FINAL TIME.3vm file in my directory.

What am I doing wrong here?

Thanks,

Bill
Attachments
extendfinaltime.lst
(23 Bytes) Downloaded 188 times
Changing FINAL TIME.mdl
(2.11 KiB) Downloaded 184 times
billh
Member
Posts: 45
Joined: Tue Jan 10, 2017 11:48 pm
Vensim version: DSS

Re: Changing FINAL TIME in a command file and other problems

Post by billh »

I found a typo that was generating the dialog box. This cft3.cmd is better, but it still doesn't change the time horizon:

Code: Select all

SPECIAL>NOINTERACTION
SPECIAL>LOADMODEL|Changing FINAL TIME.mdl
SIMULATE>SETVAL|FINAL TIME=168
SIMULATE>RUNNAME|extendfinaltime
MENU>RUN|O
MENU>VDF2CSV|extendfinaltime.vdf|extendfinaltime.CSV|extendfinaltime.lst|*||0|168
MENU>EXIT
Can you help me figure out how to extend the simulation and reporting time? In the final product, I'll be getting data of various lengths and needing to change the FINAL TIME and END TIME programmatically.

Bill
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Changing FINAL TIME in a command file and other problems

Post by Administrator »

I've just run it, and FINAL Time is set correctly.

What do you see when you look at FINAL TIME using the table tool?
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: Changing FINAL TIME in a command file and other problems

Post by Administrator »

MENU>VDF2CSV|extendfinaltime.vdf|extendfinaltime.CSV|extendfinaltime.lst|*||0|168
Could it be this?
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
billh
Member
Posts: 45
Joined: Tue Jan 10, 2017 11:48 pm
Vensim version: DSS

Re: Changing FINAL TIME in a command file and other problems

Post by billh »

I want the FINAL TIME to be 168, even though it's 144 in the model as saved to disk. I hoped that setting both the end time for reporting, as you indicated, and the FINAL TIME in the SETVAL to 168 would do that.

Here's the result I get, with the boring middle elided:

Code: Select all

Time,flow per hour,marker
0,1,1
1,1,1
2,1,1
  .
  .
  .
141,0,1
142,0,1
143,0,1
144,1,1
Did I understand your question properly?
billh
Member
Posts: 45
Joined: Tue Jan 10, 2017 11:48 pm
Vensim version: DSS

Re: Changing FINAL TIME in a command file and other problems

Post by billh »

More clearly, when you say FINAL TIME is set correctly when you run it, do you mean that it is 144 or 168?
billh
Member
Posts: 45
Joined: Tue Jan 10, 2017 11:48 pm
Vensim version: DSS

Re: Changing FINAL TIME in a command file and other problems

Post by billh »

I created cft4.cmd that has no exit command:

Code: Select all

SPECIAL>NOINTERACTION
SPECIAL>LOADMODEL|Changing FINAL TIME.mdl
SIMULATE>SETVAL|FINAL TIME=168
SIMULATE>RUNNAME|extendfinaltime
MENU>RUN|O
MENU>VDF2CSV|extendfinaltime.vdf|extendfinaltime.CSV|extendfinaltime.lst|*||0|168
When I run it, it loads the model, and I get a Vensim window titled "Command Script Definition Errors":

Code: Select all

sim  extendfinaltime
Executing SIMULATE>RUNNAME|extendfinaltime
Executing MENU>RUN|O
If I dismiss that window, I see a custom graph that runs to 168, as I hoped, the table tool shows FINAL TiME to be 168, and the End Time in the Control Panel Time Axis tab is 168. I can draw a graph with the graph tool, and it extends out to 168. Only FINAL TIME in Model > Settings is 144 still.

The directory now contains extendfinaltime.vdf and extendfinaltime.CSV, and extendfinaltime.CSV has rows running from time = 0 to time = 168.

When I switch back to cft3.cmd (the same file plus the MENU>EXIT command, I get the popup file dialog again. When I cancel out of that, I find it rewrote the CSV file but not the vdf file.

If I make the Run line

Code: Select all

MENU>RUN|o
, it seems happy: I get both the vdf and the CSV, the CSV goes to 168, and I get no errors.

In summary (I think):

http://www.vensim.com/documentation/ind ... ?25670.htm uses "O", but my computer works only with "o".

The working command script is

Code: Select all

SPECIAL>NOINTERACTION
SPECIAL>LOADMODEL|Changing FINAL TIME.mdl
SIMULATE>SETVAL|FINAL TIME=168
SIMULATE>RUNNAME|extendfinaltime
MENU>RUN|o
MENU>VDF2CSV|extendfinaltime.vdf|extendfinaltime.CSV|extendfinaltime.lst|*||0|168
MENU>EXIT
Thanks!

Bill
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Changing FINAL TIME in a command file and other problems

Post by Administrator »

billh wrote:IThis time, the same thing happens, and I also get a binary Changing FINAL TIME.3vm file in my directory.
This is a backup file, you can ignore it.
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: Changing FINAL TIME in a command file and other problems

Post by Administrator »

billh wrote:My intent was that the third line would change the End Time for this run, so graphs and tables would show results for 168 hours, and the next-to-the-last line would change FINAL TIME to 168, so the simulation would run that long.
This is exactly what happens for me. If you look at the CSV file that is generated, time runs to 168. And looking at the values for final time using the table tool (not the equation editor), it's 168.

Are you expecting the value for FINAL time to be changed in the model itself? This is not how CMD scripts work, the script sets final time just for that one run, it does not modify the model in any way.
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: Changing FINAL TIME in a command file and other problems

Post by Administrator »

Your scripts are working fine for me. One note though, using NOINTERACTION can easily miss errors. If you have the CSV file open in Excel for example, the command to generate the CSV will fail, but the script continues to execute as NOINTERATION is set.
Only FINAL TIME in Model > Settings is 144 still.
This is correct. The model is not modified in any way by the command script, the value for FINAL TIME=168 is only for that one run.
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
Post Reply