@@ -138,7 +138,11 @@ function MOI.modify(model::MOI.ModelLike, relax::PenaltyRelaxation{T}) where {T}
138
138
end
139
139
map = Dict {MOI.ConstraintIndex,MOI.ScalarAffineFunction{T}} ()
140
140
for (F, S) in MOI. get (model, MOI. ListOfConstraintTypesPresent ())
141
- _modify_penalty_relaxation (map, model, relax, F, S)
141
+ if MOI. supports (model, relax, MOI. ConstraintIndex{F,S})
142
+ _modify_penalty_relaxation (map, model, relax, F, S)
143
+ else
144
+ @warn (" Skipping PenaltyRelaxation of constraints of type $F -in-$S " )
145
+ end
142
146
end
143
147
return map
144
148
end
@@ -161,20 +165,20 @@ function _modify_penalty_relaxation(
161
165
return map
162
166
end
163
167
164
- function MOI. modify (
168
+ function MOI. supports (
169
+ :: MOI.ModelLike ,
170
+ :: PenaltyRelaxation{T} ,
171
+ :: Type{<:MOI.ConstraintIndex{F,<:MOI.AbstractScalarSet}} ,
172
+ ) where {T,F<: Union{MOI.ScalarAffineFunction{T},MOI.ScalarQuadraticFunction{T}} }
173
+ return true
174
+ end
175
+
176
+ function MOI. supports (
165
177
:: MOI.ModelLike ,
166
- ci:: MOI.ConstraintIndex ,
167
178
:: PenaltyRelaxation ,
179
+ :: Type{<:MOI.ConstraintIndex} ,
168
180
)
169
- # We use this fallback to avoid ambiguity errors that would occur if we
170
- # added {F,S} directly to the argument.
171
- _eltype (:: MOI.ConstraintIndex{F,S} ) where {F,S} = F, S
172
- F, S = _eltype (ci)
173
- @warn (
174
- " Skipping PenaltyRelaxation of constraints of type $F -in-$S " ,
175
- maxlog = 1 ,
176
- )
177
- return
181
+ return false
178
182
end
179
183
180
184
function MOI. modify (
0 commit comments