Unfortunately, you started with a tricky problem on which to start using CVX.
As I wrote above, z needs to be declared a (CVX) variable. Given that you really need z to be a length n,vector, and still need bw to be a CVX variable, you can use
variables bw(n) z(n)
I’m not sure I understand the relation between your code and the problem in your first post, so I will present code as if the simplified 1-D indexing in your code covers your situation, and guess on variable names. Otherwise, you will need to make modifications. You should be able to figure out how to modify my code if doiesn’t quite match your problem.
cvx_begin
variables bw(n) z(n)
minimize(sum((z-bw)./ChannelGainUN))
for i=1:n
{currentUsersMinRate(i)*log(2),bw(i),z(i)} == exponential(1)
end
sum(bw) == MaxBandwidthOfEachRRH
bw >= 0
cvx_end
I made up some (I suppose non-sensical) data, ran the code, and it produced an answer. No guarantees beyond that.
n = 5;
ChannelGainUN = [1.1:.1:1.5]';
currentUsersMinRate = [3.2 2.1 1.4 2.6 5.3]';
With result:
CVX Warning:
Models involving "exponential" or other functions in the log, exp, and entropy
family are solved using an experimental successive approximation method.
This method is slower and less reliable than the method CVX employs for
other models. Please see the section of the user's guide entitled
The successive approximation method
for more details about the approach, and for instructions on how to
suppress this warning message in the future.
Successive approximation method to be employed.
For improved efficiency, SDPT3 is solving the dual problem.
SDPT3 will be called several times to refine the solution.
Original size: 21 variables, 10 equality constraints
5 exponentials add 40 variables, 25 equality constraints
-----------------------------------------------------------------
Cones | Errors |
Mov/Act | Centering Exp cone Poly cone | Status
--------+---------------------------------+---------
5/ 5 | 3.021e+00 6.360e-01 0.000e+00 | Solved
5/ 5 | 6.867e-01 2.941e-02 0.000e+00 | Solved
5/ 5 | 7.530e-02 3.598e-04 0.000e+00 | Solved
5/ 5 | 9.459e-03 5.666e-06 0.000e+00 | Solved
5/ 5 | 1.189e-03 8.907e-08 0.000e+00 | Solved
0/ 5 | 1.492e-04 1.100e-09 0.000e+00 | Solved
-----------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +64.154
disp(bw)
0.683591761913353
0.440268935079385
0.288547159549769
0.527562346711498
1.060029796730820