Initializing help system before first use

XSLPaddformulas

XSLPaddformulas


Purpose
Add non-linear formulas to the SLP problem.
Synopsis
int XPRS_CC XSLPaddformulas(XSLPprob Prob, int nFormulas, int *RowIndex, int *FormulaStart, int Parsed, int *Type, double *Value);
Arguments
Prob 
The current SLP problem.
nFormulas 
Number of non-linear coefficients to be added.
RowIndex 
Integer array holding index of row for the coefficient.
FormulaStart 
Integer array of length nFormulas+1 holding the start position in the arrays Type and Value of the formula for the coefficients. FormulaStart[nFormulas] should be set to the next position after the end of the last formula.
Parsed 
Integer indicating 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 formula for each coefficient.
Value 
Array of values corresponding to the types in Type.
Example
Assume that the rows and columns of Prob are named Row0, Row1 ..., Col0, Col1 ... The following example adds nonlinear formulas representing:
Col2 * Col3 * Col6 ˆ2 into Row1 and
Col2 * Col3 ˆ 2 into Row3.
int RowIndex[3], FormulaStart[4], Type[8];
int n, nFormulas;
double Value[8];

RowIndex[0] = 1;
RowIndex[1] = 1;
RowIndex[2] = 3;

n = nFormulas = 0;
FormulaStart[nFormulas++] = n;
Type[n] = XSLP_COL; Value[n++] = 3;
Type[n++] = XSLP_EOF;

FormulaStart[nFormulas++] = n;
Type[n] = XSLP_COL; Value[n++] = 2;
Type[n] = XSLP_COL; Value[n++] = 3;
Type[n] = XSLP_OP;  Value[n++] = XSLP_MULTIPLY;
Type[n] = XSLP_COL; Value[n++] = 6;
Type[n] = XSLP_CON; Value[n++] = 2;
Type[n] = XSLP_OP;  Value[n++] = XSLP_EXPONENT;
Type[n] = XSLP_OP;  Value[n++] = XSLP_MULTIPLY;
Type[n++] = XSLP_EOF;

FormulaStart[nFormulas++] = n;
Type[n] = XSLP_COL; Value[n++] = 2;
Type[n] = XSLP_COL; Value[n++] = 3;
Type[n] = XSLP_CON; Value[n++] = 2;
Type[n] = XSLP_OP;  Value[n++] = XSLP_EXPONENT;
Type[n] = XSLP_OP;  Value[n++] = XSLP_MULTIPLY;
Type[n++] = XSLP_EOF;

FormulaStart[nFormulas] = n;

XSLPaddformulas(Prob, nFormulas, RowIndex, FormulaStart, 1 /* reversed Polish */, Type, Value);
Further information

Formula is made up of a list of tokens in Type and Value starting at FormulaStart[j]. The tokens follow the rules for parsed or unparsed formulae as indicated by the setting of Parsed. The formula must be terminated with an XSLP_EOF token. If several rows share the same nonlinear expression, they can have the same value in FormulaStart. For possible token types and values see the chapter on Xpress NonLinear Formulae.

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

The behaviour for existing formulas is additive: the formula defined in the parameters are added to any existing nonlinear expressions in the row. However, due to performance considerations, such duplications should be avoided when possible.


Related topics