Include a user function in a nonlinear constraint.
function F(UF:userfunc, arg:linctr):nlctr
function F(UF:userfunc, arg:nlctr) :nlctr
function F(UF:userfunc, arg:list of nlctr) :nlctr
function F(UF:userfunc, arg:array(any sets) of nlctr) :nlctr
function F(UF: userfunc, arg:list of nlctr, returnarg: integer) :nlctr
function F(UF:userfunc, arg:array(any sets) of nlctr, returnarg:integer) :nlctr
A user function of type userfunc
Argument to be passed to the user function
Return argument to be substituted into the formula for multivalued user functions
Return value
A nonlinear expression which may form part of any nlctr.
The following example shows how to implement a negative cosine function.
model "SimpleUF"
uses "mmxnlp"
obj: nlctr
x: mpvar
MinusSine : userfunc
! creation and assignement of the user function
MinusSine := userfuncMosel("MinusSineImplementation")
! which can then be embedded into any nonlinear expression
obj := F(MinusSine,x) 
function MinusSineImplementation (x:real) : real
returned := -sin(x)
Further information
User functions allow extremely complex, recursive or non-algebraic expressions to be included in nonlinear formulae. As such they may make use of simulators or other black box evaluators. The actual parameters to a user function depend upon the way it is bound to the model by the F function. Please see the chapter on user functions for more details. Each user function instance defined by the means of the F function must share the same argument syntax structure, however the actual formula content may differ: e.g. if a function takes an array of nonlinear expressions as input arguments, each instance of the function corresponding to the same definition based on the same F instance must have the same underlying array structure, although the expressions stored in them may differ. If a separate F instance is used using the same function implementation, this rule does not apply. Also note, that for Mosel to be able to correctly cross reference the sets used in the definition of an array, the sets must be named.
Related topics
userfuncDLL, userfuncMosel, userfuncExcel, userfuncExcelMacro.

If you have any comments or suggestions about these pages, please send mail to support@fico.com.

© Copyright 2001-2013 Fair Isaac Corporation. All rights reserved.