@@ -51,10 +51,11 @@ function MOIB.Variable.bridge_constrained_variable(
51
51
model:: MOI.ModelLike ,
52
52
set:: COI.HermitianPositiveSemidefiniteConeTriangle ,
53
53
) where {T}
54
-
55
54
n = set. side_dimension
56
- variables, psd_constraint =
57
- MOI. add_constrained_variables (model, MOI. PositiveSemidefiniteConeTriangle (2 n))
55
+ variables, psd_constraint = MOI. add_constrained_variables (
56
+ model,
57
+ MOI. PositiveSemidefiniteConeTriangle (2 n),
58
+ )
58
59
59
60
k11 = 0
60
61
k12 = MOI. dimension (MOI. PositiveSemidefiniteConeTriangle (n))
@@ -72,9 +73,9 @@ function MOIB.Variable.bridge_constrained_variable(
72
73
con_11_22 = EQ{T}[]
73
74
con12diag = EQ{T}[]
74
75
con_12_21 = EQ{T}[]
75
- for j = 1 : n
76
+ for j in 1 : n
76
77
k22 += n
77
- for i = 1 : j
78
+ for i in 1 : j
78
79
k11 += 1
79
80
k12 += 1
80
81
k22 += 1
@@ -124,23 +125,33 @@ function MOIB.Variable.supports_constrained_variable(
124
125
)
125
126
return true
126
127
end
127
- function MOIB. added_constrained_variable_types (:: Type{<:HermitianToSymmetricPSDBridge} )
128
+ function MOIB. added_constrained_variable_types (
129
+ :: Type{<:HermitianToSymmetricPSDBridge} ,
130
+ )
128
131
return [(MOI. PositiveSemidefiniteConeTriangle,)]
129
132
end
130
- function MOIB. added_constraint_types (:: Type{HermitianToSymmetricPSDBridge{T}} ) where {T}
133
+ function MOIB. added_constraint_types (
134
+ :: Type{HermitianToSymmetricPSDBridge{T}} ,
135
+ ) where {T}
131
136
return [(MOI. ScalarAffineFunction{T}, MOI. EqualTo{T})]
132
137
end
133
138
134
139
# Attributes, Bridge acting as a model
135
140
function MOI. get (bridge:: HermitianToSymmetricPSDBridge , :: MOI.NumberOfVariables )
136
141
return length (bridge. variables)
137
142
end
138
- function MOI. get (bridge:: HermitianToSymmetricPSDBridge , :: MOI.ListOfVariableIndices )
143
+ function MOI. get (
144
+ bridge:: HermitianToSymmetricPSDBridge ,
145
+ :: MOI.ListOfVariableIndices ,
146
+ )
139
147
return bridge. variables
140
148
end
141
149
function MOI. get (
142
150
bridge:: HermitianToSymmetricPSDBridge ,
143
- :: MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.PositiveSemidefiniteConeTriangle} ,
151
+ :: MOI.NumberOfConstraints {
152
+ MOI. VectorOfVariables,
153
+ MOI. PositiveSemidefiniteConeTriangle,
154
+ },
144
155
)
145
156
return 1
146
157
end
@@ -157,7 +168,9 @@ function MOI.get(
157
168
bridge:: HermitianToSymmetricPSDBridge{T} ,
158
169
:: MOI.NumberOfConstraints{MOI.ScalarAffineFunction{T},MOI.EqualTo{T}} ,
159
170
) where {T}
160
- return length (bridge. con_11_22) + length (bridge. con12diag) + length (bridge. con_12_21)
171
+ return length (bridge. con_11_22) +
172
+ length (bridge. con12diag) +
173
+ length (bridge. con_12_21)
161
174
end
162
175
function MOI. get (
163
176
bridge:: HermitianToSymmetricPSDBridge{T} ,
@@ -177,7 +190,7 @@ function MOI.delete(model::MOI.ModelLike, bridge::HermitianToSymmetricPSDBridge)
177
190
for ci in bridge. con_12_21
178
191
MOI. delete (model, ci)
179
192
end
180
- MOI. delete (model, bridge. variables)
193
+ return MOI. delete (model, bridge. variables)
181
194
end
182
195
183
196
# Attributes, Bridge acting as a constraint
@@ -187,7 +200,9 @@ function MOI.get(
187
200
:: MOI.ConstraintSet ,
188
201
bridge:: HermitianToSymmetricPSDBridge ,
189
202
)
190
- return COI. HermitianPositiveSemidefiniteConeTriangle (length (bridge. con12diag))
203
+ return COI. HermitianPositiveSemidefiniteConeTriangle (
204
+ length (bridge. con12diag),
205
+ )
191
206
end
192
207
193
208
function _matrix_indices (k)
@@ -212,7 +227,10 @@ function _variable_map(idx::MOIB.IndexInVector, n)
212
227
return idx. value
213
228
else
214
229
i, j = _matrix_indices (idx. value - N)
215
- return N + j * n + MOI. dimension (MOI. PositiveSemidefiniteConeTriangle (j)) + i
230
+ return N +
231
+ j * n +
232
+ MOI. dimension (MOI. PositiveSemidefiniteConeTriangle (j)) +
233
+ i
216
234
end
217
235
end
218
236
function _variable (bridge:: HermitianToSymmetricPSDBridge , i:: MOIB.IndexInVector )
@@ -227,7 +245,7 @@ function MOI.get(
227
245
values = MOI. get (model, attr, bridge. psd_constraint)
228
246
M = MOI. dimension (MOI. get (model, MOI. ConstraintSet (), bridge))
229
247
n = length (bridge. con12diag)
230
- return [values[_variable_map (MOIB. IndexInVector (i), n)] for i = 1 : M]
248
+ return [values[_variable_map (MOIB. IndexInVector (i), n)] for i in 1 : M]
231
249
end
232
250
233
251
# See docstring of bridge for why we ignore the dual of the constraints
@@ -247,10 +265,10 @@ function MOI.get(
247
265
k21 = MOI. dimension (MOI. PositiveSemidefiniteConeTriangle (2 n)) + 1
248
266
k22 = N
249
267
k = 0
250
- for j = 1 : n
268
+ for j in 1 : n
251
269
k21 -= n + 1 - j
252
270
k22 += n
253
- for i = 1 : j
271
+ for i in 1 : j
254
272
k11 += 1
255
273
k12 += 1
256
274
k21 -= 1
@@ -275,7 +293,7 @@ function MOI.get(
275
293
bridge:: HermitianToSymmetricPSDBridge{T} ,
276
294
i:: MOIB.IndexInVector ,
277
295
) where {T}
278
- value = MOI. get (model, attr, _variable (bridge, i))
296
+ return value = MOI. get (model, attr, _variable (bridge, i))
279
297
end
280
298
281
299
function MOIB. bridged_function (
0 commit comments