Smin Smax

Top  Previous  Next

One might wish to find the largest or smallest values over a set.  This is done using

 

r=smax(I,y[I]);

r=smax((I,j),y(i)+w(j));

 

Here the maximum element from the set is returned back over all of

 

the elements in I for the first equation

the elements in I and j for the second equation

 

Use of the syntax smin will find the smallest element across the set.

 

r=smin(I,y[I]);

r=smin((I,j),y(i)+w(j));

Notes:

The general syntax is smax(settovary,expression) where
the settovary is the name of the sets or sets that will be varied
When more than one set is to be varied they are enclosed in parentheses – smin((i,j),x(i,j)).
expression is a generally a function of the set in the smax
a ( occurs just after the word smax/smin and matches with a ) at the end of the smax/smin.
In replacement statements only parameters, scalars, and table data may freely appear.  Variables and equations can only be present if attributes are being addressed.
You cannot generally use smin and smax in equations for models unless you are dealing with a DNLP type of model.
The expression after the comma is fully computed and then applied to the calculation as if the term were in parentheses.