VMax Help

Use this forum to post Vensim related questions.
Post Reply
brettspicer
Newbie
Posts: 1
Joined: Wed Apr 08, 2009 11:49 am

VMax Help

Post by brettspicer »

I am new to Vensim and trying to compare multiple variables to each other to find the maximum value. Currently I am doing this by using MAX(Var 1, MAX(Var 2, Var 3)) but want to be able to get the maximum of (Var 1, Var 2, Var 3). I believe that VMAX can be use to do this, but have not had success so far in using VMAX. Do the variables that VMAX is comparing have to be is a specific format, such as a subscripted or scripted variables.

VMAX(X[r!])† Takes the maximum of X over the subscript range r.

VMAX†(x[i!]) MAXimum Over Subscript Range
Returns the maximum value of the elements of an array over the Subscript Range(s) marked with exclamation ! marks.
Units: VMAX(unit) --> unit (the output has same units as the input)
Example
VMAX (x[i!]) is equal to MAX(x[one] , MAX(x[two] , MAX..., x[n]))...).
Administrator
Super Administrator
Posts: 4841
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

VMAX will only work on subscripted variables.

MAX(Var 1, MAX(Var 2, Var 3)) should work ok for you. If you want to tidy it up a little you could write a macro to do it.

Tony.
LAUJJL
Senior Member
Posts: 1477
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

vmax help

Post by LAUJJL »

One easy solution is to build a subscripted variable that has the same unit dimension than the xi.
For instance if you have the variables x1,x2,x3 etc. with dimension people for instance up to a maximum of n, then build the subscript sube s1-sn, and create the variable x subscripted by sube, x[sube] with dimension people, then make x[s1] = x1, x[s2] = x2 etc...
Then the maximum of (x1,x2,... xn) will be equal to
vmax(x[sube!]).
Il may be too useful to think about the meaning of these unsubscripted xi. They should have a real world meaning and the fact than these xi exist may be the proof that your model has a bad structure and that your xi should have been already declared in a subscripted way right at the befinning.
Then the xi should not even exist and the x should replace them.
Regards.
JJ

[Edited on 8-4-2009 by LAUJJL]
Post Reply