CVXOPT quadratic programming interface

557 views Asked by At

The provided QP solver for CVXOPT solves problems of the form ( see http://cvxopt.org/userguide/coneprog.html#quadratic-programming ):

Minimize 
           (1/2)*x.t*P*x + q.T*x
Subject to
           G*x <= h
           A*x  = b

This works fine, but it gets a bit awkward when wanting to solve a problem constraint by an inequality on two sides:

Minimize 
           (1/2)*x.t*P*x + q.T*x
Subject to
           G1*x <= h1
           G2*x >= h2
            A*x  = b

I can redefine the second problem as the first one, by doubling the number of dimensions and by requiring the new_x to be the old_x stacked on top of itself:

new_x = [old_x]
        [old_x]

I think I can enforce the above condition by finding an appropriate form for A. I can then encode both the h1 and h2 inequalities into the new_G * new_x <= new_h by setting new_h to be h1 stacked on h2 and new_G to be a diagonal matrix with n consecutive 1s followed by n consecutive -1s on the diagonal.

Anyway, the above is very clumsy, it's doubling the dimensionality of my problem and it might not even work.

Is there a nicer way of expressing the second problem in CVXOPT?

1

There are 1 answers

0
nampi On
Minimize 
           (1/2)*x.T*P*x + q.T*x
Subject to
           new_G * x <= new_h
               A * x  = b

where

           new_G = [G1;-G2],
           new_h = [h1;-h2].

          (G1 - matrix m1*n, G2 - matrix m2*n, new_G - matrix (m1 + m2)*n) 

new_G = numpy.concatenate( ( G1, -G2 ), axis = 0 )
new_h = numpy.concatenate( ( h1, -h2 ), axis = 1 )

`