Page 1 of 1
How to pick the minimum value from say 6 values?
Posted: Mon Mar 01, 2010 5:32 am
by krreddi
I have my model calculating 6 variables dynamically. I want to select the least value of these variables at a particular point of time. I want to know if there is any direct function to do this are we need to put up our own lops?.
Thanks
Krishna.
Posted: Mon Mar 01, 2010 9:01 am
by Administrator
You can nest the MIN statements,
MINVALUE = MIN ( val1, MIN ( val2 , val3 ))
Alternatively you can write a macro
:MACRO: MIN6(val1,val2,val3,val4,val5,val6)
MIN6 = min(val1,min(val2,min(val3,min(val4,min(val5,val6)))))
~ val1
~ |
:END OF MACRO:
minimum value
Posted: Mon Mar 01, 2010 10:43 am
by LAUJJL
I you have at least the Pro Vensim version you can too put the 6 variables in an array variable with 1 subscript having 6 possible values like value = (v1-v6) then calculate the minimum of the arrays values minimum = vmin(variable[value!]).
Regards.
JJ
[Edited on 2-3-2010 by LAUJJL]
Posted: Fri Mar 05, 2010 7:55 am
by krreddi
Thanks for your replies. I am using second option gathering the values in subscripts and using the subscript values.