User function (simple form)
PurposeIn many cases, a user function takes one or more parameters and returns a single value. Such a function does not need the full power of the user function structure as described in User function (general form) (below), and it is possible to simplify the function definition.Synopsisfunction fName (aName:array(aRange:range) of real, nName:integer) :realArguments
aName an array of type real containing the actual values of the parameters to the function nName an integer containing the actual number of parametersReturn valueThe calculated value of the functionExampleThe following example of a user function calculates the product of an array of values:function Product(Values:array(vRange:range) of real, nValue:integer) :real declarations Value: real end-declarations Value := 1 forall (i in 1..nValue) do Value := Value * Values(vRange(i)) end-do returned := Value end-functionNotice that the function uses nValue rather than vRange to step through the array. This is because not all the values in the array will necessarily be set or used on each function call.Related topics
If you have any comments or suggestions about these pages, please send mail to docs@dashoptimization.com.