I’m trying to solve this convex problem,
The parameters’ description, I’m sorry it’s so long…
γ
This is the primary objective term or cost function component being minimized. It represents a specific performance metric, such as the total delay or system cost.
ξ
A positive weight or penalty coefficient used to balance the influence of the caching deviation term. It ensures that the caching optimization is properly weighted relative to other objectives.
xₘₙₗ
A decision variable representing the caching strategy, where xₘₙₗ ∈ [0,1].
It indicates the fraction of video layer l of video n cached on UAV m.
xₘₙₗʳ
The reference point for the caching variable xₘₙₗ in the Sequential Convex Approximation (SCA) method.
It is used to linearize the non-convex caching objective into a convex form.
τₖₘᵘ
A slack variable representing the transmission delay between user k and UAV m.
It is subject to the lower bound constraint based on the rate R̃ₖₘˡᵇ.
qₘ
A 2D or 3D vector representing the position of UAV m.
This variable is optimized for deployment purposes while ensuring safety constraints.
qᵣᵢ
The reference point for UAV i’s position in the SCA method.
It is used to linearize the non-convex safety distance constraint between UAVs.
aₖₘ
A binary association indicator that determines whether user k is associated with UAV m (1 if associated, 0 otherwise).
λₙₗ
The request probability for layer l of video n.
It reflects the demand of video content layers.
oₙᵢ
The size (in bits) of layer i of video n.
It is used to calculate the caching and transmission cost.
Zₖₘₙₗ
A term that aggregates the caching cost and delay components for user k, UAV m, video n, and layer l.
ζₖₘ
The elevation angle between UAV m and user k, expressed in degrees.
ζₖₘˡᵇ
The lower bound for the elevation angle ζₖₘ, ensuring sufficient line-of-sight (LoS) communication quality.
dₘᵢₙ²
The minimum squared safety distance that must be maintained between any two UAVs i and j to avoid collisions.
Code I wrote and debugged for 6 weeks
for iter = 1:max_iter
disp(iter)
epsilon = 1e-7; % Used to avoid division by zero
total_sum = 0;
% K is User , M is Uav , N M is for cache data
% Solve the convex optimization problem for P8
cvx_begin
variables R q_new(M, 2) x_new(M, N, L) tau_u(K, M) zeta_new(K, M)
% Compute the summation part of the objective function
C = 0;
for m = 1:M
for n = 1:N
for l = 1:L
C = C + x_new(m, n, l) - x_ref(m, n, l)^2 ...
- 2 * x_ref(m, n, l) * (x_new(m, n, l) - x_ref(m, n, l));
end
end
end
% Final objective function
minimize(R + xi * C) % R is the slack variable
subject to
% Constraint (30): Maximum elevation angle constraint
for k = 1:K
for m = 1:M
norm_ref = norm(q_ref(m, :) - params.w_k(k, :));
q_norm = norm(q_new(m, :) - params.w_k(k, :));
zeta_new(k, m) <= (180/pi()) * (atan(uav_heights(m) / norm_ref) - ...
(uav_heights(m) / (norm_ref^2 + uav_heights(m)^2)) * ...
(q_norm - norm_ref));
end
end
% Constraint (31): Safety distance constraint
for i = 1:M-1
for j = i+1:M
-norm(q_ref(i, :) - q_ref(j, :))^2 + ...
2 * (q_ref(i, :) - q_ref(j, :)) * (q_new(i, :) - q_new(j, :))' >= params.d_min^2;
end
end
% Constraint (29): Maximum rate constraint
for k = 1:K
for m = 1:M
% Reference point distance and elevation angle ζ_{km} and ζ_{km}^r
distance_ref = norm(q_ref(m, :) - params.w_k(k, :));
% Calculate elevation angle (ensure positivity)
zeta_ref = atan(uav_heights(m) / distance_ref) * (180 / pi); % Angle in degrees
% Calculate X_{km}^r
X_km_ref = 1 + exp(-(params.Ba + params.Bb * zeta_ref));
% Calculate Y^r_km (distance squared + UAV height squared)
Y_r_km = distance_ref^2 + uav_heights(m)^2;
% Calculate Γ_{km}^r
Gamma_km_ref = (params.Bc + (params.Bd / X_km_ref)) * ...
log2(1 + (params.gamma_0 / (Y_r_km^(params.alpha_L / 2))));
% Calculate Ω_{km}^r
Omega_km_ref = (params.Bd * log2(exp(1))) / (X_km_ref^2) * ...
log(1 + (params.gamma_0 / (Y_r_km^(params.alpha_L / 2))));
% Calculate Ψ_{km}^r
Psi_km_ref = (params.Bc + params.Bd / X_km_ref) * ...
(params.gamma_0 * (params.alpha_L / 2) * log2(exp(1))) / ...
(Y_r_km * ((Y_r_km^(params.alpha_L / 2)) + params.gamma_0));
Psi_km_ref = max(Psi_km_ref, epsilon); % Avoid Psi being zero or numerical errors
% Compute exp(...) difference
exp_diff = exp(-(params.Ba + params.Bb * zeta_new(k, m))) - ...
exp(-(params.Ba + params.Bb * zeta_ref));
% Compute norm difference using square_pos
norm_diff = (q_new(m, 1) - params.w_k(k, 1))^2 + (q_new(m, 2) - params.w_k(k, 2))^2 - ...
norm(q_ref(m, :) - params.w_k(k, :))^2;
% Combined R_{km}^{lb}
inv_pos(tau_u(k, m)) <= (Gamma_km_ref - Omega_km_ref * exp_diff - Psi_km_ref * norm_diff);
end
end
% Constraint (28): Total transmission time bounded by slack variable R
for k = 1:K
for m = 1:M
inner_sum = 0; % Initialize inner summation
for n = 1:N
for l = 1:L
% Compute Z_kmnl
Z_kmnl_val = 0.5 * (x_new(m, n, l) + tau_u(k, m))^2 - ...
0.5 * (x_ref(m, n, l)^2 + tau_ref(k, m)^2) - ...
x_ref(m, n, l)*(x_new(m, n, l) - x_ref(m, n, l)) - ...
tau_ref(k, m)*(tau_u(k, m) - tau_ref(k, m));
adjusted_val = Z_kmnl_val + (1 - x_new(m, n, l)) * params.tau_bk(k);
% Add weighted layer summation
layer_sum = sum(params.o(n, 1:l) * adjusted_val);
inner_sum = inner_sum + params.lambda(k, n, l) * layer_sum;
end
end
total_sum = total_sum + a(k, m) * inner_sum;
end
end
total_sum <= R;
% Constraint (3): Cache capacity constraint
for m = 1:M
sum(sum(params.o .* squeeze(x_new(m, :, :)))) <= params.C_max;
end
% Constraint (17): Caching strategy bounds
for m = 1:M
for n = 1:N
for l = 1:L
0 <= x_new(m, n, l) <= 1;
end
end
end
cvx_end
cvx_clear
% Update local points
x_ref = x_new;
q_ref = q_new;
tau_ref = tau_u;
params.xi = params.xi * 1.2;
end
I think the problem might be because of :
-
Psi_km_ref * exp_diff is too small, since I get Psi_km_ref = 3.6339e-12
the solver can run if i do Psi_km_ref = max(Psi_km_ref, epsilon);
but the value of output is kinda wrong i think…
(The delay of 1 bit will become large as 1 ~ 100… -
maybe i should not put Zeta_new ζ as a variable?
-
the expression of total_sum & total_sum <= R
I can give the paper I’m trying to redo if that helps.
If anyone can help, it’s much appreciated Thank you a lot!
( I’m now trying to scale down the Psi_km_ref , but i don’t really sure that it’s the main reason that occurs the problem
eg. 1.slow bit rate per sec τ
- cache deployment x(a,b,c) should act like x(a,b,c)=1 if x(a,b,c+1)=1
instead of x(a,b,c)=0 and x(a,b,c+1)=1