CVXOPT sparse matrix data copy is a bottleneck for dualizing large problems.
Profiling the dualization of a large SDP, I noticed that ca. 75% of time is spent on the copy operation A[:]
inside left_kronecker_I
:
if reshape:
A = A if preT else A[:] # Copy if not already fresh.
A.size = reshape
This is called by BiaffineExpression.__mul__
:
# Use identity vec(AB) = (I ⊗ A)vec(B).
factor = left_kronecker_I(lcoef, q, reshape=(m, n))
Which in turn is called in Dualization.forward
:
# Extend the dual's linear equalities for each primal variable.
for var, coef in fx._linear_coefs.items():
dual_equality_terms[var] += coef.T*dual_var.vec