Using Parameters in solving the problem

36 views
Skip to first unread message

Sandeep Parameshwara

unread,
Jun 8, 2021, 5:57:31 AM6/8/21
to cvxpy
Hello members,

I am currently solving an optimization problem in which the cost terms include many arithmetic operations on  NumPy arrays. I solve this optimization problem repeatedly in the loop by setting up the problem again and again. I guess it's possible to speed up the solve time by making use of the parameters. The structure of the problem remains the same over time but only some quantities change in their values. Currently, I am using many NumPy operations such as dot product and Kronecker product. These terms are used inside cvxpy atomic functions such as quad_form. Now, I have few questions:
  1.  Is it possible to improve my solve time as I expect above by making use of the parameters?
  2. What operations are allowed on these parameters? For example, if I am using   cost = cp.quad_form(np.dot(A,x0+ S@u - reference, Q)
where A is a matrix, x0 is a vector, S is a matrix, u is a vector, reference is a vector, Q is a matrix of appropriate dimensions
How can I rewrite this if I make A,x0, S, reference, and Q as parameters so they still satisfy DCP? here, 'u' is the only cvxpy variable.

Thanks in advance
Sandeep

Steven Diamond

unread,
Jun 9, 2021, 1:53:12 PM6/9/21
to cvxpy
Add a variable v and the constraint v == Ax0 + S@u - reference
Then cost = cp.sum_squares(Q_half @ v)

The parameters are Ax0, S, referene, and Q_half.
Ax0 should be populated with np.dot(A, x0) and Q_half is scipy.linalg.sqrtm(Q).

Reply all
Reply to author
Forward
0 new messages