Help with a simple ojective

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?

variable x(3,1)
subject to
x(1).*x(3)) >= 1;
x >= 0;


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).

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]’;
variable x(n)
minimize(0.5*quad_form(x,H) + f’x)
quad_form(x,Q)+g’*x <=1
x >= 0

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.

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

1 Like

Thanks Michal. It’s perfect now.