Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ version = "0.1.1"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"

[compat]
MathOptInterface = "1.42.0"
MathOptInterface = "1.43.0"
julia = "1.6"
3 changes: 3 additions & 0 deletions src/MathOptIIS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ include("bound.jl")
include("range.jl")
include("solver.jl")

@deprecate ConflictCount MOI.ConflictCount
@deprecate ConstraintConflictStatus MOI.ConstraintConflictStatus

end # module MathOptIIS
21 changes: 2 additions & 19 deletions src/iis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,30 +200,13 @@ function MOI.get(optimizer::Optimizer, ::MOI.ConflictStatus)
return optimizer.status
end

function MOI.get(
optimizer::Optimizer,
::MOI.ConstraintConflictStatus,
con::MOI.ConstraintIndex,
)
return MOI.get(optimizer, ConstraintConflictStatus(1), con)
end

# this should be moved to MOI
struct ConflictCount <: MOI.AbstractModelAttribute end

function MOI.get(optimizer::Optimizer, ::ConflictCount)
function MOI.get(optimizer::Optimizer, ::MOI.ConflictCount)
return length(optimizer.results)
end

# the MOI version must be generalized
struct ConstraintConflictStatus <: MOI.AbstractModelAttribute
conflict_index::Int
ConstraintConflictStatus(conflict_index = 1) = new(conflict_index)
end

function MOI.get(
optimizer::Optimizer,
attr::ConstraintConflictStatus,
attr::MOI.ConstraintConflictStatus,
con::MOI.ConstraintIndex,
)
if attr.conflict_index > length(optimizer.results)
Expand Down
19 changes: 13 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,28 @@ function test_bounds()
MOI.ConstraintConflictStatus(),
index(UpperBoundRef(y)),
) == MOI.IN_CONFLICT
@test MOI.get(solver, MOIIS.ConflictCount()) == 1
@test MOI.get(solver, MOI.ConflictCount()) == 1
@test MOI.get(
solver,
MOIIS.ConstraintConflictStatus(1),
MOI.ConstraintConflictStatus(1),
index(LowerBoundRef(y)),
) == MOI.IN_CONFLICT
@test MOI.get(
solver,
MOIIS.ConstraintConflictStatus(1),
MOI.ConstraintConflictStatus(1),
index(UpperBoundRef(y)),
) == MOI.IN_CONFLICT
@test MOI.get(solver, MOIIS.ConstraintConflictStatus(1), index(c)) ==
@test MOI.get(solver, MOI.ConstraintConflictStatus(1), index(c)) ==
MOI.NOT_IN_CONFLICT
# the next two could be errors
@test MOI.get(
solver,
MOIIS.ConstraintConflictStatus(2),
MOI.ConstraintConflictStatus(2),
index(LowerBoundRef(y)),
) == MOI.NOT_IN_CONFLICT
@test MOI.get(
solver,
MOIIS.ConstraintConflictStatus(2),
MOI.ConstraintConflictStatus(2),
index(UpperBoundRef(y)),
) == MOI.NOT_IN_CONFLICT
#
Expand Down Expand Up @@ -749,6 +749,13 @@ function test_iis_binary()
return
end

function test_deprecated()
@test (@test_deprecated MOIIS.ConflictCount()) == MOI.ConflictCount()
@test (@test_deprecated MOIIS.ConstraintConflictStatus(2)) ==
MOI.ConstraintConflictStatus(2)
return
end

end # module

TestMathOptIIS.runtests()
Loading