Try our new documentation site (beta).
![next](https://www.gurobi.com/wp-content/plugins/hd_documentations/documentation/9.0/refman/next.png?x70725)
![up](https://www.gurobi.com/wp-content/plugins/hd_documentations/documentation/9.0/refman/up.png?x70725)
![previous](https://www.gurobi.com/wp-content/plugins/hd_documentations/documentation/9.0/refman/prev.png?x70725)
Next: GRBModel.addGenConstrPoly() Up: GRBModel.addGenConstrXxx() Previous: GRBModel.addGenConstrIndicator()
GRBModel.addGenConstrPWL()
Add a new general constraint of type GRB.GENCONSTR_PWL to a model.
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.
GRBGenConstr | addGenConstrPWL ( | GRBVar | xvar, |
GRBVar | yvar, | ||
double[] | xpts, | ||
double[] | ypts, | ||
String | name ) |
-
Arguments:
xvar: The variable.
yvar: The variable.
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.
name: Name for the new general constraint.
Return value:
New general constraint.
![next](https://www.gurobi.com/wp-content/plugins/hd_documentations/documentation/9.0/refman/next.png?x70725)
![up](https://www.gurobi.com/wp-content/plugins/hd_documentations/documentation/9.0/refman/up.png?x70725)
![previous](https://www.gurobi.com/wp-content/plugins/hd_documentations/documentation/9.0/refman/prev.png?x70725)
Next: GRBModel.addGenConstrPoly() Up: GRBModel.addGenConstrXxx() Previous: GRBModel.addGenConstrIndicator()
![](/wp-content/plugins/hd_documentations/content/images/documentation-ampl-guide.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-cloud.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-example-tour.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-quick-start.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-reference-manuals.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-remote-services.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/quickstart-os-linux.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/quickstart-os-mac-osx.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/quickstart-os-windows.webp?x70725)