load('data_trial.mat');
n=numel(data(:,1));
L=data(1:4);
I=data(4:8);
k1=1e-7, k2=2e-7;
cvx_begin
variable X(4);
%variable is_nonzero(X(4));
disp(X)
for i=1:n
cost(i)= k1*X(i)^2;
loss(i)=k2/(X(i)^2);
Z(i)= k3*log(0.558*0.526/X(i));
VD(i)= I(i)*Z(i)
V(i)=(V-VD(i))/V
end
minimize((sum(cost))+sum(loss))
subject to
V<=0.1;
X>0;
cvx_end
1 Like
cost
and loss
need to be declared as expression (holder). loss
can be handled using pow_p
log(a/x)
can be rewritten as -log(x/a)
.
Presuming all the input data is nonnegative, that leaves V <= 0.1
going in the wrong direction to be convex. However if the combination of input data is such that the V
comes out with the opposite sign multiplying the log term, it would be convex and could be entered into CVX.
1 Like