Xinyuan
September 25, 2016, 3:32pm
1
Dear all,
I was trying to minimize a nonnegative object. But the result shows unbounded. Could u help me find out what’s wrong here ?
The code is to perform the algorithm shown in the following formula:
load('data1.mat');
[N,d] = size (Xtrain);
beta = ones(d,1);
solution = zeros(10,d);
for k = 1:10
cvx_begin
variable x(d);
minimize ((Ytrain - Xtrain*x)'*(Ytrain - Xtrain*x)/N + 0.5* sum(abs(x)./(sqrt(abs(beta))+ eps)));
cvx_end
solution(k, 1:d) = x';
beta = x;
clear x;
end
Can you show the output from running it? Which iteration (value of k) did your get the unbounded message? Did you look at the beta which was used in that iteration? Did it have any very large magnitude components?
We haven’t seen data1.mat, so we don’;t know whether your input data might be very bad numerically (spanning many orders of magnitude). Perhaps the solver is having numerical difficulties with challenging input data, to include value of beta somwhere for k=2:10… Have you tried more than one solver?
Xinyuan
September 26, 2016, 12:01am
3
Thank you for such a quick reply.
The dataset has been uploaded to google drive at the following link.
https://drive.google.com/drive/folders/0BwJJX4_LUeQNSFM0SDdoSl9iczg?usp=sharing
I set beta all ones at the beginning.
The “unbounded” first appear when k = 3, and the outcome of the first 3 steps are shown as below:
Calling SDPT3 4.0: 622 variables, 221 equality constraints
For improved efficiency, SDPT3 is solving the dual problem.
num. of constraints = 221
dim. of socp var = 622, num. of socp blk = 111
SDPT3: Infeasible path-following algorithms
version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime
0|0.000|0.000|3.6e+00|7.6e+05|2.5e+08| 0.000000e+00 0.000000e+00| 0:0:01| chol 1 1
1|0.989|0.989|3.8e-02|8.3e+03|3.4e+07| 9.916508e+00 -3.206466e+07| 0:0:02| chol 1 1
2|1.000|0.989|2.4e-07|9.1e+01|3.8e+05| 1.002198e+01 -3.654275e+05| 0:0:02| chol 1 1
3|1.000|0.989|3.5e-08|1.0e+00|4.2e+03| 9.901105e+00 -4.030955e+03| 0:0:02| chol 1 1
4|1.000|0.986|1.1e-08|1.4e-02|6.1e+01| 4.082889e+00 -5.550309e+01| 0:0:02| chol 1 1
5|0.978|0.968|6.7e-09|4.4e-04|1.9e+00|-4.602446e-02 -1.905544e+00| 0:0:02| chol 1 1
6|0.962|0.909|1.8e-09|4.1e-05|1.9e-01|-1.251555e-01 -3.122654e-01| 0:0:02| chol 1 1
7|0.889|0.857|6.0e-09|5.9e-06|3.3e-02|-1.288632e-01 -1.609139e-01| 0:0:02| chol 1 1
8|0.962|0.918|1.6e-09|4.9e-07|3.0e-03|-1.293898e-01 -1.323257e-01| 0:0:02| chol 1 1
9|0.932|0.945|1.7e-10|2.8e-08|3.0e-04|-1.294363e-01 -1.297357e-01| 0:0:02| chol 1 1
10|1.000|0.873|2.5e-13|3.6e-09|4.7e-05|-1.294421e-01 -1.294888e-01| 0:0:02| chol 1 1
11|0.954|0.996|1.5e-13|1.7e-11|2.7e-06|-1.294428e-01 -1.294455e-01| 0:0:02| chol 1 1
12|0.991|0.986|5.3e-14|1.2e-12|5.3e-08|-1.294429e-01 -1.294430e-01| 0:0:02| chol 1 1
13|1.000|0.517|9.4e-13|1.6e-12|2.8e-08|-1.294429e-01 -1.294429e-01| 0:0:02| chol 1 1
14|1.000|0.518|4.3e-13|1.8e-12|1.5e-08|-1.294429e-01 -1.294429e-01| 0:0:02|
stop: max(relative gap, infeasibilities) < 1.49e-08
number of iterations = 14
primal objective value = -1.29442904e-01
dual objective value = -1.29442918e-01
gap := trace(XZ) = 1.47e-08
relative gap = 1.17e-08
actual relative gap = 1.16e-08
rel. primal infeas (scaled problem) = 4.34e-13
rel. dual " " " = 1.77e-12
rel. primal infeas (unscaled problem) = 0.00e+00
rel. dual " " " = 0.00e+00
norm(X), norm(y), norm(Z) = 5.4e+00, 2.6e+01, 3.6e+01
norm(A), norm(b), norm© = 1.5e+06, 6.2e+00, 1.9e+01
Total CPU time (secs) = 1.91
CPU time per iteration = 0.14
termination code = 0
DIMACS: 1.8e-12 0.0e+00 1.7e-11 0.0e+00 1.2e-08 1.2e-08
Status: Solved
Optimal value (cvx_optval): +0.126943
Calling SDPT3 4.0: 622 variables, 221 equality constraints
For improved efficiency, SDPT3 is solving the dual problem.
num. of constraints = 221
dim. of socp var = 622, num. of socp blk = 111
SDPT3: Infeasible path-following algorithms
version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime
0|0.000|0.000|2.1e+00|7.6e+05|1.1e+19| 0.000000e+00 0.000000e+00| 0:0:00| chol 2 2
1|0.963|0.963|7.9e-02|2.8e+04|1.1e+18| 4.359271e+11 -6.531636e+17| 0:0:00| chol 2 2
2|0.988|0.988|9.7e-04|3.4e+02|1.4e+16| 4.524484e+11 -8.071464e+15| 0:0:00| chol 2 2
3|0.989|0.989|1.1e-05|3.8e+00|2.0e+14| 4.510566e+11 -1.345449e+14| 0:0:00| chol 2 2
4|0.989|0.989|1.2e-07|7.6e-02|9.4e+12| 3.412987e+11 -8.453296e+12| 0:0:00| chol 1 2
5|0.989|0.989|1.3e-09|1.8e-02|1.1e+11| 6.763820e+09 -1.054873e+10| 0:0:00| chol 2 2
6|0.989|0.989|1.4e-11|8.6e-03|1.3e+09| 7.678303e+07 4.309927e+10| 0:0:00| chol 2 2
7|0.989|0.989|1.6e-13|4.3e-03|1.4e+07| 8.736502e+05 2.211435e+10| 0:0:00| chol 2 2
8|0.989|0.989|1.4e-12|2.2e-03|1.7e+05| 9.650305e+03 1.106366e+10| 0:0:00| chol 2 2
9|0.951|0.594|1.0e-10|8.7e-04|7.2e+04| 5.358644e+02 4.491725e+09| 0:0:00| chol 2 2
10|0.999|0.578|9.3e-11|3.7e-04|3.4e+04| 3.054293e+01 1.896328e+09| 0:0:00| chol 2 2
11|1.000|0.565|7.1e-11|1.6e-04|1.7e+04| 1.432691e+01 8.243244e+08| 0:0:00| chol 2 2
12|1.000|0.556|5.7e-11|7.1e-05|8.3e+03| 6.927745e+00 3.656768e+08| 0:0:00| chol 2 2
13|1.000|0.549|4.8e-11|3.2e-05|4.2e+03| 3.376512e+00 1.647857e+08| 0:0:00| chol 2 2
14|1.000|0.543|3.9e-11|1.5e-05|2.2e+03| 1.642033e+00 7.535474e+07| 0:0:01| chol 2 2
15|1.000|0.535|2.6e-11|6.8e-06|1.2e+03| 7.875923e-01 3.507394e+07| 0:0:01| chol 2 2
16|1.000|0.526|2.8e-11|3.2e-06|6.3e+02| 3.607269e-01 1.664026e+07| 0:0:01| chol 2 2
17|1.000|0.519|2.1e-11|1.6e-06|3.6e+02| 1.388101e-01 8.010677e+06| 0:0:01|
lack of progress in infeas
number of iterations = 17
primal objective value = 1.64203328e+00
dual objective value = 7.53547409e+07
gap := trace(XZ) = 2.17e+03
relative gap = 2.87e-05
actual relative gap = -1.00e+00
rel. primal infeas (scaled problem) = 3.89e-11
rel. dual " " " = 1.47e-05
rel. primal infeas (unscaled problem) = 0.00e+00
rel. dual " " " = 0.00e+00
norm(X), norm(y), norm(Z) = 5.0e+11, 5.6e+03, 7.9e+03
norm(A), norm(b), norm© = 1.5e+06, 5.0e+11, 1.9e+01
Total CPU time (secs) = 0.62
CPU time per iteration = 0.04
termination code = 0
DIMACS: 2.2e-10 0.0e+00 1.4e-04 0.0e+00 -1.0e+00 2.9e-05
Status: Solved
Optimal value (cvx_optval): -7.53547e+07
Calling SDPT3 4.0: 622 variables, 221 equality constraints
For improved efficiency, SDPT3 is solving the dual problem.
num. of constraints = 221
dim. of socp var = 622, num. of socp blk = 111
SDPT3: Infeasible path-following algorithms
version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime
0|0.000|0.000|2.1e+00|7.6e+05|1.9e+23| 0.000000e+00 0.000000e+00| 0:0:00| chol 2 2
1|0.963|0.963|7.9e-02|2.8e+04|1.8e+22| 7.292726e+15 -1.092611e+22| 0:0:00| chol 2 2
2|0.988|0.988|9.7e-04|3.4e+02|2.3e+20| 7.569117e+15 -1.341993e+20| 0:0:00| chol 2 2
3|0.989|0.989|1.1e-05|3.8e+00|2.5e+18| 7.545832e+15 -1.471785e+18| 0:0:00| chol 2 2
4|0.989|0.989|1.2e-07|7.6e-02|3.3e+16| 5.709349e+15 -1.327953e+16| 0:0:00| chol 2 2
5|0.989|0.989|1.3e-09|1.8e-02|4.1e+14| 1.137019e+14 1.301270e+15| 0:0:00| chol 2 2
6|0.989|0.989|1.4e-11|8.6e-03|4.8e+12| 1.277963e+12 7.378025e+14| 0:0:00| chol 2 2
7|0.989|0.989|1.6e-13|4.3e-03|1.6e+11| 1.404378e+10 3.698676e+14| 0:0:00| chol 2 2
8|0.989|0.989|1.9e-12|2.1e-03|2.1e+09| 1.548868e+08 1.849956e+14| 0:0:00| chol 2 2
9|0.945|0.566|9.9e-11|9.3e-04|9.3e+08| 9.271417e+06 8.019854e+13| 0:0:00| chol 2 2
10|0.950|0.560|8.2e-11|4.1e-04|4.5e+08| 8.340412e+05 3.530685e+13| 0:0:00| chol 2 2
11|1.000|0.552|1.0e-10|1.8e-04|2.3e+08| 1.911027e+05 1.580133e+13| 0:0:00| chol 2 2
12|1.000|0.547|6.0e-11|8.3e-05|1.1e+08| 9.507463e+04 7.160112e+12| 0:0:00| chol 2 2
13|1.000|0.542|6.0e-11|3.8e-05|5.9e+07| 4.815812e+04 3.279078e+12| 0:0:00| chol 2 2
14|1.000|0.537|4.4e-11|1.8e-05|3.1e+07| 2.476822e+04 1.518621e+12| 0:0:00| chol 2 2
15|1.000|0.530|6.4e-11|8.3e-06|1.7e+07| 1.299436e+04 7.141059e+11| 0:0:00| chol 2 2
16|1.000|0.521|2.7e-11|4.0e-06|9.7e+06| 7.076006e+03 3.421685e+11| 0:0:01| chol 2 2
17|1.000|0.510|1.9e-11|1.9e-06|5.7e+06| 4.111950e+03 1.675029e+11| 0:0:01|
lack of progress in infeas
prim_inf,dual_inf,relgap = 1.91e-11, 1.95e-06, 3.39e-05
sqlp stop: primal problem is suspected of being infeasible
number of iterations = 17
residual of primal infeasibility
certificate (y,Z) = 1.21e-11
reldist to infeas. <= 1.63e-12
Total CPU time (secs) = 0.54
CPU time per iteration = 0.03
termination code = 1
DIMACS: 2.4e-10 0.0e+00 1.7e-04 0.0e+00 -1.0e+00 2.0e-05
Status: Unbounded
Optimal value (cvx_optval): -Inf
I replicated your results using SDPT3. On k = 2, cvx_optval = -7.53569e+07. On k = 3, the solver states “sqlp stop: primal problem is suspected of being infeasible” Notice that it doesn’t state that the problem is definitely infeasible (of course, that’s the same message I get when I try it on an actual infeasible problem, such as 1 <= x <= 0). I think it is having numerical difficulty because some of the terms in the sum are abs(x) times 1/sqrt(eps) = abs(x) * 6.7e7… I guess this is giving SDPT3 numerical troubles.
SeDuMi did make it through k = 10, and converged to cvx_optval = 742.242, and was already getting close by k = 3, but was pretty wild on k = 2 (cvx_optbal = 295519). I have no idea whether this converged to the correct answer, but it converged. I’ll let you worry about how to fix things up.
Xinyuan
September 26, 2016, 1:29pm
5
Thank you so much. It works after I switch to SeDumi.
Then I was trying to replace the linear expression with logit with
minimize (-sum(labelTrain.*log(exp(trainData*x)./(1+exp(trainData*x)))+(1-labelTrain).*log(1-exp(trainData*x)./(1+exp(trainData*x))))+ lambda* sum(abs(x)./(sqrt(abs(beta))+ eps)));
But it turns out an error
Error using + (line 83)
Disciplined convex programming error:
Illegal operation: {real constant} - {log-concave}
Error in - (line 21)
z = plus( x, y, true, cheat );
Error in test (line 23)
minimize
(-sum(labelTrain.log(exp(trainData x)./(1+exp(trainDatax)))+(1-labelTrain).log(1-exp(trainData x)./(1+exp(trainData x))))+
lambda* sum(abs(x)./(sqrt(abs(beta))+ eps)));
I do not understand this error information and how can I make it work?
Thank you again for your help.
You are in violation of CVX’s rules regarding log-concave functions.
You can find the rules in the CVX 3.0Beta Users Guide at http://web.cvxr.com/cvx/beta/doc/advanced.html#log-convexity . The rules stated there also apply to CVX 2,.1 even though they are not mentioned in the current 2.1 Users’ Guide. They are also discussed in the first answer by mcg in Log of sigmoid function .
“Regular” logistic regression can be done in CVX. See http://cvxr.com/cvx/examples/cvxbook/Ch07_statistical_estim/html/logistics.html for an example.