@@ -2032,49 +2032,45 @@ _check_double_single_variable(::AbstractBridgeOptimizer, ::Any, ::Any) = nothing
20322032
20332033function MOI. add_constraint (
20342034 b:: AbstractBridgeOptimizer ,
2035- f:: MOI.AbstractFunction ,
2036- s:: MOI.AbstractSet ,
2037- )
2035+ f:: F ,
2036+ s:: S ,
2037+ ) where {F <: MOI.AbstractFunction ,S <: MOI.AbstractSet }
20382038 if Variable. has_bridges (Variable. bridges (b))
2039- if f isa MOI. VariableIndex
2039+ if F <: MOI.VariableIndex
20402040 if is_bridged (b, f)
2041- if MOI. is_valid (
2042- b,
2043- MOI. ConstraintIndex {MOI.VariableIndex,typeof(s)} (f. value),
2044- )
2041+ ci = MOI. ConstraintIndex {MOI.VariableIndex,S} (f. value)
2042+ if MOI. is_valid (b, ci)
20452043 # The other constraint could have been through a variable bridge.
2046- error (
2047- " Cannot add two `VariableIndex`-in-`$(typeof (s)) `" ,
2048- " on the same variable $(f) ." ,
2049- )
2044+ msg = " Cannot add two `VariableIndex`-in-`$S ` on the same variable $f ."
2045+ throw (MOI. AddConstraintNotAllowed {F,S} (msg))
20502046 end
20512047 BridgeType = Constraint. concrete_bridge_type (
20522048 constraint_scalar_functionize_bridge (b),
2053- typeof (f) ,
2054- typeof (s) ,
2049+ F ,
2050+ S ,
20552051 )
20562052 MOI. add_constraint (Variable. bridges (b), f, s)
20572053 return add_bridged_constraint (b, BridgeType, f, s)
20582054 end
2059- elseif f isa MOI. VectorOfVariables
2055+ elseif F <: MOI.VectorOfVariables
20602056 if any (vi -> is_bridged (b, vi), f. variables)
20612057 BridgeType = Constraint. concrete_bridge_type (
20622058 constraint_vector_functionize_bridge (b),
2063- typeof (f) ,
2064- typeof (s) ,
2059+ F ,
2060+ S ,
20652061 )
20662062 return add_bridged_constraint (b, BridgeType, f, s)
20672063 end
20682064 else
20692065 f, s = bridged_constraint_function (b, f, s)
20702066 end
20712067 end
2072- if is_bridged (b, typeof (f), typeof (s) )
2068+ if is_bridged (b, F, S )
20732069 _check_double_single_variable (b, f, s)
20742070 # We compute `BridgeType` first as `concrete_bridge_type` calls
20752071 # `bridge_type` which might throw an `UnsupportedConstraint` error in
20762072 # which case, we do not want any modification to have been done
2077- BridgeType = Constraint. concrete_bridge_type (b, typeof (f), typeof (s) )
2073+ BridgeType = Constraint. concrete_bridge_type (b, F, S )
20782074 # `add_constraint` might throw an `UnsupportedConstraint` but no
20792075 # modification has been done in the previous line
20802076 return add_bridged_constraint (b, BridgeType, f, s)
0 commit comments