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
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
MathOptAnalyzerJuMPExt = "JuMP"

[compat]
Dualization = "0.6.0"
JuMP = "1.24.0"
MathOptIIS = "0.1.1"
MathOptInterface = "1.37.0"
Dualization = "0.7"
JuMP = "1.24"
MathOptIIS = "0.2"
MathOptInterface = "1.37"
julia = "1.10"
2 changes: 1 addition & 1 deletion src/Infeasibility/Infeasibility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module Infeasibility

import MathOptAnalyzer
import MathOptIIS as MOIIS
import MathOptIIS
import MathOptInterface as MOI

include("structs.jl")
Expand Down
53 changes: 24 additions & 29 deletions src/Infeasibility/analyze.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.

function _add_result(out::Data, model, iis, meta::MOIIS.BoundsData)
function _add_result(
out::Data,
model,
iis,
meta::MathOptIIS.Metadata{T,Nothing},
) where {T}
@assert length(iis.constraints) == 2
err = InfeasibleBounds{Float64}(
err = InfeasibleBounds{T}(
MOI.get(model, MOI.ConstraintFunction(), iis.constraints[1]),
meta.lower_bound,
meta.upper_bound,
Expand All @@ -14,9 +19,14 @@ function _add_result(out::Data, model, iis, meta::MOIIS.BoundsData)
return
end

function _add_result(out::Data, model, iis, meta::MOIIS.IntegralityData)
function _add_result(
out::Data,
model,
iis,
meta::MathOptIIS.Metadata{T,S},
) where {T,S<:Union{MOI.Integer,MOI.ZeroOne}}
@assert length(iis.constraints) >= 2
err = InfeasibleIntegrality{Float64}(
err = InfeasibleIntegrality{T}(
MOI.get(model, MOI.ConstraintFunction(), iis.constraints[1]),
meta.lower_bound,
meta.upper_bound,
Expand All @@ -26,13 +36,18 @@ function _add_result(out::Data, model, iis, meta::MOIIS.IntegralityData)
return
end

function _add_result(out::Data, model, iis, meta::MOIIS.RangeData)
function _add_result(
out::Data,
model,
iis,
meta::MathOptIIS.Metadata{T,S},
) where {T,S<:MOI.AbstractSet}
@assert length(iis.constraints) >= 1
for con in iis.constraints
if con isa MOI.ConstraintIndex{MOI.VariableIndex}
continue
end
err = InfeasibleConstraintRange{Float64}(
err = InfeasibleConstraintRange{T}(
con,
meta.lower_bound,
meta.upper_bound,
Expand All @@ -49,35 +64,15 @@ function _add_result(out::Data, model, iis, meta)
return
end

function _instantiate_with_modify(optimizer, ::Type{T}) where {T}
model = MOI.instantiate(optimizer)
if !MOI.supports_incremental_interface(model)
# Don't use `default_cache` for the cache because, for example, SCS's
# default cache doesn't support modifying coefficients of the constraint
# matrix. JuMP uses the default cache with SCS because it has an outer
# layer of caching; we don't have that here, so we can't use the
# default.
#
# We could revert to using the default cache if we fix this in MOI.
cache = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{T}())
model = MOI.Utilities.CachingOptimizer(cache, model)
end
return MOI.Bridges.full_bridge_optimizer(model, T)
end

function MathOptAnalyzer.analyze(
::Analyzer,
model::MOI.ModelLike;
optimizer = nothing,
)
solver = MOIIS.Optimizer()
MOI.set(solver, MOIIS.InfeasibleModel(), model)
solver = MathOptIIS.Optimizer()
MOI.set(solver, MathOptIIS.InfeasibleModel(), model)
if optimizer !== nothing
MOI.set(
solver,
MOIIS.InnerOptimizer(),
() -> _instantiate_with_modify(optimizer, Float64),
)
MOI.set(solver, MathOptIIS.InnerOptimizer(), optimizer)
end
MOI.compute_conflict!(solver)
out = Data()
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
HiGHS = "1"
JuMP = "1"
MathOptInterface = "1"
SCS = "1"
SCS = "2"
4 changes: 2 additions & 2 deletions test/test_Infeasibility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function test_bounds()
data =
MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model)
list = MathOptAnalyzer.list_of_issue_types(data)
@test length(list) == 1
@test 1 <= length(list) <= 2
ret = MathOptAnalyzer.list_of_issues(data, list[1])
@test length(ret) == 1
@test ret[] == MathOptAnalyzer.Infeasibility.InfeasibleBounds{Float64}(
Expand Down Expand Up @@ -81,7 +81,7 @@ function test_integrality()
data =
MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model)
list = MathOptAnalyzer.list_of_issue_types(data)
@test length(list) == 1
@test 1 <= length(list) <= 2
ret = MathOptAnalyzer.list_of_issues(data, list[1])
@test length(ret) == 1
@test ret[] == MathOptAnalyzer.Infeasibility.InfeasibleIntegrality{Float64}(
Expand Down
Loading