A short story about an osqp speedup

I have an optimization problem with parts of the objective function on the form (a*sum(v1) + b*sum(v2)+c*sum(v3) ...)^2

a,b,c are all constants. v1,v2,v3 represent some groupings of 100+ variables each.

I created an intermediary variable i1,i2,i3, for sum(v1),sum(v2),sum(v3) and adding linear constraints sum(v1) = i1, sum(v2) = i2 … and making my objective function be (a*i1 + b*i2+c*i3 ...)^2.

This massively reduce memory consumption since the resulting P matrix is far more sparse. Large cases previously gave me OOM, and for most other cases resulted in 30% shorter runtime.