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

[Bridges] add {SOS1,SOS2,Indicator}ToMILPBridge #2318

Merged
merged 11 commits into from
Oct 29, 2023
Merged

[Bridges] add {SOS1,SOS2,Indicator}ToMILPBridge #2318

merged 11 commits into from
Oct 29, 2023

Conversation

odow
Copy link
Member

@odow odow commented Oct 24, 2023

Part of #2316

I'll need to run the solver-tests, because this should let HiGHS support SOS constraints, but it will probably also start supporting Indicator because of IndicatorToSOS, except that IndicatorToSOS introduces an unbounded variable in the SOS.

https://github.com/jump-dev/MathOptInterface.jl/actions/runs/6620504066

src/Utilities/variables.jl Outdated Show resolved Hide resolved
@odow
Copy link
Member Author

odow commented Oct 24, 2023

So this is pretty breaking (to tests, not in practice) because it opens up IndicatorToSOS1 bridge. So I think we need to add an IndicatorToMILPBridge to fix it.

@odow
Copy link
Member Author

odow commented Oct 25, 2023

@odow
Copy link
Member Author

odow commented Oct 25, 2023

Found a few bugs in jump-dev/HiGHS.jl#187, jump-dev/HiGHS.jl#188.

@odow
Copy link
Member Author

odow commented Oct 25, 2023

@odow
Copy link
Member Author

odow commented Oct 25, 2023

@odow
Copy link
Member Author

odow commented Oct 26, 2023

Failures are:

@odow odow changed the title [Bridges] add SOS1ToMILPBridge and SOS2ToMILPBridge [Bridges] add {SOS1,SOS2,Indicator}ToMILPBridge Oct 26, 2023
@odow
Copy link
Member Author

odow commented Oct 26, 2023

@odow
Copy link
Member Author

odow commented Oct 27, 2023

It's pretty cool that stuff like this works now:

using JuMP, HiGHS
xp = 0.0:0.1:pi
yp = sin.(xp)
n = length(xp)
model = Model(HiGHS.Optimizer)
@variable(model, 0 <= x <= π)
@variable(model, -1 <= y <= 1)
@variable(model, 0 <= λ[1:n] <= 1)
@variable(model, z, Bin)
@constraint(model, λ in SOS2())
@constraint(model, sum(λ) == 1)
@constraint(model, xp' * λ == x)
@constraint(model, yp' * λ == y)
@constraint(model, z --> {x <= 0.45})
@constraint(model, !z --> {x == y})
@objective(model, Max, x)
optimize!(model)

This will let us use SOS1 and SOS2 and indicator constraints in the documentation tutorials.

@blegat
Copy link
Member

blegat commented Oct 27, 2023

Yes, it's also helpful for teaching since then you can add complexity incrementally. The students can use indicator constraints without having learned the big-M formulation as requirement.

@odow odow merged commit cab3440 into master Oct 29, 2023
17 checks passed
@odow odow deleted the od/sos-bridges branch October 29, 2023 20:04
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