Skip to content

Commit 5c5b4ce

Browse files
authored
Update _range_infeasibility to check only present constraints (#29)
1 parent 966a106 commit 5c5b4ce

File tree

1 file changed

+27
-32
lines changed

1 file changed

+27
-32
lines changed

src/range.jl

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,40 +37,37 @@ end
3737

3838
# Back to functions written for MathOptIIS.jl
3939

40+
_supports_range(::Type{MOI.ScalarAffineFunction{T}}) where {T} = true
41+
_supports_range(::Type{MOI.EqualTo{T}}) where {T} = true
42+
_supports_range(::Type{MOI.GreaterThan{T}}) where {T} = true
43+
_supports_range(::Type{MOI.LessThan{T}}) where {T} = true
44+
_supports_range(::Type{T}) where {T} = false
45+
4046
function _range_infeasibility!(
4147
optimizer::Optimizer,
4248
::Type{T},
4349
variables::Dict{MOI.VariableIndex,Interval{T}},
4450
lb_con::Dict{MOI.VariableIndex,MOI.ConstraintIndex},
4551
ub_con::Dict{MOI.VariableIndex,MOI.ConstraintIndex},
4652
) where {T}
47-
range_consistent = _range_infeasibility!(
48-
optimizer,
49-
optimizer.original_model,
50-
T,
51-
variables,
52-
lb_con,
53-
ub_con,
54-
MOI.EqualTo{T},
55-
)
56-
range_consistent &= _range_infeasibility!(
57-
optimizer,
58-
optimizer.original_model,
59-
T,
60-
variables,
61-
lb_con,
62-
ub_con,
63-
MOI.LessThan{T},
64-
)
65-
return _range_infeasibility!(
66-
optimizer,
67-
optimizer.original_model,
68-
T,
69-
variables,
70-
lb_con,
71-
ub_con,
72-
MOI.GreaterThan{T},
73-
)
53+
range_consistent = true
54+
for (F, S) in
55+
MOI.get(optimizer.original_model, MOI.ListOfConstraintTypesPresent())
56+
if !_supports_range(F) || !_supports_range(S)
57+
continue
58+
end
59+
range_consistent &= _range_infeasibility!(
60+
optimizer,
61+
optimizer.original_model,
62+
T,
63+
variables,
64+
lb_con,
65+
ub_con,
66+
F,
67+
S,
68+
)
69+
end
70+
return range_consistent
7471
end
7572

7673
function _range_infeasibility!(
@@ -80,13 +77,11 @@ function _range_infeasibility!(
8077
variables::Dict{MOI.VariableIndex,Interval{T}},
8178
lb_con::Dict{MOI.VariableIndex,MOI.ConstraintIndex},
8279
ub_con::Dict{MOI.VariableIndex,MOI.ConstraintIndex},
80+
::Type{F},
8381
::Type{S},
84-
) where {T,S}
82+
) where {T,F,S}
8583
range_consistent = true
86-
for con in MOI.get(
87-
original_model,
88-
MOI.ListOfConstraintIndices{MOI.ScalarAffineFunction{T},S}(),
89-
)
84+
for con in MOI.get(original_model, MOI.ListOfConstraintIndices{F,S}())
9085
if !_in_time(optimizer)
9186
return range_consistent
9287
end

0 commit comments

Comments
 (0)