Page 1 of 1

Using fewer subscripts

Posted: Tue Mar 19, 2019 11:31 pm
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,

Re: Using fewer subscripts

Posted: Tue Mar 19, 2019 11:35 pm
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.

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 2:19 am
by Quame
Thanks tomfid for the reply. My main output variable actually has about 13 variables.

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 3:46 am
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?

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 5:00 am
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

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 5:04 am
by Quame
Please find attached the model

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 8:05 am
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.

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 10:30 am
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.

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 1:17 pm
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.

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 1:18 pm
by tomfid
2222^13 = 3.2186423e+43 :)

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 2:26 pm
by Quame
Thanks a lot tomfid, I think that would work, I will try it and let you know.

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 2:42 pm
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.

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 4:07 pm
by Quame
Okay, so please how do I use the equivalence relations for the subscript?

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 4:20 pm
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

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 4:36 pm
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

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 4:42 pm
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.

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 4:57 pm
by Quame
Okay thanks

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 8:39 pm
by Quame
Thanks a lot tomfid, I tried and works just fine. I really appreciate.
Kind regards

Re: Using fewer subscripts

Posted: Wed Mar 20, 2019 9:14 pm
by tomfid
Great!