# I need help to solve my problem, Illegal operation: {convex} - {convex} ,

`````` cvx_begin quiet
cvx_solver sedumi
variable alpha_i; % power coefficient for user i
variable alpha_j; % power coefficient for user j
variable alpha_k; % power coefficient for user k
variable alpha_s; % power coefficient for the target
minimize ((alpha_i^2) + (alpha_j^2) + (alpha_k^2) + (alpha_s^2) )
subject to
alpha_i >= 0 ;
alpha_j >= 0 ;
alpha_k >= 0;
alpha_s >= 0 ;
(alpha_i^2)*(norm(hi))^2-gamma*(((alpha_j^2)*(norm(hi))^2)+((alpha_k^2)*(norm(hi))^2)+((alpha_s^2)*(norm(hi))^2))>=gamma*sigma_UE;
(alpha_j^2)*(norm(hj))^2-gamma*(((alpha_i^2)*(norm(hj))^2)+((alpha_k^2)*(norm(hj))^2)+((alpha_s^2)*(norm(hj))^2))>=gamma*sigma_UE;
(alpha_k^2)*(norm(hk))^2-gamma*(((alpha_i^2)*(norm(hk))^2)+((alpha_j^2)*(norm(hk))^2)+((alpha_s^2)*(norm(hk))^2))>=gamma*sigma_UE;
trace(Mr)*((alpha_i^2)+(alpha_j^2)+(alpha_k^2)+(alpha_s^2) );
cvx_end
``````

Those constraints are non-convex as written.

However, all the variables only appear as squares (not counting the nonnegativity constraints). So you could redefine the variables to be the squares of what they are now, and replace all instances of `variable^2` with `variable`. That makes this into a Linear Programming problem, which of course satisfies CVX’s rules. After solution, you can take the square roots of the variables if that’s what you want.

Is this what do you mean? I have tried to do so and still get the same error.
alpha_i_squared = alpha_i^2;
alpha_j_squared = alpha_j^2;
alpha_k_squared = alpha_k^2;
alpha_s_squared = alpha_s;
aux _i = norm(hi)^2;
(alpha_i_squared)aux_i-gamma((alpha_j_squaredaux_i)+(alpha_k_squaredaux_i)+(alpha_s_squaredaux_i))>=gammasigma_UE;

No.

``````variable alpha_i_squared
...
minimize ((alpha_isquared + ...)
``````

etc.

ok, problem has been solved, Thank you so much for your help

however cvx_status is ‘Unbounded’

Perhaps you forgot the nonnegativity constraints on the variables?

I have added one more constraint and now it’s been solved, can i ask you sir one question?
due to the non-negativity constraint the variables i have defined should be positive, correct? however I got negative variables. how to fix this problem?

Please show your program and all CVX and solver output. In order to get the output, remove `quiet`. Please show us the variable values.

The solvers (and CVX) allow variables constrained to be nonnegatiive to be negative by up to a solver tolerance amount, no more than 1e-6. So if variables come out to be -1e-6 or -1e-9, that is considered to be solved properly. If that is not acceptable to you, either reset the slightly negative values to exactly zero after CVX concludes, or change the constraints to `variable >= small_positive_number`, where small_positive number is perhaps 1e-6.

``````cvx_begin
cvx_solver sedumi
%cvx_precision best
variable alpha_i_squared; % power coefficient for user i
variable alpha_j_squared; % power coefficient for user j
variable alpha_k_squared; % power coefficient for user k
variable alpha_s_squared; % power coefficient for the target
minimize ((alpha_i_squared) + (alpha_j_squared) + (alpha_k_squared) + (alpha_s_squared) )
subject to
alpha_i_squared >= 0 ;
alpha_j_squared >= 0 ;
alpha_k_squared >= 0 ;
alpha_s_squared >= 0 ;
alpha_i_squared + alpha_j_squared + alpha_k_squared + alpha_s_squared <=Ptx;
trace(Mr)*(alpha_i_squared+alpha_j_squared+alpha_k_squared+alpha_s_squared )>=zeta;
(alpha_i_squared*(norm(hi)^2))-gamma*((alpha_j_squared*(norm(hi))^2)+(alpha_k_squared*(norm(hi))^2)+(alpha_s_squared*(norm(hi))^2))>=gamma*sigma_UE;
(alpha_j_squared*(norm(hj)^2))-gamma*((alpha_i_squared*(norm(hj))^2)+(alpha_k_squared*(norm(hj))^2)+(alpha_s_squared*(norm(hj))^2))>=gamma*sigma_UE;
(alpha_k_squared*(norm(hk)^2))-gamma*((alpha_i_squared*(norm(hk))^2)+(alpha_j_squared*(norm(hk))^2)+(alpha_s_squared*(norm(hk))^2))>=gamma*sigma_UE;
cvx_end
alpha_i_opt = alpha_i_squared;
alpha_j_opt = alpha_j_squared;
alpha_k_opt = alpha_k_squared;
alpha_s_opt = alpha_s_squared;
P_total = alpha_i_opt + alpha_j_opt + alpha_k_opt + alpha_s_opt ;
``````

## Calling SeDuMi 1.3.4: 9 variables, 4 equality constraints For improved efficiency, SeDuMi is solving the dual problem.

SeDuMi 1.3.4 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 4, order n = 10, dim = 10, blocks = 1
nnz(A) = 24 + 0, nnz(ADA) = 16, nnz(L) = 10
it : by gap delta rate t/tP t/tD* feas cg cg prec
0 : 8.01E+02 0.000
1 : -3.39E+02 1.95E+02 0.000 0.2428 0.9000 0.9000 1.86 1 1 1.3E+00
2 : 1.39E+01 7.15E+00 0.000 0.0367 0.9900 0.9900 0.95 1 1
iter seconds digits cx by
2 0.2 Inf -3.6584682951e-08 7.7793441129e-15
|Ax-b| = 2.1e-16, [Ay-c]_+ = 9.0E-09, |x|= 3.4e+00, |y|= 2.2e-14

Detailed timing (sec)
Pre IPM Post
6.001E-02 1.090E-01 6.005E-03
Max-norms: ||b||=1, ||c|| = 1000,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 1.
Status: Solved
Optimal value (cvx_optval): -7.77934e-15

alpha_i_squared = -3.59046651365961e-15
alpha_j_squared = -1.55586882258583e-14
alpha_k_squared = 1.49602771402484e-14
alpha_s_squared = -3.59046651365961e-15

The assessment and advice in the 2nd paragraph of my previous post apply.

The exact optimal solution for this input data is all variables exactly zero. Clearly, the optimal objective value can’t be less than zero, so if all variables being zero is feasible (i.e., satisfies all constraints), it must be optimal, as is the case here.

how did you define that the optimal solutions of the variable is zero? what the mistakes that Ive done

I don’t know whether you’ve made any “mistakes”. Given the input data you used, the model has a trivial solution. All the variable values found by the solver are within essentially roundoff error of zero. Given the objective function and nonnegativity constraints, f a solution with objective value of zero is feasible, it must be optimal.