# How do I properly write the code for penalty CCP? provided function of problem

where
R_{k}(\mathbf{V}) & \triangleq \log_2(1+\gamma_k) \nonumber \
& \triangleq \log_2 \left( 1+\frac{|(V^H Z_{k}) w_k|^2 p_k}{\sum_{j=1,j\neq k}^{K}|(V^H Z_{k}) w_j|^2 p_j + \sigma^2} \right)

I write the code following the problem as below, but the result failed.


I = 3;
K = 6;
M = 30;
Nt = 8;
noise = 1e-12;
Puav = 0.03;
Pris = 9e-4;
lambda = 0.8;
tau = 0.1;
Rmin = 1;
e_theta = 2 * rand(1, M, I) - 1 + j * (2 * rand(1, M, I) - 1);
Z = 2 * rand(M*I, Nt, K) - 1 + j * (2 * rand(M*I, Nt, K) - 1);
w = 2 * rand(Nt, 1, K) - 1 + j * (2 * rand(Nt, 1, K) - 1);
p = rand(6, 1);
Pt_sum = sum(p);
P_sum = Pt_sum + Puav + Pris;

cvx_begin
variable c1(M * I) nonnegative
variable c2(K) nonnegative
variable V(M * I) complex
variable V_gamma(K) nonnegative

V_ini_R_sum = 0;
for Vk = 1:K
for Vi = 1:I
phi(:, :, Vi) = e_theta(:, :, Vi)';
V_noH((Vi - 1) * M + 1 : Vi * M) = phi(:, :, Vi)';
end
V_ini = V_noH';
V_ini_Hwp(:, :, Vk) = abs( V_ini' * Z(:, :, Vk) * w(:, :, Vk))^2 * p(Vk);

V_ini_interference_sum = 0;
for Vj = 1:K
if Vj ~= Vk
V_ini_interference = abs( V_ini' * Z(:, :, Vk) * w(:, :, Vj))^2 * p(Vj);
V_ini_interference_sum = V_ini_interference_sum + V_ini_interference;
end
end
V_ini_gamma(Vk) = V_ini_Hwp(:, :, Vk) / (V_ini_interference_sum + noise);
V_ini_R(Vk) = log(1 + V_ini_gamma(Vk)) / log(2);
V_ini_R_sum = V_ini_R_sum + V_ini_R(Vk);
V_R(Vk) = log(1 + V_gamma(Vk)) / log(2);
end

maximize ( sum(V_R) - lambda * P_sum - tau * ( sum(abs(c1)) + sum(abs(c2)) ) )
subject to
pow_abs(V,2) <= 1 + c1
2 * real( V_ini' * V ) - pow_abs(V_ini,2) >= 1 - c1

for Vks = 1:K
( V_gamma(Vks) - V_ini_gamma(Vks) ) / ( (1 + V_ini_gamma(Vks)) * log(2) ) >= Rmin - c2(Vks)
end


cvx_end

## Cones | Errors | Mov/Act | Centering Exp cone Poly cone | Status --------±--------------------------------±-------- 6/ 6 | 8.000e+00 1.747e+01 0.000e+00 | Failed 6/ 6 | 5.613e+00 1.706e+00 0.000e+00 | Failed 6/ 6 | 1.110e+00 5.659e-02 0.000e+00 | Failed 0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed 0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed 0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed

Status: Failed
Optimal value (cvx_optval): NaN

The best and most reliable solver for this problem is Mosek, which avoids CVX’s Successive Approximation method. if Mosek is not available to you, follow the advice at CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions

However, Mosek 10.1.10 failed on the few (random) problem instances I tried, with the status of dual ill-posed, which given that Mosek was provided the primal, means that Mosek assessed the problem is dual ill-posed. I will leave the assessment as to why to others.

Note that I have not attempted to check whether your CVX code matches the problem statement in the graphic. But because CVX called the solver, the program is a “legal” CVX program, although whether it is “correct” or good is another matter.

1 Like