Loading data for constants with multiple subscripts

Use this forum to post Vensim related questions.
Post Reply
joconnor
Junior Member
Posts: 2
Joined: Wed Jan 23, 2019 2:08 am
Vensim version: DSS

Loading data for constants with multiple subscripts

Post by joconnor »

Hi,

I am getting some unexpected errors when attempting to load data for constants with multiple subscripts using Vensim DSS. It works when I only have 1 subscript, but when I have 5, as in my example attached, these errors show up: "More than two subscripts are a subscript range," and "illegal constant equation for -variable-".

Hope you can help. I have attached my model, a screenshot, and the input data.

Thank you!
John
Attachments
Loading data for constants with multiple subscripts.PNG
Loading data for constants with multiple subscripts.PNG (127.67 KiB) Viewed 3361 times
Model -- v3 -- subscripts and optimization testing.mdl
(3.45 KiB) Downloaded 223 times
test subscript input 5.xls
(49 KiB) Downloaded 203 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Loading data for constants with multiple subscripts

Post by Administrator »

GET XLS CONSTANTS can only read a 2d matrix, so not really the best solution for reading values for a 5 range constant. You would need to have a separate equation for each 2d, for example,

DTE DL30 TO DL60[a,aa,aaa,cat4,cat5] = GET XLS CONSTANTS('test subscript input 5.xls','Sheet13','B162*')
DTE DL30 TO DL60[a,aa,bbb,cat4,cat5] = GET XLS CONSTANTS('test subscript input 5.xls','Sheet13','B162*')
DTE DL30 TO DL60[a,aa,ccc,cat4,cat5] = GET XLS CONSTANTS('test subscript input 5.xls','Sheet13','B162*')
and so on.

I'd suggest the best option if you have 5d constants would be to write a macro in Excel to dump them into a CIN file.
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
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: Loading data for constants with multiple subscripts

Post by LAUJJL »

Hi

I would too try uding the DLL functionnality using VBA. You can set values to constants using the
simulate>setval function directly using subscripted variables or embedded do loops in VBA if you want to use the setvar function with simple variables.

But this solution may be cumbersome, because I do not know if it is possible to call Excel from Vensim to set the values in VBA. You may be obliged to launch your Vensim model from Exel VBA directly.

But it may be possible once you have launched one run from VBA, to put the values from the .vdf file generated into .cin file to be used later on. I am not sure if it works.

One must test it with a simple model and see if once the model is run with a specific constant value, if that value is put into a .cin file.

Regards.

JJ
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Loading data for constants with multiple subscripts

Post by tomfid »

Another possibility is to load the constants from a .cin file that essentially contains a relational list of all the values. You can put :NA: or 0 in the equation as a default value to be overridden by the .cin.
joconnor
Junior Member
Posts: 2
Joined: Wed Jan 23, 2019 2:08 am
Vensim version: DSS

Re: Loading data for constants with multiple subscripts

Post by joconnor »

The .cin solution seems to work well.

Thank you!
John
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Loading data for constants with multiple subscripts

Post by tomfid »

Great!
Post Reply