Using fewer subscripts

Use this forum to post Vensim related questions.
Post Reply
Quame
Member
Posts: 26
Joined: Tue Mar 12, 2019 7:37 pm
Vensim version: DSS

Using fewer subscripts

Post by Quame »

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,
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Using fewer subscripts

Post by tomfid »

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.
Quame
Member
Posts: 26
Joined: Tue Mar 12, 2019 7:37 pm
Vensim version: DSS

Re: Using fewer subscripts

Post by Quame »

Thanks tomfid for the reply. My main output variable actually has about 13 variables.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Using fewer subscripts

Post by tomfid »

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?
Quame
Member
Posts: 26
Joined: Tue Mar 12, 2019 7:37 pm
Vensim version: DSS

Re: Using fewer subscripts

Post by Quame »

Would be glad if I could attach the model, but basically, the 13 subscripts represent landscape processes for about 2000 plus land units
Quame
Member
Posts: 26
Joined: Tue Mar 12, 2019 7:37 pm
Vensim version: DSS

Re: Using fewer subscripts

Post by Quame »

Please find attached the model
Attachments
Dyn_NE_JD.zip
(771.78 KiB) Downloaded 176 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Using fewer subscripts

Post by Administrator »

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
Quame
Member
Posts: 26
Joined: Tue Mar 12, 2019 7:37 pm
Vensim version: DSS

Re: Using fewer subscripts

Post by Quame »

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.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Using fewer subscripts

Post by tomfid »

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.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Using fewer subscripts

Post by tomfid »

2222^13 = 3.2186423e+43 :)
Quame
Member
Posts: 26
Joined: Tue Mar 12, 2019 7:37 pm
Vensim version: DSS

Re: Using fewer subscripts

Post by Quame »

Thanks a lot tomfid, I think that would work, I will try it and let you know.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Using fewer subscripts

Post by tomfid »

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.
Quame
Member
Posts: 26
Joined: Tue Mar 12, 2019 7:37 pm
Vensim version: DSS

Re: Using fewer subscripts

Post by Quame »

Okay, so please how do I use the equivalence relations for the subscript?
Quame
Member
Posts: 26
Joined: Tue Mar 12, 2019 7:37 pm
Vensim version: DSS

Re: Using fewer subscripts

Post by Quame »

tomfid 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.
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 etc
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Using fewer subscripts

Post by tomfid »

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
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Using fewer subscripts

Post by tomfid »

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.
Quame
Member
Posts: 26
Joined: Tue Mar 12, 2019 7:37 pm
Vensim version: DSS

Re: Using fewer subscripts

Post by Quame »

Okay thanks
Quame
Member
Posts: 26
Joined: Tue Mar 12, 2019 7:37 pm
Vensim version: DSS

Re: Using fewer subscripts

Post by Quame »

Thanks a lot tomfid, I tried and works just fine. I really appreciate.
Kind regards
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Using fewer subscripts

Post by tomfid »

Great!
Post Reply