Hi, I am using the CVX toolbox to optimize the following problem,
Here is the code I used in Matlab:
k=[1 1 2];
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.