4
$\begingroup$

I would like to solve the support vector regression problem.

The formula for the optimization is the following:

$$a_1^*, a_2^* = \max\sum_{i=1}^{n} (a_{1i}-a_{2i})y_{i} - eta\sum_{i=1}^{n}(a_{1i}+a_{2i}) - 1/2\sum_{j=1}^{n}\sum_{i=1}^{n}(a_{1j}-a_{2j})(a_{1i}-a_{2i})〈x_i,x_i〉$$

with $〈x_i,x_i〉$ being the dot product of $x_i$

and the constrains: $0\leq a_{1j}, a_{2j}\leq C$ and $\sum_{i=1}^{n}(a_{1i}+a_{2i})=0$

How can I solve this problem using a quadratic programming solver? I would use cvxopt.solvers.qp for this. But the solver demands the following form as input.

$x^* = \min$ $1/2x^TPx+q^Tx$ subject to $Gx \leq h$ and $Ax=b$

Is there a way to reformulate the formula, which is dependent by two variable vectors instead of one to that form?

Thank you in advance!

$\endgroup$
2
$\begingroup$

If you use CVXOPT directly, I believe you will have to concatenate all your variables into a single vector, and then write the objective function and constraints in terms of elements of that vector.

However, it should be easier and less error prone to use CVXPY, which is a higher level optimization modeling interface than CVXOPT. CVXPY will let you declare as many scalar, vector, or matrix variables as you want (presumably, vector for your Quadratic Programming problem) and enter the optimization problem in a fairly natural mathematical way, in terms of the variables you declared. CVXPY will do the dirty work to transform what you entered into a form suitable for the solver. CVXOPT solvers are among many solver choices within CVXPY.

$\endgroup$
  • $\begingroup$ Thank you! I didn't know that CVXPY allows a more flexible input form. I tried it and it works well. $\endgroup$ – laurenz Jun 10 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.