diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 844a5282..e783b750 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,13 @@ jobs: ${{ runner.os }}-test-${{ env.cache-name }}- ${{ runner.os }}-test- ${{ runner.os }}- + - name: CPE + shell: julia --project=@. {0} + run: | + using Pkg + Pkg.add([ + PackageSpec(name="ConstraintProgrammingExtensions", rev="master"), + ]) - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 @@ -57,4 +64,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key - run: julia --project=docs/ docs/make.jl \ No newline at end of file + run: julia --project=docs/ docs/make.jl diff --git a/Project.toml b/Project.toml index c7dd9201..aae193b4 100644 --- a/Project.toml +++ b/Project.toml @@ -19,7 +19,7 @@ StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c" TableLogger = "72b659bb-f61b-4d0d-9dbb-0f81f57d8545" [compat] -ConstraintProgrammingExtensions = "^0.6" +ConstraintProgrammingExtensions = "^0.7" DataStructures = "~0.11, ~0.12, ~0.13, ~0.14, ~0.15, ~0.16, ~0.17, ~0.18" Formatting = "^0.4.1" JSON = "~0.18, ~0.19, ~0.20, ~0.21" @@ -27,7 +27,7 @@ JuMP = "^0.22, 0.23, 1" LightGraphs = "1" MathOptInterface = "^0.10, 1" MatrixNetworks = "^1" -StatsBase = "^0.33" -StatsFuns = "^0.9.5" +StatsBase = "^0.33, 0.34" +StatsFuns = "^0.9.5, 1" TableLogger = "^0.1" julia = "^1.6" diff --git a/src/ConstraintSolver.jl b/src/ConstraintSolver.jl index a5a5f528..5a444bd8 100644 --- a/src/ConstraintSolver.jl +++ b/src/ConstraintSolver.jl @@ -93,7 +93,7 @@ include("simplify.jl") Return the ConstraintSolverModel for the Model or Optimizer """ -function get_inner_model(m::Model) +function get_inner_model(m::JuMP.GenericModel) JuMP.backend(m).optimizer.model.model.inner end diff --git a/src/MOI_wrapper/Bridges/bool.jl b/src/MOI_wrapper/Bridges/bool.jl index 5d4ba577..09cc2e28 100644 --- a/src/MOI_wrapper/Bridges/bool.jl +++ b/src/MOI_wrapper/Bridges/bool.jl @@ -77,7 +77,7 @@ function get_constraint_types( if direct_support return [(F,S)] else - return MOIB.added_constraint_types(inner_bridge, F, S) + return MOIB.added_constraint_types(MOIB.Constraint.concrete_bridge_type(inner_bridge, F, S)) end end diff --git a/src/MOI_wrapper/indicator.jl b/src/MOI_wrapper/indicator.jl index 65030278..7db39681 100644 --- a/src/MOI_wrapper/indicator.jl +++ b/src/MOI_wrapper/indicator.jl @@ -10,11 +10,11 @@ function JuMP._build_indicator_constraint( S = typeof(constraint.set) F = typeof(JuMP.moi_function(constraint)) set = CS.Indicator{A,F,S}(constraint.set, 1 + length(constraint.func)) - if constraint.func isa Vector{VariableRef} - vov = JuMP.VariableRef[variable] + if constraint.func isa Vector{typeof(variable)} + vov = [variable] else - vov = JuMP.AffExpr[variable] + vov = typeof(1variable)[variable] end append!(vov, constraint.func) return JuMP.VectorConstraint(vov, set) -end \ No newline at end of file +end diff --git a/src/MOI_wrapper/reified.jl b/src/MOI_wrapper/reified.jl index 5b96858d..f4e021a4 100644 --- a/src/MOI_wrapper/reified.jl +++ b/src/MOI_wrapper/reified.jl @@ -45,7 +45,7 @@ end function JuMP.parse_constraint_head(_error::Function, ::Val{:(:=)}, lhs, rhs) variable, S = _reified_variable_set(_error, lhs) - if !JuMP.isexpr(rhs, :braces) || length(rhs.args) != 1 + if !Meta.isexpr(rhs, :braces) || length(rhs.args) != 1 _error("Invalid right-hand side `$(rhs)` of reified constraint. Expected constraint surrounded by `{` and `}`.") end rhs_con = rhs.args[1] diff --git a/src/MOI_wrapper/results.jl b/src/MOI_wrapper/results.jl index 84ab1e6b..83493c04 100644 --- a/src/MOI_wrapper/results.jl +++ b/src/MOI_wrapper/results.jl @@ -3,7 +3,7 @@ function MOI.get(model::Optimizer, ::MOI.TerminationStatus) end function MOI.get(model::Optimizer, ov::MOI.ObjectiveValue) - return model.inner.solutions[ov.result_index].incumbent + return float(model.inner.solutions[ov.result_index].incumbent) end function MOI.get(model::Optimizer, ::MOI.ObjectiveBound) diff --git a/src/constraints/element1Dconst.jl b/src/constraints/element1Dconst.jl index a9b9c459..6d1da733 100644 --- a/src/constraints/element1Dconst.jl +++ b/src/constraints/element1Dconst.jl @@ -149,8 +149,10 @@ function prune_constraint!( end elseif change_type == :remove_above for val in change_val+1:length(T) - T_val_shifted = T[val] - z.lower_bound + 1 - zSupp[T_val_shifted] > 0 && (zSupp[T_val_shifted] -= 1) + if z.lower_bound <= T[val] <= z.upper_bound + T_val_shifted = T[val] - z.lower_bound + 1 + zSupp[T_val_shifted] > 0 && (zSupp[T_val_shifted] -= 1) + end end elseif change_type == :remove_below for val in 1:min(change_val-1, length(T)) diff --git a/test/Project.toml b/test/Project.toml index 3bfdc17d..1cc541f2 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -18,4 +18,4 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] -ReferenceTests = "=0.9.0" +ReferenceTests = "0.10" diff --git a/test/graph_color.jl b/test/graph_color.jl index aa1491ec..f5f7adcc 100644 --- a/test/graph_color.jl +++ b/test/graph_color.jl @@ -762,7 +762,7 @@ @constraint(m, georgia != florida) # test strictly less than - @constraint(m, max_color .< states+1) + @constraint(m, max_color .< states .+ 1) @objective(m, Max, max_color) diff --git a/test/unit/constraints/indicator.jl b/test/unit/constraints/indicator.jl index d7a0d5ff..3dcf3483 100644 --- a/test/unit/constraints/indicator.jl +++ b/test/unit/constraints/indicator.jl @@ -62,7 +62,7 @@ for ind in constr_indices[2:3] @test sort(CS.values(com.search_space[ind])) == [-3, 1, 2, 3] end - @test sort(CS.values(com.search_space[1])) == [0, 1] + @test sort(CS.values(com.search_space[constr_indices[1]])) == [0, 1] # feasible but remove -3 @test CS.fix!(com, com.search_space[constr_indices[1]], 1) @test CS.prune_constraint!(com, constraint, constraint.fct, constraint.set) @@ -161,4 +161,4 @@ end constraint = com.constraints[1] # b is not active so no pruning should happen @test sort(CS.values.(m, x)) == -5:5 -end \ No newline at end of file +end