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

Add bridge from Cumulative to MILP #2398

Open
schlichtanders opened this issue Jan 9, 2024 · 6 comments
Open

Add bridge from Cumulative to MILP #2398

schlichtanders opened this issue Jan 9, 2024 · 6 comments
Labels
Project: constraint programming Issues relating to constraint programming Submodule: Bridges About the Bridges submodule
Milestone

Comments

@schlichtanders
Copy link

schlichtanders commented Jan 9, 2024

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!

Originally posted by @odow in #1805 (comment)

Which Solver supports MOI.Cumulative?

I am just starting to use MOI.Cumulative, however I am lost about which solver supports it. You mentioned Cbc, HiGHS and Gurobi, but the docs do not mention that MOI.Cumulative would be supported by any of these.

Actually the Cumulative test explicitly skips those solvers who do not support Moi.Cumulative, so I guess the mentioned test is not run for these.

(I also tried a little example with HiGHS, but it says VectorOfVariables-in-Cumulative is not supported)

Failing Example

m = Model(HiGHS.Optimizer)
n = 10
@variable(m, test_start[1:n] >= 0)
@variable(m, test_duration[1:n] >= 1)
@variable(m, resources[1:n] == 1)
@variable(m, resource_bound == 1)
# constraint to be after another
@constraint(m, [test_start; test_duration; resources; resource_bound] in MOI.Cumulative(3*n+1))

# objective
@variable(m, total_end >= 0)
@constraint(m, total_end .>= (test_start .+ test_duration))
@objective(m, Min, total_end)

optimize!(m)

@show value.(test_start) value.(test_duration)

which fails with

Constraints of type MathOptInterface.VectorOfVariables-in-MathOptInterface.Cumulative are not supported by the solver.

If you expected the solver to support your problem, you may have an error in your formulation. Otherwise, consider using a different solver.

The list of available solvers, along with the problem types they support, is available at https://jump.dev/JuMP.jl/stable/installation/#Supported-solvers.

error(::String)@error.jl:35
_moi_add_constraint(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{HiGHS.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, ::MathOptInterface.VectorOfVariables, ::MathOptInterface.Cumulative)@constraints.jl:686
add_constraint(::JuMP.Model, ::JuMP.VectorConstraint{JuMP.VariableRef, MathOptInterface.Cumulative, JuMP.VectorShape}, ::String)@constraints.jl:713
macro expansion@[Local: 133](http://localhost:1234/edit?id=d74b46c6-aed3-11ee-0b56-c17eddcbfb9c#)[inlined]
macro expansion@[Local: 375](http://localhost:1234/edit?id=d74b46c6-aed3-11ee-0b56-c17eddcbfb9c#)[inlined]
top-level scope@[Local: 9](http://localhost:1234/edit?id=d74b46c6-aed3-11ee-0b56-c17eddcbfb9c#)[inlined]

As there seems to be no bridge, I am really struggling, how to use this constraint.

@schlichtanders
Copy link
Author

It seems the only option is MiniZinc.jl, it is pretty slow though...

It would be great if Cumulative (and Path) could also get a MOI bridge

@odow
Copy link
Member

odow commented Jan 9, 2024

As there seems to be no bridge
It would be great if Cumulative (and Path) could also get a MOI bridge

Correct, see:

I haven't done Path and Cumulative because they're quite complicated

It seems the only option is MiniZinc.jl, it is pretty slow though...

What size problem are you solving?

@odow
Copy link
Member

odow commented Jan 10, 2024

@odow odow changed the title How to use MOI.Cumulative constraint? Add bridge from Cumulative to MILP Jan 10, 2024
@odow odow added Submodule: Bridges About the Bridges submodule Project: constraint programming Issues relating to constraint programming labels Jan 10, 2024
@odow odow added this to the v1.x milestone Jan 10, 2024
@blegat
Copy link
Member

blegat commented Jan 10, 2024

It seems the only option is MiniZinc.jl, it is pretty slow though...

What is slow exactly ? The time taken by MiniZinc.jl, the time taken by minizinc to reformulate or the time it takes for the MILP solver because the MILP reformulation is not appropriate ?

@odow
Copy link
Member

odow commented Jan 10, 2024

the time it takes for the MILP solver because the MILP reformulation is not appropriate ?

I assume this. The cumulative constraint is non-trivial to reformulate. (See PDF above.)

@schlichtanders
Copy link
Author

Thank you for the pdf pointer.

I can confirm that MiniZinc.jl performance is unacceptable slow for even tiny cases.
Unfortunately I probably won't find time to implement the PDF algorithm for a MOI bridge, (in case I find another quicker workaround).

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 Submodule: Bridges About the Bridges submodule
Development

No branches or pull requests

3 participants