getctrnextterm
getctrnextterm |
Purpose
Synopsis
void *getctrnextterm(XPRMcontext ctx, XPRMlinctr ctr, void *prev, XPRMmpvar *var, double *coeff);
Arguments
ctx
|
Mosel's execution context
|
ctr
|
Reference to a linear constraint
|
prev
|
Last value returned by this function. Should be
NULL for the first call
|
var
|
Pointer to return the decision variable reference for the current term
|
coeff
|
Pointer to return the coefficient of the current term
|
Return value
The value to be used as
prev for the next call or
NULL when all terms have been returned.
Example
The following function displays the terms of a linear constraint.
void displinctr(XPRMcontext ctx, XPRMlinctr ctr) { void *prev; XPRMmpvar v; double coeff; prev=mm->getctrnextterm(ctx, ctr, NULL, &v, &coeff); mm->printf(ctx, "%g ",coeff); while(prev!=NULL) { prev=mm->getctrnextterm(ctx, ctr, prev, &v, &coeff); mm->printf(ctx, "%+g %p ", coeff, v); } mm->printf(ctx, "\n"); }
Further information
1. This function can be called repeatedly to enumerate all terms of a linear constraint. For the first call, the parameter
prev must be
NULL and the function returns the constant term of the linear constraint (the value returned for
var is then
NULL and
coeff contains the constant term). For the following calls, the value of
prev must be the last value returned by the function. The enumeration is completed when the function returns
NULL.
2. With a range constraint it is possible to retrieve the lower bound of the range using the special value
-1 for the
prev parameter. In this case the function returns always
NULL.