This is my problem, the code, and the final running screenshot. During the iterative process, the optimal value fluctuates greatly, but it doesn’t converge. Even the differences between them are quite large. I tried using different solvers, but the problem still persists. How can this be solved?
Even after the gap was further widened, CVX simply crashed.
function [r_m_opt,obj_history] = optimize_receive_antenna(r_m, r_m_all, u_r, w_n, alpha_t, alpha_c, sigma2, C_r, D, lambda, m, F_rd, h_td, h_tc, F_rc, g_rd, g_rc, L_path, theta_rdp, phi_rdp, theta_rcp, phi_rcp, L, N, M, zeta)
max_iter = 200;
tol = 1e-2;
r_current = r_m;
obj_history = zeros(max_iter, 1);
for iter = 1:max_iter
[f_rm, grad_f, g_rm, grad_g, delta_f, delta_g] = calculate_f_g_delta_function(r_current, r_m_all, u_r, h_td, h_tc, w_n, alpha_t, alpha_c, lambda, m, F_rd, F_rc, g_rd, g_rc, L_path, theta_rdp, phi_rdp, theta_rcp, phi_rcp, L, N, sigma2);
cvx_begin quiet
cvx_solver mosek
cvx_precision high
variable r(2)
variable alpha_f nonnegative
variable beta_g nonnegative
variable chi nonnegative
maximize chi
subject to
alpha_f >= real(1/2*(zeta*(beta_g)^2 + (chi)^2/zeta))
f_rm + grad_f.'*(r - r_current) - 0.5*delta_f*sum_square(r - r_current) >= alpha_f
g_rm + grad_g.'*(r - r_current) + 0.5*delta_g*sum_square(r - r_current) <= beta_g
r(1) >= C_r(1,1)
r(1) <= C_r(1,2)
r(2) >= C_r(2,1)
r(2) <= C_r(2,2)
for i = 1:M
if i == m
continue;
else
r_other = r_m_all(:, i);
dist = norm(r_current - r_other);
(r_current - r_other)' * (r - r_other) / dist >= D
end
end
cvx_end
if strcmp(cvx_status, 'Solved')
zeta = real(beta_g) / max(real(chi), 1e-12);
obj_history(iter) = cvx_optval;
r_current = r;
r_m_all(:, m) = r;
if iter > 1
obj_change = abs(obj_history(iter) - obj_history(iter-1));
if obj_change < tol
break;
end
end
else
error('CVX solution failed');
end
end
r_m_opt = r_current;
end

