how Python cvxopt solvers qp basically works

harumomo503 picture harumomo503 · Sep 12, 2015 · Viewed 10.5k times · Source

I want to use cvxopt solvers qp and compute Lagrange multiplier but I wonder how it works "exactly". I was trying to find more information but there is not much information about cvxopt out there. I was looking at this example problem and I am not sure what these variables signify and how they come up with a solution.

The example is like this:

enter image description here

can be solved by using

Q = 2*matrix([ [2, .5], [.5, 1] ])
p = matrix([1.0, 1.0])
G = matrix([[-1.0,0.0],[0.0,-1.0]])
h = matrix([0.0,0.0])
A = matrix([1.0, 1.0], (1,2))
b = matrix(1.0)
sol=solvers.qp(Q, p, G, h, A, b)
print(sol['x'])

Answer

Nikhil Bhatia picture Nikhil Bhatia · Oct 20, 2015

You should have a look at this:

Solving QP with CVXopt

For solving a quadratic programming problem, CVXopt accepts a set of matrices, generally mentioned as P,q,G,A, and h. You have to first convert your problem into the specific form accepted by CVXopt (mentioned in the link). The aim is to find an optimal solution, (in your case, Lagrange multipliers) which is the matrix 'x'.

The object in which you 'store' the solution has a number of properties, one of which is the matrix 'x', which you can print or use for further calculations.