Try our new documentation site (beta).
Filter Content By
Version
Text Search
${sidebar_list_label} - Back
Filter by Language
Model.setPWLObj()
setPWLObj ( var, x, y )
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 and
arguments give coordinates for the
vertices of the function.
For additional details on piecewise-linear objective functions, refer to this discussion.
Arguments:
var: A Var object that gives the variable whose objective function is being set.
x: The values for the points that define the piecewise-linear function. Must be in non-decreasing order.
y: The values for the points that define the piecewise-linear function.
Example usage:
model.setPWLObj(var, [1, 3, 5], [1, 2, 4])
![](/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)