Unexpected solution

Hi, I am using the CVX toolbox to optimize the following problem,

minimize -sum(kblog2(1+p/b))
s.t. sum§<=1;

Here is the code I used in Matlab:

k=[1 1 2];

cvx_begin quiet
variable p(x)
variable b(x)

minimize -sum(k*(-rel_entr(b,p+b)/log(2)))
subject to

It seems that the solution CVX gives is to allocate all p and b to the entity with the largest value of k (in the example case, the solution becomes p=[0 0 1], b=[0 0 1] ), but I would expect all p and b should be allocated with some value? Is it the problem with my coding?

I believe CVX is correctly optimizing the problem you provided it. I don’t know whether that’s the problem you intended to provide it.

The first version of your objective function, i.e. ,not the one provided to CVX, evaluates to a row vector (note that p/b evaluates to an x by x matrix) . I think when p or b have more than one non-zero element, the non-zero element (or the sum) of your first objective function does not equal your CVX objective. If p and b were both scalars, then your two objective functions wold be equal.

So your first step is to determine what you really want the objective function to be. Then make sure it is correctly modeled in CVX.