Closed vtjeng closed 1 month ago
All you need to do is give a vector of the discretization points d
along the domain of your x
variable, and a vector of the corresponding function values fd
at each point; you don't need to compute big-M bounds. Then you can impose that z = f(x)
(if your function is univariate) with
z = piecewiselinear(model, x, d, fd)
You can optionally specify the formulation you would like to use; you can see our recent paper and the references for more info on the details of the formulations.
Closing as stale and because this discussion seems resolved.
I seem to have missed this response and only realized it when @odow closed the issue ...
along the domain of your
x
variable
just to clarify, @joehuchette, do we need the domain to be finite? e.g. if I have f(x) = max(x, 0)
then I also need to know what range of values x could take?
The d
in:
z = piecewiselinear(model, x, d, fd)
is a discrete set of points.
PiecewiseLinearOpt.jl doesn't get to see the expression max(x, 0)
. It just gets to see the set of points (d, fd)
.
x
will end up being restricted to some convex combination of the domain d
.
You mention that you can do a better job formulating piecewise constraints here. Could you explain what your approach is? (My big-M approach relies on finding the best possible bounds I can on the input, and then using those bounds in the big-M formulation.
(Filing as an issue here because I thought it would be relevant to future users of this library.)