I try to use CVX to solve a convex problem, this is the problem fomulation:
and this is my code:
function [f,beita,cvx_optval] = resource_allocation(Si_size,A,B,W,D,E,f_min,f_max)
cvx_begin
variable f(Si_size)
expressions T1(Si_size)
expressions beita_t(Si_size)
expressions T2(Si_size)
expressions summ
summ = 0
for i = 1:Si_size
T1(i) = (A(i) + 2*B(i)*f(i)*f(i)*D(i)/E(i))^(1/2);
summ = summ + T1(i);
end
for i = 1:Si_size
beita_t(i) = T1(i)/summ
T1(i) = A(i)*inv_pos(beita_t(i))+ B(i)*f(i)*f(i);
T2(i) = D(i)*inv_pos(beita_t(i)) + E(i)inv_pos(f(i))
end
minimize(sum(T1)+Wmax(T2))
subject to
f_min <= f <= f_max
cvx_end
T = (A + 2.B.(f.^2).*D./E).^(1/2)
beita = T./sum(T)
disp(f)
disp(beita)
end
I set the value of the parameters randomly as
Si_size = 3; %length(A/B/D/E)
A = [1,2,3];
B = [2,3,4];
W = 2; %a constant
D = [4,5,2];
E = [2,4,6];
f_min = 2;
f_max = 8;
and the error is:
Illegal operation: {convex} .^ {0.5}
(Consider POW_P, POW_POS, or POW_ABS instead.)
.^ (line 55)
z = pow_cvx( x, y, ‘power’ );
^ (line 9)
z = power( x, y );
resource_allocation (line 32)
T1(i) = (A(i) + 2*B(i)*f(i)*f(i)*D(i)/E(i))^(1/2);
i have tried many methods(maybe wrong methods), but still cannot solve it.
so how to express the problem properly in cvx?
I really appreciate your geneous help.