Optimization problem is in png. And this is my matlab code.

The error is “Disciplined convex programming error:
Cannot perform the operation: {real affine} ./ {real affine}”

I think the error occurs in log term. I don’t know how to deal with this.

N=10;

cvx_clear
cvx_begin
variables k(N)
variables z(N)

obj=0;
for i=1:N
obj = obj + k(i)*log(1+z(i)/k(i)) -z(i);
end
maximize obj
subject to
k_sum=0;
for i=1:N
k_sum = k_sum + k(i);
end
k_sum <= 1;
for i=1:N
k(i)>=0;
z(i)>=0;
end

I will address the optimization problem in your code. The optimization problem in the image is non-convex (maybe it’s a typo to not have z_i inside the log be divided by k_i?).

k(i)*log(1+z(i)/k(i)) can be reformulated as -rel_entr(k(i),k(i)+z(i)).
But rel_entr accepts vector arguments, producing vector result. So the for loop can be eliminated, and the objective written directly as maximize(sum(-rel_entr(k,k+z)-z))

All the other for loops can also be eliminated.
Use

Hello, I would like to ask about the expression of v_2[n] in my question. Only w_k[n] is a variable, and all other letters can be considered constants. How can the content of the log function be expressed using the rel_entr function instead？