Skip to content

Commit 6c2ca24

Browse files
authored
Update to use MOI.ConflictCount and MOI.ConstraintConflictStatus (#25)
1 parent 95e37cd commit 6c2ca24

File tree

4 files changed

+19
-26
lines changed

4 files changed

+19
-26
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ version = "0.1.1"
66
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
77

88
[compat]
9-
MathOptInterface = "1.42.0"
9+
MathOptInterface = "1.43.0"
1010
julia = "1.6"

src/MathOptIIS.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ include("bound.jl")
1212
include("range.jl")
1313
include("solver.jl")
1414

15+
@deprecate ConflictCount MOI.ConflictCount
16+
@deprecate ConstraintConflictStatus MOI.ConstraintConflictStatus
17+
1518
end # module MathOptIIS

src/iis.jl

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -200,30 +200,13 @@ function MOI.get(optimizer::Optimizer, ::MOI.ConflictStatus)
200200
return optimizer.status
201201
end
202202

203-
function MOI.get(
204-
optimizer::Optimizer,
205-
::MOI.ConstraintConflictStatus,
206-
con::MOI.ConstraintIndex,
207-
)
208-
return MOI.get(optimizer, ConstraintConflictStatus(1), con)
209-
end
210-
211-
# this should be moved to MOI
212-
struct ConflictCount <: MOI.AbstractModelAttribute end
213-
214-
function MOI.get(optimizer::Optimizer, ::ConflictCount)
203+
function MOI.get(optimizer::Optimizer, ::MOI.ConflictCount)
215204
return length(optimizer.results)
216205
end
217206

218-
# the MOI version must be generalized
219-
struct ConstraintConflictStatus <: MOI.AbstractModelAttribute
220-
conflict_index::Int
221-
ConstraintConflictStatus(conflict_index = 1) = new(conflict_index)
222-
end
223-
224207
function MOI.get(
225208
optimizer::Optimizer,
226-
attr::ConstraintConflictStatus,
209+
attr::MOI.ConstraintConflictStatus,
227210
con::MOI.ConstraintIndex,
228211
)
229212
if attr.conflict_index > length(optimizer.results)

test/runtests.jl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,28 @@ function test_bounds()
5252
MOI.ConstraintConflictStatus(),
5353
index(UpperBoundRef(y)),
5454
) == MOI.IN_CONFLICT
55-
@test MOI.get(solver, MOIIS.ConflictCount()) == 1
55+
@test MOI.get(solver, MOI.ConflictCount()) == 1
5656
@test MOI.get(
5757
solver,
58-
MOIIS.ConstraintConflictStatus(1),
58+
MOI.ConstraintConflictStatus(1),
5959
index(LowerBoundRef(y)),
6060
) == MOI.IN_CONFLICT
6161
@test MOI.get(
6262
solver,
63-
MOIIS.ConstraintConflictStatus(1),
63+
MOI.ConstraintConflictStatus(1),
6464
index(UpperBoundRef(y)),
6565
) == MOI.IN_CONFLICT
66-
@test MOI.get(solver, MOIIS.ConstraintConflictStatus(1), index(c)) ==
66+
@test MOI.get(solver, MOI.ConstraintConflictStatus(1), index(c)) ==
6767
MOI.NOT_IN_CONFLICT
6868
# the next two could be errors
6969
@test MOI.get(
7070
solver,
71-
MOIIS.ConstraintConflictStatus(2),
71+
MOI.ConstraintConflictStatus(2),
7272
index(LowerBoundRef(y)),
7373
) == MOI.NOT_IN_CONFLICT
7474
@test MOI.get(
7575
solver,
76-
MOIIS.ConstraintConflictStatus(2),
76+
MOI.ConstraintConflictStatus(2),
7777
index(UpperBoundRef(y)),
7878
) == MOI.NOT_IN_CONFLICT
7979
#
@@ -749,6 +749,13 @@ function test_iis_binary()
749749
return
750750
end
751751

752+
function test_deprecated()
753+
@test (@test_deprecated MOIIS.ConflictCount()) == MOI.ConflictCount()
754+
@test (@test_deprecated MOIIS.ConstraintConflictStatus(2)) ==
755+
MOI.ConstraintConflictStatus(2)
756+
return
757+
end
758+
752759
end # module
753760

754761
TestMathOptIIS.runtests()

0 commit comments

Comments
 (0)