Skip to content

Commit 79eae7d

Browse files
committed
Patch to sdp_utils to allow for Mosek 11 when using the (default) solve_dual=True keyword argument.
1 parent 78fcc4c commit 79eae7d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

inflation/sdp/sdp_utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,20 +302,22 @@ def constraint_dicts_to_sparse(constraints: List[dict]) -> (coo_array, coo_array
302302
I = M.variable("I",
303303
len(var_inequalities),
304304
Domain.greaterThan(0))
305+
I_reshaped = I.reshape(I.getShape()[0], 1)
305306
# It seems MOSEK Fusion API does not allow to pick index i
306307
# of an expression (A^T I)_i, so we do it manually row by row.
307308
AtI = [] # \sum_j I_j A_ji as i-th entry of AtI
308309
for var in variables:
309310
slice_ = coo_getcol(A, var2index[var])
310311
sparse_slice = scipy_to_mosek(slice_)
311-
AtI.append(Expr.dot(sparse_slice, I))
312+
AtI.append(Expr.dot(sparse_slice, I_reshaped))
312313
if var_equalities:
313314
E = M.variable("E", len(var_equalities), Domain.unbounded())
315+
E_reshaped = E.reshape(E.getShape()[0], 1)
314316
CtI = [] # \sum_j E_j C_ji as i-th entry of CtI
315317
for var in variables:
316318
slice_ = coo_getcol(C, var2index[var])
317319
sparse_slice = scipy_to_mosek(slice_)
318-
CtI.append(Expr.dot(sparse_slice, E))
320+
CtI.append(Expr.dot(sparse_slice, E_reshaped))
319321

320322
# Define and set objective function
321323
# c0 + Tr Z F0 + I·b + E·d
@@ -328,11 +330,11 @@ def constraint_dicts_to_sparse(constraints: List[dict]) -> (coo_array, coo_array
328330
del F0_mosek
329331
if var_inequalities:
330332
b_mosek = scipy_to_mosek(b)
331-
obj_mosek = Expr.add(obj_mosek, Expr.dot(I, b_mosek))
333+
obj_mosek = Expr.add(obj_mosek, Expr.dot(b_mosek, I_reshaped))
332334
del b_mosek
333335
if var_equalities:
334336
d_mosek = scipy_to_mosek(d)
335-
obj_mosek = Expr.add(obj_mosek, Expr.dot(E, d_mosek))
337+
obj_mosek = Expr.add(obj_mosek, Expr.dot(d_mosek, E_reshaped))
336338
del d_mosek
337339

338340
M.objective(ObjectiveSense.Minimize, obj_mosek)

0 commit comments

Comments
 (0)