joehuchette / PiecewiseLinearOpt.jl

Solve optimization problems containing piecewise linear functions
Other
51 stars 21 forks source link

Formulating linear constraints #15

Open vtjeng opened 6 years ago

vtjeng commented 6 years ago

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.)

joehuchette commented 6 years 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.