Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formulating linear constraints #15

Closed
vtjeng opened this issue Oct 27, 2017 · 4 comments
Closed

Formulating linear constraints #15

vtjeng opened this issue Oct 27, 2017 · 4 comments

Comments

@vtjeng
Copy link

vtjeng commented Oct 27, 2017

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
Copy link
Contributor

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.

@odow
Copy link
Member

odow commented Sep 11, 2024

Closing as stale and because this discussion seems resolved.

@odow odow closed this as completed Sep 11, 2024
@vtjeng
Copy link
Author

vtjeng commented Sep 11, 2024

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?

@odow
Copy link
Member

odow commented Sep 11, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants