SIMULATE>SETVAL Quotes and subscripts

Use this forum to post Vensim related questions.
Post Reply
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

SIMULATE>SETVAL Quotes and subscripts

Post by kleemax »

I can't get a script to work, because I don't know how to correctly put the code.

I have read in the help files that I am supposed to use quotes around the command if I have a subscripted variable.
I am not sure what that means, specifically, what to include in the quotes (you may wanna clarify this in future versions of the help files, because there may be other just as helpless as me;-)
"SIMULATE>SETVAL|variable"= skalar
"SIMULATE>SETVAL|"variable= skalar
SIMULATE>SETVAL|"variable"= skalar
SIMULATE>SETVAL|"variable[x,y]"= skalar
I guess it is the third and/or fourth option?


In my case, the respective variable is called: D_VFT_hdv_delta_Logit[GVW,TruckTech]
As you see it has two subscripts, GVW has 5 elements, TruckTech has 7 elements
I want to set it to =0 for all its elements
These do simulate, but I don't get the expected result:
SIMULATE>SETVAL|"D_VFT_hdv_delta_Logit"=0
SIMULATE>SETVAL|"D_VFT_hdv_delta_Logit[GVW,TruckTech]"=0
SIMULATE>SETVAL|"D_VFT_hdv_delta_Logit[GVW,TruckTech]"=0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0,

The definition of the variable is using subranges. Does that mean I have to use the same subranges in the script?

How would I use quotes when I have a lookup variable?
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: SIMULATE>SETVAL Quotes and subscripts

Post by Administrator »

You need to include quotes if the variable has any non ASCII characters.

There is no shortcut to set all subscript elements in a parameter to a single value, you will need to list them out.
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW1,TruckTech1]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW1,TruckTech2]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW1,TruckTech3]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW1,TruckTech4]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW1,TruckTech5]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW1,TruckTech6]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW1,TruckTech7]=0

SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW2,TruckTech1]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW2,TruckTech2]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW2,TruckTech3]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW2,TruckTech4]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW2,TruckTech5]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW2,TruckTech6]=0
SIMULATE>SETVAL|D_VFT_hdv_delta_Logit[GVW2,TruckTech7]=0
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: 3806
Joined: Wed May 24, 2006 4:54 am

Re: SIMULATE>SETVAL Quotes and subscripts

Post by tomfid »

There is no shortcut to set all subscript elements in a parameter to a single value, you will need to list them out.
A shortcut for this that will shorten the script is to put the 0 parameters in a .cin file and load it with READCIN/ADDCIN.
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

Re: SIMULATE>SETVAL Quotes and subscripts

Post by kleemax »

Toms hint with the READCIN/ADDCIN was helpful.
I know I had originally posted this a long while ago, I am still struggling to implement SETVAL with a table function. This example does not work:
SIMULATE>SETVAL|variable_name[C_1200kw]((1995,0),(2018,0),(2019,0),(2020,0),(2021,0),(2022,0),(2023,150),(2024,900),(2025,2250),(2026,4000),(2027,5000),(2028,5500),(2029,6000),(2030,6500),(2031,5000),(2032,5000),(2033,4000),(2034,3000),(2035,2500))
Vensim documentation indicates that SETVAL with subscripts also needs quotes if the table function has subscripts.
<<If you use subscripted variables in the SETVAL command you will need to surround the command in double quotes " ". >>
The question is quotes around what? And furthermore: do I need to put hashes (#) around the variable name for a table function as I have to in cin-files?
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: SIMULATE>SETVAL Quotes and subscripts

Post by Administrator »

Can you give us the rest of the command script? I've just tried the following and it worked without any problems.

SIMULATE>SETVAL|A subscripted lookup[sub1]((1.331445,3.440860), (4.957507,7.383512), (6.764680,1.575134), (6.864432,1.644506))
SIMULATE>RUNNAME|BASELINE
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
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

Re: SIMULATE>SETVAL Quotes and subscripts

Post by kleemax »

For example:
SIMULATE>RUNNAME|MKS_1232_REF2020_OHend_EISREF2021_butChargerKSSP_LogitBetasBEVsameDieselRel_CNGLNGmu9_MarginBEVlowfromstart
SIMULATE>SETVAL|D_VFT_hdv_technology_costs_by_componentxGVWxTruckTech_Euro2020[szm,BEVTruck,HDVmargin]((1995,17200),(2035,17200))
MENU>RUN|o
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

Re: SIMULATE>SETVAL Quotes and subscripts

Post by kleemax »

I should add that the variable for some subscripts has a table function for others equations or even constants. I currently use vensim 9.2.4.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: SIMULATE>SETVAL Quotes and subscripts

Post by Administrator »

Can you put the problem variable in a separate model and let us see? I cannot recreate the problem you are seeing.
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
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

Re: SIMULATE>SETVAL Quotes and subscripts

Post by kleemax »

I have attached a zip file that contains a tiny model with only a table function as well as a command script and the batch file that I use to run the command file.
If I run it, I do get two vdfx files, but they are identical although they should not be as you see if you look into the script.

Note:
I use vensim 9.2.4 as that is the last version we have paid for at M-Five. I run simulations in compiled mode.
I have tried different computers, to no avail.

(Note that for some reason I have not figured out, I cannot start cmd files from within Vensim via the open dialogue. I have started another thread on that problem a while ago but so far I haven't figured out why it doesn't work. Our workaround is a bat file which I have also included)
Attachments
ProblemTableFunctionsCmd.zip
(53.67 KiB) Downloaded 84 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: SIMULATE>SETVAL Quotes and subscripts

Post by tomfid »

The problem is that the command script syntax is not working when a lookup is embedded in a WITH LOOKUP auxiliary.

There's probably an easy fix for that, but for the moment, if you use regular lookups instead, the script works fine. See attached.
TestTF.zip
(1.72 KiB) Downloaded 92 times
Post Reply