XSLPaddcoefs
XSLPaddcoefs |
int XPRS_CC XSLPaddcoefs(XSLPprob Prob, int nSLPCoef, int *RowIndex, int *ColIndex, double *Factor, int *FormulaStart, int Parsed, int *Type, double *Value);
Prob
|
The current SLP problem.
|
nSLPCoef
|
Number of non-linear coefficients to be added.
|
RowIndex
|
Integer array holding index of row for the coefficient.
|
ColIndex
|
Integer array holding index of column for the coefficient.
|
Factor
|
Double array holding factor by which formula is scaled. If this is
NULL, then a value of 1.0 will be used.
|
FormulaStart
|
Integer array of length
nSLPCoef+1 holding the start position in the arrays
Type and
Value of the formula for the coefficients.
FormulaStart[nSLPCoef] 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.
|
Col2 * Col3 + Col6 * Col2 ˆ2 into Row1 and
Col2 ˆ 2 into Row3.
int RowIndex[3], ColIndex[3], FormulaStart[4], Type[8]; int n, nSLPCoef; double Value[8]; RowIndex[0] = 1; ColIndex[0] = 2; RowIndex[1] = 1; ColIndex[1] = 6; RowIndex[2] = 3; ColIndex[2] = 2; n = nSLPCoef = 0; FormulaStart[nSLPCoef++] = n; Type[n] = XSLP_COL; Value[n++] = 3; Type[n++] = XSLP_EOF; FormulaStart[nSLPCoef++] = n; Type[n] = XSLP_COL; Value[n++] = 2; Type[n] = XSLP_COL; Value[n++] = 2; Type[n] = XSLP_OP; Value[n++] = XSLP_MULTIPLY; Type[n++] = XSLP_EOF; FormulaStart[nSLPCoef++] = n; Type[n] = XSLP_COL; Value[n++] = 2; Type[n++] = XSLP_EOF; FormulaStart[nSLPCoef] = n; XSLPaddcoefs(Prob, nSLPCoef, RowIndex, ColIndex, NULL, FormulaStart, 1, Type, Value);
The first coefficient in Row1 is in Col2 and has the formula Col3, so it represents Col2 * Col3.
The second coefficient in Row1 is in Col6 and has the formula Col2 * Col2 so it represents Col6 * Col2 ˆ2. The formulae are described as parsed (Parsed=1), so the formula is written as
Col2 Col2 *
rather than the unparsed form
Col2 * Col2
The last coefficient, in Row3, is in Col2 and has the formula Col2, so it represents Col2 * Col2.
The jth coefficient is made up of two parts: Factor and Formula. Factor is a constant multiplier, which can be provided in the Factor array. If Xpress NonLinear can identify a constant factor in Formula, then it will use that as well, to minimize the size of the formula which has to be calculated. 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 coefficients share the same formula, they can have the same value in FormulaStart. For possible token types and values see the chapter on "Formula Parsing".
The XSLPadd... functions load additional items into the SLP problem. The corresponding XSLPload... functions delete any existing items first.
The behaviour for existing coefficients is additive: the formula defined in the parameters are added to any existing formula coefficients. However, due to performance considerations, such duplications should be avoided when possible.