Initializing help system before first use

F

Purpose
Include a user function in a nonlinear constraint.
Synopsis
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
Arguments
UF 
A user function of type userfunc
arg 
Argument to be passed to the user function
returnarg 
Return argument to be substituted into the formula for multivalued user functions
Return value
A nonlinear expression which may form part of any nlctr.
Example
The following example shows how to implement a negative cosine function.

model "SimpleUF"
 uses "mmxnlp"
 declarations
  obj: nlctr
  x: mpvar
  MinusSine: userfunc
 end-declarations

! Creation and assignment of the user function
 MinusSine := userfuncMosel("MinusSineImplementation")
! which can then be embedded into any nonlinear expression
 obj := F(MinusSine,x)
 minimize(obj)

 public function MinusSineImplementation (x:real): real
  returned := -sin(x)
 end-function
end-model
    
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
Module

© 2001-2022 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.