Conditional functions

<< Click to Display Table of Contents >>

Navigation:  Using GeNIe > Equation-based and hybrid models > Writing equations in GeNIe > Functions >

Conditional functions

Choose(index,v0,v1,...,vn)

Returns vi if index is equal to i. When index evaluates to a value smaller than 0 or larger than n-1, the function returns 0. Examples:

Choose(0,1,2,3,4,5)=1

Choose(4,1,2,3,4,5)=5

Choose(7,1,2,3,4,5)=0

If(cond,tval,fval)

If cond evaluates to non-zero return tval, fval otherwise, e.g., If(1=2,3,4)=4, If(1,5,10)=5

Switch(x,a1,b1,a2,b2,...,[def])

If x=a1, return b1, if x=a2, return b2, when x is not equal to any of as, return def (default value), which is an optional argument. When x is not equal to any of as and no def is defined, return 0. Examples:

Switch(3,1,111,2,222,3,333,4,444,5,555,999)=333

Switch(8,1,111,2,222,3,333,4,444,5,555,999)=999

Switch(8,1,111,2,222,3,333,4,444,5,555)=0