Try our new documentation site (beta).


GRBModel::addGenConstrPWL()

Add a new general constraint of type GRB_GENCONSTR_PWL to a model.

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

GRBGenConstr addGenConstrPWL ( GRBVar xvar,
    GRBVar yvar,
    int npts,
    const double* xpts,
    const double* ypts,
    std::string name="" )

Arguments:

xvar: The <span>$</span>x<span>$</span> variable.

yvar: The <span>$</span>y<span>$</span> variable.

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

xpts: The <span>$</span>x<span>$</span> values for the points that define the piecewise-linear function. Must be in non-decreasing order.

ypts: The <span>$</span>y<span>$</span> values for the points that define the piecewise-linear function.

name (optional): Name for the new general constraint.

Return value:

New general constraint.


Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Search

Gurobi Optimization