Initializing help system before first use

XSLPadduserfuncs

XSLPadduserfuncs


Purpose
Add user function definitions to an SLP problem.
Synopsis
int XPRS_CC XSLPadduserfuncs(XSLPprob Prob, int nSLPUserFunc, int *Type, double *Value);
Arguments
Prob 
The current SLP problem.
nSLPUserFunc 
Number of SLP user functions to be added.
Type 
Integer array of token types.
Value 
Double array of token values corresponding to the types in Type.
Example

Suppose we have the following user functions written in C in a library lib01:
Func1 which takes two arguments and returns two values
Func2 which takes one argument and returns the value and (optionally) the derivative of the function. Although the function is referred to as Func2 in the problem, we are actually using the function NewFunc2 from the library.

The following example adds the two functions to the SLP problem:


int nUserFuncs, ExtName, LibName, Type[10];
double Value[10];

XSLPsetstring(Prob,&LibName,"lib01");
Type[0] = XSLP_UFARGTYPE;  Value[0] = (double) 023;
Type[1] = XSLP_UFEXETYPE;  Value[1] = (double) 1;
Type[2] = XSLP_STRING;     Value[2] = 0;
Type[3] = XSLP_STRING;     Value[3] = LibName;
Type[4] = XSLP_EOF;

XSLPsetstring(Prob,&ExtName,"NewFunc2");
Type[5] = XSLP_UFARGTYPE;  Value[5] = (double) 010023;
Type[6] = XSLP_UFEXETYPE;  Value[6] = (double) 1;
Type[7] = XSLP_STRING;     Value[7] = ExtName;
Type[8] = XSLP_STRING;     Value[8] = LibName;
Type[9] = XSLP_EOF;

XSLPgetintattrib(Prob,XSLP_UFS,&nUserFuncs);
XSLPadduserfuncs(Prob,2,Type,Value);
XSLPaddnames(Prob,XSLP_USERFUNCNAMES,"Func1\0Func2",
             nUserFuncs+1,nUserFuncs+2);

Note that the values for XSLP_UFARGTYPE are in octal

XSLP_UFEXETYPE describes the functions as taking a double array of values and an integer array of function information.

The remaining tokens hold the values for the external name and the three optional parameters (file, item and template). Func01 has the same internal name (in the problem) and external name (in the library), so the library name is not required. A zero string index is used as a place holder, so that the next item is correctly recognized as the library name. Func2 has a different external name, so this appears as the first string token, followed by the library name. As neither function needs the item or template names, these have been omitted.

The number of user functions already in the problem is in the integer problem attribute XSLP_UFS. The new internal names are added using XSLPaddnames.


Further information

The token type and value arrays Type and Value are formatted in a similar way to the unparsed internal format function stack. For possible token types and values see the chapter on "Formula Parsing". Each formula must be terminated by an XSLP_EOF token.

The XSLPadd... functions load additional items into the SLP problem. The corresponding XSLPload... functions delete any existing items first.


Related topics

© 2001-2019 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.