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

Update to JuMP and MOI v1 #291

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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/ConstraintSolver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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
8 changes: 4 additions & 4 deletions src/MOI_wrapper/indicator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
end
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
2 changes: 1 addition & 1 deletion src/MOI_wrapper/results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions src/constraints/element1Dconst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
ReferenceTests = "=0.9.0"
ReferenceTests = "0.10"
2 changes: 1 addition & 1 deletion test/graph_color.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 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 Down Expand Up @@ -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
end
Loading