Page 1 of 1

Loading data for constants with multiple subscripts

Posted: Wed Jan 23, 2019 3:58 pm
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

Re: Loading data for constants with multiple subscripts

Posted: Wed Jan 23, 2019 4:06 pm
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.

Re: Loading data for constants with multiple subscripts

Posted: Wed Jan 23, 2019 5:05 pm
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

Re: Loading data for constants with multiple subscripts

Posted: Wed Jan 23, 2019 5:32 pm
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.

Re: Loading data for constants with multiple subscripts

Posted: Wed Jan 23, 2019 9:25 pm
by joconnor
The .cin solution seems to work well.

Thank you!
John

Re: Loading data for constants with multiple subscripts

Posted: Wed Jan 23, 2019 10:30 pm
by tomfid
Great!