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

[docs] add tutorial on piecewise linear #3563

Merged
merged 5 commits into from
Nov 7, 2023
Merged

Conversation

odow
Copy link
Member

@odow odow commented Nov 6, 2023

Copy link

codecov bot commented Nov 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ec3c779) 98.20% compared to head (c43d014) 98.38%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3563      +/-   ##
==========================================
+ Coverage   98.20%   98.38%   +0.17%     
==========================================
  Files          37       37              
  Lines        5622     5624       +2     
==========================================
+ Hits         5521     5533      +12     
+ Misses        101       91      -10     

see 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@odow
Copy link
Member Author

odow commented Nov 6, 2023

I think this is a good addition. I can imagine linking quite a few discourse posts to it.

@jd-foster
Copy link
Collaborator

This is nice; I've wanted to write something like this for a while but hadn't got around to it.

@jd-foster
Copy link
Collaborator

jd-foster commented Nov 7, 2023

  1. Are you interested in solving the problems and displaying the optimal values?
  2. I find it a bit confusing to put outer approximation first up when it's about PWL functions - the OA stuff is 'implicit' PWL while the linear approximation is more 'explicit'.
  3. What do you think about an example showing combination PWL constraint + exact function (x^2 >= 0) constraint to give a tight envelope?
  4. Could reinforce that SOS2 gets you on the line by showing an optimal solution 'before' vs 'after' add the SOS2() constraint.

BTW: typo here for SOS1, read SOS2:

SOS1 (Special Ordered Sets type 2) object than can be used to constrain a

@odow
Copy link
Member Author

odow commented Nov 7, 2023

See #3565 for docstrings

@odow
Copy link
Member Author

odow commented Nov 7, 2023

I find it a bit confusing to put outer approximation first up when it's about PWL functions

Should we just call it # Approximating nonlinear functions then?

@odow
Copy link
Member Author

odow commented Nov 7, 2023

What do you think about an example showing combination PWL constraint + exact function (x^2 >= 0) constraint to give a tight envelope?

I don't understand. How does one represent x^2 >= 0?

@odow
Copy link
Member Author

odow commented Nov 7, 2023

Are you interested in solving the problems and displaying the optimal values?

I wasn't quite sure of a good way to do this. Ideally, you'd have some sort of interactive slider, where you could move x around, but we can't do that in a static environment.

@jd-foster
Copy link
Collaborator

I don't understand. How does one represent x^2 >= 0?

No idea why I wrote that: I meant the epi-graph{t : t >= x^2 }.

@odow
Copy link
Member Author

odow commented Nov 7, 2023

I still don't really follow what you're suggesting?

@jd-foster
Copy link
Collaborator

jd-foster commented Nov 7, 2023

Broadly speaking, I was thinking that you can combine both sections of the tutorial: a non-convex inner approximation boundary with a convex function (or concave, depending on the direction of the inequality) constraint to get a tight envelope to a function.

@constraints(model, begin
	y >= f(x),
	x == sum(λ[i] * x̂[i] for i in 1:n)
	y <= sum(λ[i] * ŷ[i] for i in 1:n)
    sum(λ) == 1
    λ in SOS2() 
)

But I'll just wait to read the whole thing again once it settles, or just PR later.

Edit: I guess this becomes nonlinear, so might not be useful within the LP tutorials or HiGHS anyway.

@odow odow merged commit 23a7f00 into master Nov 7, 2023
11 checks passed
@odow odow deleted the od/doc-piecewise-linear branch November 7, 2023 21:06
@odow
Copy link
Member Author

odow commented Nov 7, 2023

@jd-foster I merged because this is an improvement. But feel free to make other edits in a separate PR.

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

Successfully merging this pull request may close these issues.

2 participants