Comparison using subscripts
Posted: Fri Feb 12, 2010 2:45 pm
Hi,
I am facing a problem when it comes to compare values of a variable with subscripts. Let me explain myself:
I have a variable Var1 which has a subscript [sub] and the subscript can take values from 1-100. When running the model a value will be calculated for Var1[sub1], Var1[sub2], ... etc. What I want to do is to calculate how many different values exist in all 100 realizations:
For example: if Var1[sub1]=3 , Var1[sub2]=7, Var1[sub3]=3 , then there exist 2 different values: 3 and 7.
In order to do that comparison, and avoid double counting, you have to compare each subscript to all consecutive ones: Var1[sub1] to Var[sub2-100] , ... Var1[sub50] to Var1[sub 51-100] and so on.
I am using the generic formula: IF THEN ELSE ( Var1[sub]=Var1[sub!], 1, 0 ) but it compares each value of the subscript to the entire range (including its own). Is there any way to ask [sub!] to take only its consecutive values? I have tried mapping but it requires to add another subscript and still go through hard-writing the mapping for all the range of [sub1].
Thanks for the tips!
Marios
I am facing a problem when it comes to compare values of a variable with subscripts. Let me explain myself:
I have a variable Var1 which has a subscript [sub] and the subscript can take values from 1-100. When running the model a value will be calculated for Var1[sub1], Var1[sub2], ... etc. What I want to do is to calculate how many different values exist in all 100 realizations:
For example: if Var1[sub1]=3 , Var1[sub2]=7, Var1[sub3]=3 , then there exist 2 different values: 3 and 7.
In order to do that comparison, and avoid double counting, you have to compare each subscript to all consecutive ones: Var1[sub1] to Var[sub2-100] , ... Var1[sub50] to Var1[sub 51-100] and so on.
I am using the generic formula: IF THEN ELSE ( Var1[sub]=Var1[sub!], 1, 0 ) but it compares each value of the subscript to the entire range (including its own). Is there any way to ask [sub!] to take only its consecutive values? I have tried mapping but it requires to add another subscript and still go through hard-writing the mapping for all the range of [sub1].
Thanks for the tips!
Marios