1

If I understand correctly, cvxpy converts our high-level problem description to the standard canonical form before it is sent to a solver.

By the standard form I mean the form that can be used for the descent algorithms, so, for instance, it would convert all the absolute values in the objective to be a difference of two positive numbers with some new constraints, etc.

Wondering if its possible to see what the reduction looked like for a problem I specify in cvxpy? For instance, lets say I have the following problem:

import numpy as np
import cvxpy as cp

x = cp.Variable(2)
L = np.asarray([[1,2],[2,3]])
P = L.T @ L

constraints = []
constraints.append(x >= [-10, -10])
constraints.append(x <= [10, 10])

obj = cp.Minimize(cp.quad_form(x, P) - [1, 2] * x)
prob = cp.Problem(obj, constraints)
prob.solve(), prob.solver_stats.solver_name
(-0.24999999999999453, 'OSQP')

So, I would like to see the actual arguments (P, q, A, l, u) being sent to the OSQP solver https://github.com/oxfordcontrol/osqp-python/blob/master/module/interface.py#L278

Any help is greatly appreciated!

t-arsin
  • 13
  • 2

1 Answers1

2

From looking at the documentation, it seems you can do this using the command get_problem_data as follows:

data, chain, inverse_data = prob.get_problem_data(prob.solver_stats.solver_name)

I have not tried it, and it says it output depends on the particular solver and the solver chain, but it may help you!

linx
  • 78
  • 1
  • 7