Please help me to find out the error in this program,Why can't it run?

code:

a=zeros(1,4);
b=ones(1,4);
g=9*rand(4,2)+5;
% Create and solve the model
cvx_begin
    variable x( 1, 4) 
    variable p( 2, 4);
   maximise(log(1+p(1,:)*g(:,1))/log(2)+log(1+p(2,:)*g(:,2))/log(2))
    sum(p)<=2*x
    sum(x)>=2
     a<=x<=b
cvx_end

I doubt you’ll get much help until you share a bit more detail, like exactly what is going wrong.

I ran it a few times with different random numbers using sedumi as solver, and the result was Status: Inaccurate/Solved , cvx_optval = 50.9508.

Using sdpt3 as solver, there was a very large number of “Warning: Matrix is singular to working precision In linsysolvefun at 29” messages, then 0/ 2 | 3.418e-12 9.682e-12 0.000e+00 | Failed, then Status: Failed.

I then ran it using SCS 1.1.5 under CVX 3.0 beta build 1175. I thought CVX would use SCS’s native exponential cone support, but received the warning CVX Warning: ‘Models involving “log” or other functions in the log, exp, and entropy family are solved using an experimental successive approximation method. …’ So I’m not clear whether the successive approximation method or native exponential cone was being used. Nevertheless, I hit max_iters, even after setting it as high as 1e7.

Edit: I tried SCS with max_iters = 1e8. Here is the outcome:

100000000| 3.26e-02  3.40e-01  1.71e-02  2.60e+01  2.69e+01  4.86e-15  1.95e+03 
----------------------------------------------------------------------------
Status: Solved/Inaccurate
Hit max_iters, solution may be inaccurate
Timing: Total solve time: 1.95e+03s
    Lin-sys: nnz in L factor: 45, avg solve time: 1.85e-007s
    Cones: avg projection time: 1.05e-005s
----------------------------------------------------------------------------
Error metrics:
dist(s, K) = 7.2071e-05, dist(y, K*) = 8.5313e-01, s'y/m = -1.1749e+00
|Ax + s - b|_2 / (1 + |b|_2) = 3.2603e-02
|A'y + c|_2 / (1 + |c|_2) = 3.3977e-01
|c'x + b'y| / (1 + |c'x| + |b'y|) = 1.7073e-02
----------------------------------------------------------------------------
c'x = 25.9930, -b'y = 26.9134
============================================================================
------------------------------------------------------------
Status: Failed
Optimal value (cvx_optval): NaN

Ok,thank you.I will try it.

CVX Warning:
Models involving “log” 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.
SDPT3 will be called several times to refine the solution.
Original size: 26 variables, 13 equality constraints
2 exponentials add 16 variables, 10 equality constraints

Cones | Errors |
Mov/Act | Centering Exp cone Poly cone | Status
--------±--------------------------------±--------
2/ 2 | 3.714e+00 7.993e-01 0.000e+00 | Solved
2/ 2 | 3.902e-01 9.909e-03 0.000e+00 | Solved
2/ 2 | 9.776e-03 6.173e-06 0.000e+00 | Solved
0/ 2 | 1.624e-04 1.663e-09 0.000e+00 | Solved

Status: Solved
Optimal value (cvx_optval): +9.26255

I want to know If problem is resolved or not when the CVX Warning appears,and is the optimal value true when it appears?

Given that a model contains a function in the log, exp, or entropy family, CVX will always issue that warning that it might not succeed. But I think if you get status Solved, that should mean it succeeded, and the values of your CVX variables (x and p) and cvx_optval should be correct. Have you checked to see whether the solution seems reasonable?

I don’t know why you succeeded with sdpt3 and I didn’t, but be grateful that it worked for you. I did get different behaviors between using sedumi and sdpt3 in CVX 2.1 vs. 3.0 beta, but they all failed for me (counting inaccurate/solved in sedumi under CVX 2,1, which looks like a failure to me). I wonder if you have a different linsysolvefun version than me, or something.