Problem with log objective function


(Gorantla Balavenkataramulu) #1

my CVX code is the following:

cvx_begin quiet
variable x(MN,1) nonnegative
maximize sum(log(on1+c.x)/log(2))
subject to
x<=b
ones(M
N,1)
A*x<=d
cvx_end

where the constraints are written in AX<=d form and all cij are vectorized as C.
Why is it showing NaN for some instances and how to deal with it. Thank you in advance.


(Mark L. Stone) #2

Unless you are using CVX3.0 beta with SCS or ECOS solvers, I believe you are using CVX"s experimental successive approximation method. Please read http://cvxr.com/cvx/doc/advanced.html#the-successive-approximation-method for all the warnings and suggestions. Perhaps CVX"s successive approximation method is converging in some instances and not in others. If you are using CVX 2.1, your best “bet” might be use of MOSEK if available, otherwise try sedumi, sdpt3, and ECOS. Use of ECOS or SCS under CVX3.0 beta will avoid the successive approximation method and might have a better chance at success (but still see last sentence of next paragraph)…

Show us the output from the solver/CVX. Have you tried different solvers? Your coefficients span a wide range and are perhaps contributing to numerical difficulties for the solver, especially in combination with CVX’s successive approximation method. Can you reformulate your problem to have a smaller range of coefficients?

You haven’t told us what is changing between the instances in which it is finding a solution (if indeed it is, for which you should also show is the output) and instances in which you get a NaN solution. Perhaps some of your instances are either infeasible, or numerically appear to be infeasible to the solver.


(Michael C. Grant) #3

There is absolutely a scaling problem here. You’re going to need to find a way to perform a change of variables and scaling so that your values of a_i, g_{ij}, b_i, c_{ij}, etc. are all much closer to 1.


(Gorantla Balavenkataramulu) #4

I am using CVX 2.1, and it is showing the warning regarding successive approximation method. I tried using sedumi, SDPT3, NaN issue is persisting frequently like once every 7 instances (on an average) . Upon your advice, I tried with MOSEK, the frequency of NaN issue greatly decreased compared to sedumi and SDPT3, but still, there are NaN issues once every 100 instances.

In the problem, A, d and c are changing between the instances.


(Mark L. Stone) #5

I don’t know how your A, d, and c are generated, but try to do as mcg suggests and get your coefficients closer to magnitude 1 if you can.

Other than that, use MOSEK 8 rather than MOSEK 7 if you can, because its ability to handle numerically difficult problems is improved. Or try CVX 3.0 beta using ECOS or SCS, which have have support for the exponential cone, and therefore avoid the successive approximation method.