Initializing help system before first use

XSLPchgformula

XSLPchgformula


Purpose
Add or replace a single matrix formula using a parsed or unparsed formula
Synopsis
int XPRS_CC XSLPchgformula(XSLPprob Prob, int RowIndex, int Parsed, int *Type, double *Value);
Arguments
Prob 
The current SLP problem.
RowIndex 
The index of the matrix row for the coefficient.
Parsed 
Integer indicating the whether the token arrays are formatted as internal unparsed ( Parsed=0) or internal parsed reverse Polish ( Parsed=1).
Type 
Array of token types providing the description and formula for each item.
Value 
Array of values corresponding to the types in Type.
Example
Assuming that the columns of the matrix are named Col1, Col2, etc, the following example puts the formula sin(Col1) into the coefficient in row 1.
int n, iSin, Type[4];
double Value[4];

XSLPgetindex(Prob, XSLP_INTERNALFUNCNAMESNOCASE,
             "sin", &iSin);

n = 0;
Type[n] = XSLP_IFUN; Value[n++] = iSin;
Type[n] = XSLP_VAR;  Value[n++] = 1;
Type[n++] = XSLP_RB;
Type[n++] = XSLP_EOF;

Factor = 2.5;
XSLPchgformula(Prob, 1, 0, Type, Value);

XSLPgetindex is used to retrieve the index for the internal function sin. The "nocase" version matches the function name regardless of the (upper or lower) case of the name.

Token type XSLP_VAR always counts from 1, so Col1 is always 1.

The formula is written in unparsed form (Parsed = 0) and so it is provided as tokens in the same order as they would appear if the formula were written in character form.


Further information

If the row already has a nonlinear expression in it, it will be changed into the new formula. If it does not exist, it will be added to the problem.


Related topics