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
Loading data for constants with multiple subscripts
Loading data for constants with multiple subscripts
- Attachments
-
- Loading data for constants with multiple subscripts.PNG (127.67 KiB) Viewed 3487 times
-
- Model -- v3 -- subscripts and optimization testing.mdl
- (3.45 KiB) Downloaded 233 times
-
- test subscript input 5.xls
- (49 KiB) Downloaded 213 times
-
- Super Administrator
- Posts: 4620
- Joined: Wed Mar 05, 2003 3:10 am
Re: Loading data for constants with multiple subscripts
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.
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Loading data for constants with multiple subscripts
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
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
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.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Loading data for constants with multiple subscripts
The .cin solution seems to work well.
Thank you!
John
Thank you!
John
Re: Loading data for constants with multiple subscripts
Great!
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/