ConstraintSolver.jl icon indicating copy to clipboard operation
ConstraintSolver.jl copied to clipboard

Update to JuMP and MOI v1

Open blegat opened this issue 1 year ago • 8 comments

Closes https://github.com/Wikunia/ConstraintSolver.jl/pull/289

blegat avatar Aug 29 '24 17:08 blegat

Thanks a lot for your work. Appreciate it 😊

Wikunia avatar Aug 29 '24 19:08 Wikunia

I'm giving a tutorial next Wednesday and I'd like to show that one can swap MiniZinc with CBLS or ConstraintSolver so I'll first update with this PR and then transition to the MOI sets for the sets that I need (e.g., MOI.AllDifferent instead of CPE.AllDifferent). Do you think you could make a release before the tutorial so that users of the tutorial don't have to checkout the package ? I'll release a new version of CPE soon so that your dependencies are released.

blegat avatar Aug 29 '24 21:08 blegat

I'm now getting

Simple: Error During Test at /home/blegat/.julia/dev/ConstraintSolver/test/constraints/element1Dconst.jl:2
  Got exception outside of a @test
  BoundsError: attempt to access 25-element Vector{Int64} at index [28]
  Stacktrace:
    [1] getindex
      @ ./essentials.jl:13 [inlined]
    [2] prune_constraint!(com::ConstraintSolver.ConstraintSolverModel{Float64}, constraint::ConstraintSolver.Element1DConstConstraint, fct::MathOptInterface.VectorOfVariables, set::ConstraintSolver.Element1DConstInner; logs::Bool)
      @ ConstraintSolver ~/.julia/dev/ConstraintSolver/src/constraints/element1Dconst.jl:153
    [3] prune!(com::ConstraintSolver.ConstraintSolverModel{Float64}; pre_backtrack::Bool, all::Bool, only_once::Bool, initial_check::Bool)
      @ ConstraintSolver ~/.julia/dev/ConstraintSolver/src/pruning.jl:95
    [4] prune!
      @ ~/.julia/dev/ConstraintSolver/src/pruning.jl:53 [inlined]
    [5] backtrack!(com::ConstraintSolver.ConstraintSolverModel{Float64}, max_bt_steps::Int64; sorting::Bool, log_table::Bool, first_parent_idx::Int64, single_path::Bool, compute_bounds::Bool, check_bounds::Bool, cb_finished_pruning::ConstraintSolver.var"#159#161")
      @ ConstraintSolver ~/.julia/dev/ConstraintSolver/src/ConstraintSolver.jl:602
    [6] backtrack!
      @ ~/.julia/dev/ConstraintSolver/src/ConstraintSolver.jl:509 [inlined]
    [7] solve_with_backtrack!(com::ConstraintSolver.ConstraintSolverModel{Float64}, max_bt_steps::Int64; sorting::Bool)
      @ ConstraintSolver ~/.julia/dev/ConstraintSolver/src/ConstraintSolver.jl:480

Not sure how to fix it :thinking:

blegat avatar Aug 29 '24 21:08 blegat

In general I'm happy to release a new version before that. Not sure about the error though. Don't have much time this weekend but will check.

I guess the one test case you removed is currently a limitation though.

Wikunia avatar Aug 30 '24 05:08 Wikunia

Ah just saw that a new JuMP version with the fix was already released.

Wikunia avatar Aug 30 '24 05:08 Wikunia

When it's a bug fix, we prefer to release it quickly. Quite convenient to open an issue late yesterday and to have the bug fixed and released overnight, thanks @odow !

blegat avatar Aug 30 '24 07:08 blegat

@blegat I'm currently running into the problem that JuMP defines operator_to_set(error_fn::Function, ::Val{:<}) which is a method that I define as well to work with CPE.Strictly.

(ConstraintSolver) pkg> instantiate
Precompiling project...
        Info Given ConstraintSolver was explicitly requested, output will be shown live 
WARNING: Method definition operator_to_set(Function, Base.Val{:<}) in module JuMP at /Users/olek/.julia/packages/JuMP/PKxEW/src/macros/@constraint.jl:560 overwritten in module ConstraintSolver at /Users/olek/Code/git/ConstraintSolver.jl/src/MOI_wrapper/constraints.jl:5.
ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.
  ? ConstraintSolver

Does this make it impossible to use < with JuMP? I'm quite confused why this problem doesn't appear in CI.

Wikunia avatar Aug 30 '24 19:08 Wikunia

I also have it locally but it doesn't prevent the tests from passing

blegat avatar Aug 30 '24 22:08 blegat