Initializing help system before first use

XPRBgetnextterm

XPRBgetnextterm


Purpose
Get the next linear term of a constraint.
Synopsis
const void *XPRBgetnextterm(XPRBctr ctr, const void *ref, XPRBvar *var, double *coeff);
Arguments
ctr 
Constraint whose terms are to be enumerated.
ref 
Reference pointer or NULL.
var 
BCL reference to a variable. May be NULL if not required.
coeff 
Coefficient associated to variable var. May be NULL if not required.
Return value
Reference pointer for the next call to XPRBgetnextterm or NULL if there are no more terms.
Example
XPRBprob prob;
XPRBctr ctr;
XPRBvar var;
double coeff;
const void *ref;
   ...
ref = NULL;
while ((ref = XPRBgetnextterm(ctr, ref, &var, &coeff)) != NULL) {
  XPRBprintf("Variable %s has coefficient %g\n",
    XPRBgetvarname(var), coeff);
}
This code extract prints all linear terms of a constraint.
Further information
This function can be used to enumerate the linear terms of a constraint. The second parameter serves to keep track of current location in the enumeration; if this parameter is NULL, the first term is returned. This function returns NULL if it is called with the reference to the last element. Otherwise, the returned value can be used as the input parameter ref to retrieve the following term of the same type. Note that the constant term of the constraint is not included in this enumeration (it can be retrieved with XPRBgetcoeff)
Related topics