1
- function operate_coefficient (f, T:: Type , term:: MOI.ScalarAffineTerm )
2
- MOI. ScalarAffineTerm (f (term. coefficient), term. variable_index)
3
- end
4
- function operate_coefficient (f, T:: Type , term:: MOI.VectorAffineTerm )
5
- return MOI. VectorAffineTerm (term. output_index, operate_coefficient (f, T, term. scalar_term))
6
- end
7
- function operate_coefficients (f, T:: Type , func:: MOI.VectorAffineFunction )
8
- return MOI. VectorAffineFunction (
9
- [operate_coefficient (f, T, term) for term in func. terms],
10
- map (f, func. constants)
11
- )
12
- end
13
-
14
- similar_type (:: Type{<:MOI.VectorAffineFunction} , T:: Type ) = MOI. VectorAffineFunction{T}
15
-
16
1
struct SplitZeroBridge{T, F<: MOI.Utilities.TypedLike{T} , G<: MOI.Utilities.TypedLike{Complex{T}} } <: MOI.Bridges.Constraint.AbstractBridge
17
2
dimension:: Int
18
3
constraint:: MOI.ConstraintIndex{F, MOI.Zeros}
@@ -27,8 +12,8 @@ function MOI.Bridges.Constraint.bridge_constraint(
27
12
f:: G ,
28
13
set:: MOI.Zeros
29
14
) where {T, F, G}
30
- real_part = operate_coefficients ( real, T, f)
31
- imag_part = operate_coefficients (imag, T, f)
15
+ real_part = real ( f)
16
+ imag_part = MOI . Utilities . operate (imag, T, f)
32
17
real_indices = _nonzero_indices (real_part)
33
18
imag_indices = _nonzero_indices (imag_part)
34
19
func = MOIU. operate (
@@ -40,6 +25,7 @@ function MOI.Bridges.Constraint.bridge_constraint(
40
25
return SplitZeroBridge {T, F, G} (MOI. dimension (set), constraint, real_indices, imag_indices)
41
26
end
42
27
28
+ # We don't support `MOI.VectorOfVariables` as it would be a self-loop in the bridge graph
43
29
function MOI. supports_constraint (
44
30
:: Type{SplitZeroBridge{T}} , :: Type{<:MOI.Utilities.TypedLike{Complex{T}}} ,
45
31
:: Type{MOI.Zeros} ) where T
52
38
function MOI. Bridges. Constraint. concrete_bridge_type (
53
39
:: Type{<:SplitZeroBridge{T}} , G:: Type{<:MOI.Utilities.TypedLike} ,
54
40
:: Type{MOI.Zeros} ) where T
55
- return SplitZeroBridge{T, similar_type (G, T), G}
41
+ F = MA. promote_operation (imag, G)
42
+ return SplitZeroBridge{T, F, G}
56
43
end
57
44
58
45
# Attributes, Bridge acting as a model
0 commit comments