JuliaConstraints / ConstraintProgrammingExtensions.jl

Extensions to MathOptInterface to support constraint programming.
MIT License
22 stars 2 forks source link

Use this package more generally? #7

Open dourouc05 opened 3 years ago

dourouc05 commented 3 years ago

This package started with https://github.com/jump-dev/JuMP.jl/issues/2227. Its goal is to be the official extension to MOI for constraint programming. It is now in a useable state, and allows to wrap most of the CPLEX CP Optimizer solver: it should be relatively stable, except for new features (unlike the first versions, which broke compatibility every now and then).

In the Julia ecosystem, there are two other packages for constraint programming, but they focus on solving problems: https://github.com/Wikunia/ConstraintSolver.jl and https://github.com/JuliaConstraints. For now, these packages have different MOI sets to represent the same constraints. The goal of the present package is to provide these MOI sets, so that users can easily switch from one solver to another (and to ease writing new solvers/wrappers for existing solvers). It may be integrated into MOI in the future.

I mapped the constraints supported in each package to those in CP: ConstraintSolver.jl and JuliaConstraints.

@Wikunia @Azzaare Is there anything missing in this package? Would you have designed things differently? Would you be ready to use this package as a dependency for your own solvers (instead of your custom sets), until it migrates into MOI?

Azzaare commented 3 years ago

Hi @dourouc05

Sorry, I have been quite busy, so I will try an extensive answer later.

The answer is yes on principle, even though I would need to check the exact implications (for instance are the involved packages all registered etc).

We have a Constraint Programming stream on julia's Zulip btw. There is also an incoming new CP solver in Julia called SeaPearl.jl. one of the author is also on Zulip.

Talk to you soon (we can schedule an online meeting to make things smoother too).

Wikunia commented 3 years ago

Hi @dourouc05 thanks for the package! I have one question by skimming through it. Do you support x in AllDifferent() or just x in AllDifferent(5) so does one need to fill in the dimension as a user?

dourouc05 commented 3 years ago

@Azzaare Regarding dependencies, this package only depends on MOI, and it is also registered. (Unlike CPLEXCP, a wrapper for CPLEX CP Optimizer, which has heavier dependencies…)

Thanks for pointing at Zulip, I didn't know it existed! (And I now subscribed, of course!)

For meeting, we could have a BoF or equivalent at JuliaCon or the next JuMP workshop?

@Wikunia MOI forces you to implement MOI.dimension, so that the dimension must be stored in the set, like Zeros or Nonnegatives (although I don't know the whole set of consequences if you don't). At the very least, I'm using it in some sets like reification or conditions in order to parse the set of variables (e.g., for reification, the first variable is a binary and the rest is the constraint being reified). If there is no dimension, then it's not possible to parse things like conditions (if AllDifferent(4) then AllDifferent(3) else AllDifferent(2), for instance).

Azzaare commented 3 years ago

Thanks @dourouc05

If it registered I am fine with it. We were considering BoF, but we have little time left to submit ... I will try to have a better look at BoF submissions. It should not be too complicated.

As for the dimension related thing, there is a workaround that was given to me on JuMP-dev (@odow I think), which allows us to skip the dimension in JuMP syntax (but not in MOI). For my solver, providing the dimension is just extra noise.

What about making the dimension optional?

odow commented 3 years ago

At the MOI level, you should explicitly state the dimension. We can make nicer syntax at the JuMP level https://github.com/jump-dev/JuMP.jl/blob/3ba8d43527534492e904e79cc74732e5e265441c/src/sets.jl#L15-L39

Azzaare commented 3 years ago

Hi there! I think I more or less completed the basic interface I wanted with JuMP. I think the solver framework in JuliaConstraints is ready to step forward with ConstraintProgrammingExtensions.jl and more. All my code interfacing MOI (and JuMP) is in https://github.com/JuliaConstraints/CBLS.jl

Also, there is a new kid in town with https://github.com/corail-research/SeaPearl.jl It seems they have a JuMP interface too.

It seems we have some critical mass. Should we try to have some meeting?