User Function declaration in native languages
This section describes how to declare a user function in C. The general shape of the declaration is shown. Not all the possible arguments will necessarily be used by any particular function, and the actual arguments required will depend on the way the function is declared to Xpress NonLinear.
User function declaration in C
If the function is placed in a library, XSLPimportlibfunc may be used to retrieve a pointer to be passed to XSLPadduserfunction.
A user function can be included in the executable program which calls Xpress NonLinear.
A multimapdelta function's deltas is an array with the same number of items as inputvalues. It is used as an indication of which derivatives (if any) are required on a particular function call. If deltas[i] is zero then a derivative for input variable i is not required and must not be returned. If deltas[i] is nonzero then a derivative for input variable i is required and must be returned.
When no derivatives are calculated, the array of return values simply contains the results.
When derivatives are calculated, the array contains the values and the derivatives as follows (DVi is the ith variable for which derivatives are required, which may not be the same as the ith input value):
Result1
Derivative of Result1 w.r.t. DV1
Derivative of Result1 w.r.t. DV2
...
Derivative of Result1 w.r.t. DVn
Result2
Derivative of Result2 w.r.t. DV1
Derivative of Result2 w.r.t. DV2
...
Derivative of Result2 w.r.t. DVn
...
Derivative of Resultm w.r.t. DVn
It is therefore important to check whether derivatives are required and, if so, how many.
The return value of the user functions that return an int (as opposed to the evaluation value) is a status code indicating whether the function has completed normally. Possible values are:
- 0
- No errors: the function has completed normally.
- 1
- The function has encountered an error. This will terminate the optimization.
- -1
- The calling function must estimate the function value from the last set of values calculated. This will cause an error if no values are available.
© 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.