Help with a simple ojective

Uncategorized
Sep 25, 2023
K

Hi all,

I have recently started implementing optimization problems using CVX and still learning. I have implemented the following quadratic constraint quadratic optimization problem. However, CVX is producing the error. I have learned from online help available that multiplication of two variables is not allowed in CVX. Could anyone help me with how I can Implement this simple program in CVX?

cvx_begin
variable x(3,1)
minimize((x(1).^2)+(0.1x(2).^2)+(x(3).^2)-(x(1).x(3))-x(2))
subject to
x(1)+x(2)+x(3)-(x(1)^2)-(x(2)^2)-(0.1
(x(3).^2))+(0.2
x(1).*x(3)) >= 1;
x >= 0;

cvx_end

K

M
Replying to #2

It is an example from the MOSEK manual and in CVX you have to input it in the same way, that is write each quadratic expression in the standard form x^TQx and then input it as quad_form(x,Q).

K
Replying to #3

Thanks for your response. Michal. Yes, you are right I have taken this example from the manual.
As you suggested, I have tried the following code with CVX but still it’s not working.

close all; clear; clc
n = 3;
H = [2 0 -1; 0 0.2 0; -1 0 2]; % make spsd
f = [0 -1 0]‘;
Q = [-2 0 0.2;0 -2 0;0.2 0 -0.2]; % make spsd
g = [1 1 1]’;
cvx_begin
variable x(n)
minimize(0.5*quad_form(x,H) + f’x)
0.5
quad_form(x,Q)+g’*x <=1
x >= 0
cvx_end

Error using cvxprob/newcnstr
Disciplined convex programming error:
Invalid constraint: {concave} <= {real constant}

Error in <= (line 21)
b = newcnstr( evalin( ‘caller’, ‘cvx_problem’, ‘’ ), x, y, ‘<=’ );

Error in quad_example (line 50)
0.5*quad_form(x,Q)+g’*x <=1

I would be grateful if you could give some suggestions to debug this code.

M
Replying to #4

You wrote the inequality the wrong way. It is >=1 and not <=1.

K
Replying to #5

Thanks Michal. It’s perfect now.