Skip to content

Commit 8038482

Browse files
committed
Upddate _range_infeasibility to check only present constraints
1 parent 966a106 commit 8038482

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

src/range.jl

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,40 +37,39 @@ 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,
53+
range_consistent = true
54+
for (F, S) in MOI.get(
6755
optimizer.original_model,
68-
T,
69-
variables,
70-
lb_con,
71-
ub_con,
72-
MOI.GreaterThan{T},
56+
MOI.ListOfConstraintTypesPresent(),
7357
)
58+
if !_supports_range(F) || !_supports_range(S)
59+
continue
60+
end
61+
range_consistent &= _range_infeasibility!(
62+
optimizer,
63+
optimizer.original_model,
64+
T,
65+
variables,
66+
lb_con,
67+
ub_con,
68+
F,
69+
S,
70+
)
71+
end
72+
return range_consistent
7473
end
7574

7675
function _range_infeasibility!(
@@ -80,13 +79,11 @@ function _range_infeasibility!(
8079
variables::Dict{MOI.VariableIndex,Interval{T}},
8180
lb_con::Dict{MOI.VariableIndex,MOI.ConstraintIndex},
8281
ub_con::Dict{MOI.VariableIndex,MOI.ConstraintIndex},
82+
::Type{F},
8383
::Type{S},
84-
) where {T,S}
84+
) where {T,F,S}
8585
range_consistent = true
86-
for con in MOI.get(
87-
original_model,
88-
MOI.ListOfConstraintIndices{MOI.ScalarAffineFunction{T},S}(),
89-
)
86+
for con in MOI.get(original_model, MOI.ListOfConstraintIndices{F,S}())
9087
if !_in_time(optimizer)
9188
return range_consistent
9289
end

0 commit comments

Comments
 (0)