Purpose
Check a formula in internal (parsed or unparsed) format for unknown tokens
Synopsis
int XPRS_CC XSLPvalidformula(int *inType, double *inValue, int *nToken,
char *Name, char *StringTable);
Arguments
|
inType
|
Array of token types providing the formula.
|
|
inValue
|
Array of values corresponding to the types in inType
|
|
nToken
|
Number of the first invalid token in the formula. A value of zero
means that the formula is valid. May be NULL if not required.
|
|
Name
|
Character buffer to hold the name of the first invalid token.
May be NULL if not required.
|
|
StringTable
|
Character buffer holding the names of the unidentified tokens
(this can be created by XSLPpreparseformula).
|
Example
The following example pre-parses the formula "sin ( x + y )" and then tries
to identify the unknown tokens:
int n, Index, NewType, Type[20];
double Value[20];
char Strings[200], Name[20];
XSLPpreparseformula(Prob, "sin ( x + y )", NULL,
Type, Value, Strings, NULL);
for (;;) {
XSLPvalidformula(&Type[n], &Value[n], &n, Name, Strings);
if (n == 0) break;
Index = 0;
if (Type[n+1] == XSLP_LB) { /* function */
NewType = XSLP_IFUN;
XSLPgetindex(Prob, XSLP_INTERNALFUNCNAMESNOCASE,
Name, &Index);
}
else { /* try for column */
NewType = XSLP_VAR;
XSLPgetindex(Prob, 2, Name, &Index);
}
if (Index) {
Type[n] = NewType; Value[n] = Index;
}
else {
printf("\nUnidentified token %s",Name);
break;
}
}
XSLPpreparseformula converts the formula into unparsed internal
format.
XSLPvalidformula then checks forward from the last invalid token
and tries to identify it as an internal function (followed by a left bracket) or as a
column (otherwise). If it cannot be identified, the checking stops with an error message.
Otherwise, the token type and value are updated and the procedure continues.
Related topics
If you have any comments or suggestions about these pages,
please send mail to docs@dashoptimization.com.