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

Constraint programming support #1805

Closed
26 tasks done
odow opened this issue Apr 20, 2022 · 9 comments · Fixed by #1955
Closed
26 tasks done

Constraint programming support #1805

odow opened this issue Apr 20, 2022 · 9 comments · Fixed by #1955
Labels
Project: constraint programming Issues relating to constraint programming

Comments

@odow
Copy link
Member

odow commented Apr 20, 2022

This issue is to track support for a limited subset of constraint programming in MOI. At present, we don't envisage MOI having the same scope as MiniZinc, but we want users to be able to write down common constraint programs and solve them using a specialized constraint programming solver, or a MIP solver via bridges.

Background

MathOptInterface

Add new sets to MOI. Definitions taken from: https://www.minizinc.org/doc-2.5.5/en/lib-globals.html

MOI.Bridges

MOI.FileFormats

MOI.Test

  • Add new tests for constraint solvers

Solvers

Update solvers to new sets in MOI

Replaced by the MiniZinc interface: https://github.com/jump-dev/MiniZinc.jl
@odow
Copy link
Member Author

odow commented May 1, 2022

I've opened PRs to add the first 5 sets, since they are the simplest. There's still some bike shedding to be done. For the next step, I'll add the FlatZinc file format to get things in place. One we have that, we can start some end-to-end tests with a CP solver, and that should flush out any issues before we work on the other 5 sets.

@odow
Copy link
Member Author

odow commented May 3, 2022

I've been taking a look at FlatZinc support. it's actually slightly more complicated than it looks, because its effectively MOI without bridges, and each solver supports a different set of constraints. What would be easier to target is MiniZinc, and then have MiniZinc compile down to FlatZinc when passed a particular solver. For example, Chuffed_jll contains a directory of re-definitions, which are equivalent to our bridges.

First step is to get libminizinc building: JuliaPackaging/Yggdrasil#4861

@odow
Copy link
Member Author

odow commented May 4, 2022

I now have https://github.com/jump-dev/MiniZinc.jl.

This writes the JuMP model into a flattened form of MiniZinc, and we then call out to different solvers. The benefit of this is that it automatically supports all of the solvers that MiniZinc supports, so it works for Chuffed and Gurobi, for example.

I have it working locally, but MiniZinc_jll is segfaulting: JuliaPackaging/Yggdrasil#4866

@odow
Copy link
Member Author

odow commented May 19, 2022

Bill says

i assume that MOI++ including constraints you're working on will support reified constraints so that in principle we might
support something like
alldiff(x1,x3,x5) or alldiff(x2,x4,x6) which translates to:
alldif_reif(x1,x3,x5,b1) and
alldiff_reif(x2,x4,x6,b2) and
(b1 or b2)

we don't necessarily need models for all reified constraints now and those could be filled in over time.

We could probably add Reified{S} similar to how we have indicator constraints.

@odow
Copy link
Member Author

odow commented Jun 9, 2022

Initial support for the sets has been merged, and MiniZinc.jl is being registered: JuliaRegistries/General#62010

@odow
Copy link
Member Author

odow commented Jun 30, 2022

MILP bridges are largely done. I haven't done Path and Cumulative because they're quite complicated, but Cbc, HiGHS, and Gurobi are all passing tests with the new constraint programming sets!

Once #1931 is merged, I'll prep for v1.6.0, and then write a blog post showing off the new goods.

@odow
Copy link
Member Author

odow commented Jul 18, 2022

I've started looking into reified constraints: jump-dev/MiniZinc.jl#13

@odow
Copy link
Member Author

odow commented Jul 18, 2022

@odow
Copy link
Member Author

odow commented Jul 20, 2022

This issue is pretty close to completion. One blocker is deciding whether to add the Reified set. I've added Reified to MiniZinc.jl, but adding to MOI would add a lot more sets, and the reified to MILP bridges are much more complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Project: constraint programming Issues relating to constraint programming
Development

Successfully merging a pull request may close this issue.

1 participant