Filter Content By
Version
Languages

 int GRBaddgenconstrPWL ( GRBmodel *model, const char *name, int xvar, int yvar, int npts, double *xpts, double *ypts )

Add a new general constraint of type GRB_GENCONSTR_PWL to a model. Note that, due to our lazy update approach, the new constraint won't actually be added until you update the model (using GRBupdatemodel), optimize the model (using GRBoptimize), or write the model to disk (using GRBwrite).

A piecewise-linear (PWL) constraint states that the relationship must hold between variables and , where is a piecewise-linear function. The breakpoints for are provided as arguments. Refer to the description of piecewise-linear objectives for details of how piecewise-linear functions are defined.

Return value:

A non-zero return value indicates that a problem occurred while adding the general constraint. Refer to the Error Code table for a list of possible return values. Details on the error can be obtained by calling GRBgeterrormsg.

Arguments:

model: The model to which the new general constraint should be added.

name: Name for the new general constraint. This argument can be NULL, in which case the constraint is given a default name.

xvar: The index of variable .

yvar: The index of variable .

npts: The number of points that define the piecewise-linear function.

xpts: The values for the points that define the piecewise-linear function. Must be in non-decreasing order.

ypts: The values for the points that define the piecewise-linear function.

Example usage:

  double xpts[] = {1, 3, 5};
double ypts[] = {1, 2, 4};
error = GRBaddgenconstr(model, "pwl", xvar, yvar, 3, x, y);