Using fewer subscripts
Using fewer subscripts
Please I am trying to modify an existing model in VENSIM DSS which initially had subcatchment (upto about 2000 plus) processes modelled using lookup tables and time function. I want to use subscripts instead as I want to utilize the time function for dynamic processes within the model. I realized the final output contains more than 8 subscripts. How do I manage or reduce these subscripts?
Thanks,
Thanks,
Re: Using fewer subscripts
You can have as many subscripts as you want, as long as no single variable uses more than 8.
I think we need more information about your specific problem and model structure in order to give useful advice.
I think we need more information about your specific problem and model structure in order to give useful advice.
/*
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: Using fewer subscripts
Thanks tomfid for the reply. My main output variable actually has about 13 variables.
Re: Using fewer subscripts
If each subscript range has 2 elements, that's 2^13=8192. 3 elements each would be near the practical limits. I've never seen a model use more than 5 or 6 dimensions.
What's the real-world system under study?
What's the real-world system under study?
/*
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: Using fewer subscripts
Would be glad if I could attach the model, but basically, the 13 subscripts represent landscape processes for about 2000 plus land units
Re: Using fewer subscripts
Please find attached the model
- Attachments
-
- Dyn_NE_JD.zip
- (771.78 KiB) Downloaded 689 times
-
- Super Administrator
- Posts: 4832
- Joined: Wed Mar 05, 2003 3:10 am
Re: Using fewer subscripts
You'll have to give some sort of explanation of what the model is supposed to do, I've opened the model but have no idea what anything is.
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: Using fewer subscripts
Okay thanks. The model estimates nutrient exported from agricultural catchment. These nutrients are total nitrogen (TN and TP) highlighted yellow in the model. The model uses catchment properties such as fertilizer applied to the farm, manure from cattle, soil permeability, catchment slope, stream length etc. However, the catchment is subdivided to about 2222 and I need to calculate the TN and TP for each of these and sum them at (TN leaving Jumping Deer) in order to estimate the total nutrient leaving the entire catchment. The variables highlighted brown are the unique properties for each of the 2222 subdivisions. Initially, lookup table and time function were used to estimate the contributions from each of the subdivisions, but now I wanted to use subscripts to do that. To do this however, I realized I needed about 13 subscripts at the point of summation (ie TN leaving Jumping Deer). These subscripts are those from the inputs (Non-point source N-JD, Land-to-water delivery N-JD, etc) into that variable (TN in Jumping Deer Sub-catchments). In the model I sent, I had deleted those subscripts, but checking all the inputs into that variable, you would find these subscripts. The first half of the model is the TN estimation and the second half TP estimation all highlighted yellow and using the same concept in calculation. I hope this helps, otherwise let me know if additional information is needed.
Re: Using fewer subscripts
The fact that these subscripts are all the same size suggests to me that you really just need a single dimension:
Catchment : (c1-c2222)
or something like that.
As is, if you write variable[ManureN,FertN] it will have over 4 million elements, which can be done, but quickly bogs things down.
So, I think you want your equations to wind up looking like:
"Non-point source N-MJ"[catchment] = max(0,"Fertilizer N series-MJ"[catchment]+"Forest N series-MJ"[catchment]+"Manure N series-MJ"[catchment]+"Corral N-MJ"[catchment])
where each item has a single dimension with 2222 spatial elements and manure, fertilizer, precip, etc. are in separate variables.
Catchment : (c1-c2222)
or something like that.
As is, if you write variable[ManureN,FertN] it will have over 4 million elements, which can be done, but quickly bogs things down.
So, I think you want your equations to wind up looking like:
"Non-point source N-MJ"[catchment] = max(0,"Fertilizer N series-MJ"[catchment]+"Forest N series-MJ"[catchment]+"Manure N series-MJ"[catchment]+"Corral N-MJ"[catchment])
where each item has a single dimension with 2222 spatial elements and manure, fertilizer, precip, etc. are in separate variables.
/*
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: Using fewer subscripts
2222^13 = 3.2186423e+43 

/*
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: Using fewer subscripts
Thanks a lot tomfid, I think that would work, I will try it and let you know.
Re: Using fewer subscripts
One more thought ...
If you do want to use different names for the same dimension, you can use equivalence relations. One common application:
City : boston, chicago, denver
Origin <-> City
Destination <-> City
Then you can subscript things with [Origin,Destination]
In your case, I'd hope to avoid having 2222 x 2222 matrices however.
If you do want to use different names for the same dimension, you can use equivalence relations. One common application:
City : boston, chicago, denver
Origin <-> City
Destination <-> City
Then you can subscript things with [Origin,Destination]
In your case, I'd hope to avoid having 2222 x 2222 matrices however.
/*
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: Using fewer subscripts
Okay, so please how do I use the equivalence relations for the subscript?
Re: Using fewer subscripts
The values of Fertilizer, precip etc are different for each of the 2222 elements. Is there a way to use the above equation given and still have different values of [catchment] for Fertilizer N series-MJ,Forest N series-MJ etctomfid wrote: ↑Wed Mar 20, 2019 1:17 pm The fact that these subscripts are all the same size suggests to me that you really just need a single dimension:
Catchment : (c1-c2222)
or something like that.
As is, if you write variable[ManureN,FertN] it will have over 4 million elements, which can be done, but quickly bogs things down.
So, I think you want your equations to wind up looking like:
"Non-point source N-MJ"[catchment] = max(0,"Fertilizer N series-MJ"[catchment]+"Forest N series-MJ"[catchment]+"Manure N series-MJ"[catchment]+"Corral N-MJ"[catchment])
where each item has a single dimension with 2222 spatial elements and manure, fertilizer, precip, etc. are in separate variables.
Re: Using fewer subscripts
You can define equivalence relations by defining a new subscript, then changing the variable's subtype to "equivalence" in the equation editor.
See also http://vensim.com/documentation/usr17.htm
See also http://vensim.com/documentation/usr17.htm
/*
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: Using fewer subscripts
I think the equation above already does what you want.
If you write:
c : (c1-c10)
y[c] = x[c] + z
you assign 10 (presumably different) values of x to 10 values of y. On the other hand, the same single value of z will be used in each computation of y.
So, in your case, you just need to be sure that each constant (parameter) input has 2222 distinct values. Since 2222 is a lot, I would tend to put all the data in a spreadsheet, with a column for each variable and a row for each catchment. Then use GET XLS CONSTANTS (or the GET DIRECT equivalent) to read in the values.
If you write:
c : (c1-c10)
y[c] = x[c] + z
you assign 10 (presumably different) values of x to 10 values of y. On the other hand, the same single value of z will be used in each computation of y.
So, in your case, you just need to be sure that each constant (parameter) input has 2222 distinct values. Since 2222 is a lot, I would tend to put all the data in a spreadsheet, with a column for each variable and a row for each catchment. Then use GET XLS CONSTANTS (or the GET DIRECT equivalent) to read in the values.
/*
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: Using fewer subscripts
Okay thanks
Re: Using fewer subscripts
Thanks a lot tomfid, I tried and works just fine. I really appreciate.
Kind regards
Kind regards
Re: Using fewer 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
*/