How to express this SOCP in cvx?


Hello, everyone, could you help me? just as the paper (“Robust twin support vector machine for pattern classification”) says, I want to solve this problem. Although no error, but the results seems errors. This is my code:
A = X_train(y_train == 1, :);
B = X_train(y_train ~= 1, :);
n = size(X_train, 1);
n1 = size(A, 1);
n2 = size(B, 1);
c1 = 100;

cvx_begin
variables beta1 beta2 gamma1 gamma2 zu1 zv1 zu2 zv2 lambda1(n1) alpha1(n2)
maximize(beta1 + beta2 + sum(alpha1))
subject to
% - linear equality constraints
beta1 + zu1 == 0.5
beta1 + zv1 == -0.5
beta2 + zu2 == 0.5
beta2 + zv2 == -0.5
sum(alpha1) - sum(lambda1) == 0
norm(lambda1’ * A - alpha1’ * B) <= sum(alpha1 - gamma1)
norm(lambda1) <= -gamma2
norm([gamma1; zv1]) <= zu1
norm([gamma2; zv2]) <= zu2
0 <= alpha1 <= c1;
cvx_end

I have no idea whether your inputs are correct.

But one thing I noticed is that unless r is a vector of ones, you are missing it in
norm(lambda1’ * A - alpha1’ * B) <= sum(alpha1 - gamma1).

I also have no idea whether gamma1 is supposed to be inside or outside the sum. That is for you to determine.

From a CVX perspective, this problem is extremely straightforward to enter. Getting it correct is a matter of getting the details correct, and very importantly, understanding the actual optimization problem specification, even though it might be ambiguous in the image you posted.

Hi, Mrak, Thank you for your kind reply. For the sake of simplification, I regard r as a vector of 1. I’m still stuck in how to solve this problem (fig:1). Similar to the paper(“Robust twin support vector machine for pattern classificatio”), I’m trying my best to solve the same optimization problem:

In my case (fig:2), where A and B are data matrix, e1,e2 are identical matrix, is or not this is a convex optimization? and how to solve in cvx?

These can be entered in CVX “as is”, and will be solved as SOCP. Getting it correct is a matter of making sure your indexing is correct, which is really more a standard MATLAB syntax than CVX-specific matter.

Thank you, sincerely. Perhaps, I got it. I need to transfer the objective function and the corresponding constrains into CVX-specific form rather than MATLAB syntax. I’m tring my best to do that… Thank you again :smiley:

hi, Mark, your comments have helped me a lot and the optimization problem (SOCP) have been solved by cvx. However, I found the speed seems too slow. Thus, I want to use sedumi instead cvx to solve SOCP. I have convert my SOCP to sedumi(At, bt, ct, K), and I want to know the difference between my form and that by cvx. In a words, is there any methods to display the At, bt, ct, K in cvx?

Run time in CVX is roughly divided into CVX modeling time, solver time and CVX post-processing time, the last of which is generally negligible. Your time savings from directly calling sedumi would be eliminating CVX modeling time, which is the time until the first output is written. if the excessive run time is in the solution phase (after first CVX output is written), you are unlikely to save much, if any, time, by directly calling sedumik.

Edit: See my next post.

You could use YALMIP, instead of CVX, and make use of its optimizer capability, which allows for repeated solution of the same problem with different input data, in a way which avoids most of the model setup time. it also allows you to export models into various formats, such as sedumi, as shown at export - YALMIP .

I am amending the middle paragraph of my previous reply as follows:

See

It’s also possible to write a Mosek task file if using Mosek as solver, but I don’t know that would be of benefit to you.

Thank you very much, I will try as you suggested.