XSLPloaduserfuncs
XSLPloaduserfuncs |
int XPRS_CC XSLPloaduserfuncs(XSLPprob Prob, int nSLPUserFunc, int *Type, double *Value);
Prob
|
The current SLP problem.
|
nSLPUserFunc
|
Number of SLP user functions to be loaded.
|
Type
|
Integer array of token types.
|
Value
|
Double array of token values corresponding to the types in
Type.
|
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 loads the two functions into the SLP problem:
int 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; XSLPloaduserfuncs(Prob,2,Type,Value); XSLPaddnames(Prob,XSLP_USERFUNCNAMES,"Func1\0Func2", 1,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.
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 XSLPload... functions load items into the SLP problem. Any existing items of the same type are deleted first. The corresponding XSLPadd... functions add or replace items leaving other items of the same type unchanged.