Convert problem to cvx

(Mark L. Stone) #13

Everything in my example data is 5 by 1, including ChannelGainUN = [1.1:.1:1.5]' , so it was all compatible and successfully ran. I just made up the data so I could check that there were no syntax errors and that ir ran successfully. You should be able to duplicate my results.

I presume that you have or will obtain actual input data which you want to use. Of course, you should make the dimensions of everything compatible. You can make adjustments to my program as needed to match your data and problem.

(negin) #14

yes your example is totally correct, but my channelgainUN is a signle number, and when I put that is here:


it gives no errors but it does not solve it and says that its infeasible.

(Mark L. Stone) #15

If you show a complete reproducible example, with all input data, then perhaps we can diagnose your problem.

(negin) #16


yes sure

(Mark L. Stone) #17

Let’s make this simpler. Just display with format long all the input data used by your CVX code.


Please show the CVX and solver output you got when you ran your code which you wrote “says that its infeasible”/

(negin) #19

i gave these values:


I changed the MaxBandwidthOfEachRRH to a single number (i had given an array before but it was a mistake) and now it says "solved"
and now it gives me 4 values for bw:


and this is the output:

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: 16 variables, 7 equality constraints
4 exponentials add 32 variables, 20 equality constraints
Cones | Errors |
Mov/Act | Centering Exp cone Poly cone | Status
4/ 4 | 6.429e-01 2.889e-02 0.000e+00 | Solved
4/ 4 | 2.916e-02 6.174e-05 0.000e+00 | Solved
2/ 4 | 1.786e-03 2.098e-07 0.000e+00 | Solved
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Solved
Status: Solved
Optimal value (cvx_optval): +0.474269

thank you so much for your help

(Mark L. Stone) #20

After solution, bw should be an n by 1 vector containing the optimal values.

After cvx_end, you have the statement bandwidth(i)=max(0,bw(i)); This will only be executed for the then current value of i, which is n (because it had been used as the index of a for loop from 1 to n). If an optimal solution has been obtained, bw should be non-negative anyhow, unless you are worried about roundoff-level negative values. If you really want to do this, then use bandwidth = max(0,bw); which will ensure each element is non-negative.

(negin) #21

it gives me 4 bw s now, thank you so much for your help

(negin) #22

@Mark_L_Stone hi again, I have a new question that is related to this one. I need to add the constraint below to my cvx optimization. how can I add it to my code?

I want my cvx code to minimize the current problem that i mentioned above and it also shoud minimize the power in a way that 1/(bw.log2((1+power.gain)/bw(0.1+Interference)) is minimized too.
this is my current cvx code:

            variables bw(n) z(n);
            for i=1:n
              {a(i)*log(2),bw(i),z(i)} == exponential(1);
            sum(bw) == maxbwofthisrrh;
            bw >= 0;
            bw = bw.';
         for i=1:n

is there any way to achieve this?

(Mark L. Stone) #23

You seem to have some missing symbols in your additional objective, so I am not sure what it is, and whether it is convex and expressible in CVX.

Presuming that it is convex and expressible in CVX, either combine both objectives in a way which makes sense to you., such as a weighted sum, or minimize one of the objectives subject to an additional constraint that the other objective <= u, where u is a constant you choose. If u is too small, the problem might be infeasible. By varying u, you can map out an efficient frontier of optimal tradeoffs between the two objectives.

(negin) #24

I actually made some changes to make it easier to solve. so I came up with adding the phrase below:

∑k∈Kn 1/(b(w).R(k,min))

to the previous one.
and b(w) is the same as the previous problem, and is the variable that I am looking for. and R(k,min) is the same R(k,min) in the previous problem, I mean currentUsersMinRate. so it’s and array in size of Kn

so I need to minimize this phrase:

s + ∑k∈Kn 1/(b(w).R(k,min))

what should I add to my CVX code?

(Mark L. Stone) #25

I don’t understand what problem you want to solve. Do you want to add an additional term to your existing objective function? If so, can you write this new term in MATLAB, even if is not legal in CVX? Be sure to make clear what variables would be CVX (optimization) variables and what is input data. Also, use the same variable names as before for anything which is supposed to be the same variables as before. It might be best to show the complete program. At least that way we can see the problem you want to solve.

Of course, this additional term better be convex.

Do you maybe want to use inv_pos? But I don’t understand what R(k,min) is.

(negin) #26

yes, I want to add and additional term to my current objective function. I have calculated the second term and its is convex. so I need to minimize the sum of both phrases.
I mean something like this. (I don’t know how to add R(k,min) to my cvx.

            variables bw(n) z(n);
            for i=1:n
              {a(i)*log(2),bw(i),z(i)} == exponential(1);
            sum(bw) == maxbwofthisrrh;
            bw >= 0;
            bw = bw.';

(Mark L. Stone) #27

Can you show a formula or code segment for creating R(k,min) ?

(negin) #28

R(k,min) is an array like [0.1,1,10,0.1]. it is created randomly at the beggining of the code.
its the same as currentUsersMinRate in this post. Convert problem to cvx

(Mark L. Stone) #29

do what you want?

(negin) #30

so it should be:

        variables bw(n) z(n);
        for i=1:n
          {a(i)*log(2),bw(i),z(i)} == exponential(1);
        sum(bw) == maxbwofthisrrh;
        bw >= 0;
        bw = bw.';

why does R has a prime? thanks

(Mark L. Stone) #31

R’ because I mis-read R as a column vector.

I think you want one of the following, I’m guessing now you want the first of these:

Note: edited to use R’ in first line of code

(negin) #32

I will try both to see which one works best, thanks @Mark_L_Stone

(Mark L. Stone) #33

They are different models. You have to figure out what you want.

If R = [2 3], they correspond to:
1/(2*bw(1)) + 1/(3*bw(2))
1/(2*bw(1) + 3*bw(2))