Try our new documentation site (beta).


GRBModel::setPWLObj()

Set a piecewise-linear objective function for a variable.

The arguments to this method specify a list of points that define a piecewise-linear objective function for a single variable. Specifically, the <span>$</span>x<span>$</span> and <span>$</span>y<span>$</span> arguments give coordinates for the vertices of the function.

For additional details on piecewise-linear objective functions, refer to this discussion.

void setPWLObj ( GRBvar var,
    int npoints,
    double[] x,
    double[] y )
    Set the piecewise-linear objective function for a variable.

    Arguments:

    var: The variable whose objective function is being set.

    npoints: Number of points that define the piecewise-linear function.

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

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

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