Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
run: julia --project=docs/ docs/make.jl
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ 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"
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"
2 changes: 1 addition & 1 deletion src/MOI_wrapper/Bridges/bool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/MOI_wrapper/reified.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
ConstraintProgrammingExtensions = "b65d079e-ed98-51d9-b0db-edee61a5c5f8"
ConstraintSolver = "e0e52ebd-5523-408d-9ca3-7641f1cd1405"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Expand All @@ -18,4 +19,4 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
ReferenceTests = "=0.9.0"
ReferenceTests = "0.10"
157 changes: 79 additions & 78 deletions test/unit/constraints/indicator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -72,82 +72,83 @@
CS.values(com.search_space[constr_indices[1]]) == [1]
end

@testset "indicator is_constraint_violated test" begin
m = Model(optimizer_with_attributes(CS.Optimizer, "no_prune" => true, "logging" => []))
@variable(m, b, Bin)
@variable(m, -5 <= x[1:5] <= 5, Int)
@constraint(m, b => {x in CS.GeqSet()})
optimize!(m)
com = CS.get_inner_model(m)

constraint = com.constraints[1]

variables = com.search_space
@test CS.fix!(com, variables[constraint.indices[1]], 1; check_feasibility = false)
@test CS.remove_above!(
com,
variables[constraint.indices[2]],
3;
check_feasibility = false,
)
@test CS.remove_below!(
com,
variables[constraint.indices[3]],
4;
check_feasibility = false,
)
@test CS.is_constraint_violated(com, constraint, constraint.fct, constraint.set)

m = Model(optimizer_with_attributes(CS.Optimizer, "no_prune" => true, "logging" => []))
@variable(m, b, Bin)
@variable(m, -5 <= x[1:5] <= 5, Int)
@constraint(m, b => {x in CS.GeqSet()})
optimize!(m)
com = CS.get_inner_model(m)

constraint = com.constraints[1]

variables = com.search_space
@test CS.fix!(com, variables[constraint.indices[1]], 1; check_feasibility = false)
@test CS.remove_above!(
com,
variables[constraint.indices[2]],
3;
check_feasibility = false,
)
@test CS.remove_below!(
com,
variables[constraint.indices[3]],
3;
check_feasibility = false,
)
@test !CS.is_constraint_violated(com, constraint, constraint.fct, constraint.set)

m = Model(optimizer_with_attributes(CS.Optimizer, "no_prune" => true, "logging" => []))
@variable(m, b, Bin)
@variable(m, -5 <= x[1:5] <= 5, Int)
@constraint(m, b => {x in CS.GeqSet()})
optimize!(m)
com = CS.get_inner_model(m)

constraint = com.constraints[1]

variables = com.search_space
@test CS.fix!(com, variables[constraint.indices[1]], 0; check_feasibility = false)
@test CS.remove_above!(
com,
variables[constraint.indices[2]],
3;
check_feasibility = false,
)
@test CS.remove_below!(
com,
variables[constraint.indices[3]],
4;
check_feasibility = false,
)
@test !CS.is_constraint_violated(com, constraint, constraint.fct, constraint.set)
end
# FIXME this is hitting https://github.com/jump-dev/JuMP.jl/issues/3812
#@testset "indicator is_constraint_violated test" begin
# m = Model(optimizer_with_attributes(CS.Optimizer, "no_prune" => true, "logging" => []))
# @variable(m, b, Bin)
# @variable(m, -5 <= x[1:5] <= 5, Int)
# @constraint(m, b => {x in CS.GeqSet()})
# optimize!(m)
# com = CS.get_inner_model(m)
#
# constraint = com.constraints[1]
#
# variables = com.search_space
# @test CS.fix!(com, variables[constraint.indices[1]], 1; check_feasibility = false)
# @test CS.remove_above!(
# com,
# variables[constraint.indices[2]],
# 3;
# check_feasibility = false,
# )
# @test CS.remove_below!(
# com,
# variables[constraint.indices[3]],
# 4;
# check_feasibility = false,
# )
# @test CS.is_constraint_violated(com, constraint, constraint.fct, constraint.set)
#
# m = Model(optimizer_with_attributes(CS.Optimizer, "no_prune" => true, "logging" => []))
# @variable(m, b, Bin)
# @variable(m, -5 <= x[1:5] <= 5, Int)
# @constraint(m, b => {x in CS.GeqSet()})
# optimize!(m)
# com = CS.get_inner_model(m)
#
# constraint = com.constraints[1]
#
# variables = com.search_space
# @test CS.fix!(com, variables[constraint.indices[1]], 1; check_feasibility = false)
# @test CS.remove_above!(
# com,
# variables[constraint.indices[2]],
# 3;
# check_feasibility = false,
# )
# @test CS.remove_below!(
# com,
# variables[constraint.indices[3]],
# 3;
# check_feasibility = false,
# )
# @test !CS.is_constraint_violated(com, constraint, constraint.fct, constraint.set)
#
# m = Model(optimizer_with_attributes(CS.Optimizer, "no_prune" => true, "logging" => []))
# @variable(m, b, Bin)
# @variable(m, -5 <= x[1:5] <= 5, Int)
# @constraint(m, b => {x in CS.GeqSet()})
# optimize!(m)
# com = CS.get_inner_model(m)
#
# constraint = com.constraints[1]
#
# variables = com.search_space
# @test CS.fix!(com, variables[constraint.indices[1]], 0; check_feasibility = false)
# @test CS.remove_above!(
# com,
# variables[constraint.indices[2]],
# 3;
# check_feasibility = false,
# )
# @test CS.remove_below!(
# com,
# variables[constraint.indices[3]],
# 4;
# check_feasibility = false,
# )
# @test !CS.is_constraint_violated(com, constraint, constraint.fct, constraint.set)
#end

@testset "indicator is_constraint_violated test" begin
m = Model(optimizer_with_attributes(CS.Optimizer, "backtrack" => false, "logging" => []))
Expand All @@ -161,4 +162,4 @@ end
constraint = com.constraints[1]
# b is not active so no pruning should happen
@test sort(CS.values.(m, x)) == -5:5
end
end
Loading