Closed mpf closed 8 years ago
That's very strange. You can take a look at the conic form of the problem by calling c,A,b,cones,_ = conic_problem(prob)
. The problem passed to the solvers is
minimize c^T x
subject to b - Ax in cones
(see the MPB docs).
I tried this problem with Mosek and ECOS and they also failed. I'm not sure why this particular problem is giving the solvers such trouble. With random data of the same size (and using the same formulation) the solvers succeed.
The optimal objective value is pretty large (~1e8), but not too bad. Ipopt doesn't have any issues:
using JuMP, Ipopt, JLD
data = load("data.jld")
A, b, τ = data["A"], data["b"], data["τ"]
n = size(A,2)
m = Model(solver=IpoptSolver())
@defVar(m, x[1:n] ≥ 0)
@setObjective(m, Min, sum((A*x-b).^2))
@addConstraint(m, sum(x) == τ)
status = solve(m)
This is Ipopt version 3.12.1, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).
Number of nonzeros in equality constraint Jacobian...: 2
Number of nonzeros in inequality constraint Jacobian.: 0
Number of nonzeros in Lagrangian Hessian.............: 10752
Total number of variables............................: 2
variables with only lower bounds: 2
variables with lower and upper bounds: 0
variables with only upper bounds: 0
Total number of equality constraints.................: 1
Total number of inequality constraints...............: 0
inequality constraints with only lower bounds: 0
inequality constraints with lower and upper bounds: 0
inequality constraints with only upper bounds: 0
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 2.4973601e+08 0.00e+00 1.12e+04 0.0 0.00e+00 - 0.00e+00 0.00e+00 0
1 1.3703469e+08 2.84e-14 4.32e-07 -1.4 1.07e+02 - 1.00e+00 1.00e+00f 1
2 1.3703469e+08 0.00e+00 8.68e-02 -11.0 6.98e-04 - 9.90e-01 1.00e+00f 1
3 1.3703469e+08 0.00e+00 8.68e-04 -11.0 1.99e-07 - 9.90e-01 1.00e+00h 1
4 1.3703469e+08 2.84e-14 8.68e-06 -11.0 3.28e-13 - 9.90e-01 1.00e+00f 1
5 1.3703469e+08 0.00e+00 1.65e-08 -11.0 1.13e-13 - 9.98e-01 1.00e+00h 1
6 1.3703469e+08 2.84e-14 2.23e-12 -11.0 4.51e-14 - 1.00e+00 1.00e+00f 1
Number of Iterations....: 6
(scaled) (unscaled)
Objective...............: 4.7095083704558457e+05 1.3703469152281412e+08
Dual infeasibility......: 2.2252975357988175e-12 6.4750487179865272e-10
Constraint violation....: 2.8421709430404007e-14 2.8421709430404007e-14
Complementarity.........: 1.3202291009656215e-11 3.8415302269173957e-09
Overall NLP error.......: 1.3202291009656215e-11 3.8415302269173957e-09
Number of objective function evaluations = 7
Number of objective gradient evaluations = 7
Number of equality constraint evaluations = 8
Number of inequality constraint evaluations = 0
Number of equality constraint Jacobian evaluations = 1
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations = 1
Total CPU secs in IPOPT (w/o function evaluations) = 0.416
Total CPU secs in NLP function evaluations = 0.128
Thanks for the input, folks! SCS (via Convex) behaves better if it's given a hint:
# Conic formulation
x = Variable(n)
r = Variable(m)
t = Variable(1)
prob = minimize( t, norm(r) ≤ t, A*x+r==b, sum(x)==τ, x≥0)
solve!(prob, SCS.SCSSolver(verbose=1))
Here's the output:
----------------------------------------------------------------------------
SCS v1.1.5 - Splitting Conic Solver
(c) Brendan O'Donoghue, Stanford University, 2012
----------------------------------------------------------------------------
Lin-sys: sparse-direct, nnz in A = 10761
eps = 1.00e-04, alpha = 1.80, max_iters = 20000, normalize = 1, scale = 5.00
Variables n = 2693, constraints m = 5382
Cones: primal zero / dual free vars: 2690
linear vars: 3
soc vars: 2689, soc blks: 1
Setup time: 2.01e-03s
----------------------------------------------------------------------------
Iter | pri res | dua res | rel gap | pri obj | dua obj | kap/tau | time (s)
----------------------------------------------------------------------------
0| inf inf nan -inf inf inf 5.44e-04
100| inf inf nan inf inf inf 2.12e-02
200| inf inf nan inf inf inf 3.80e-02
300| inf inf nan inf inf inf 5.84e-02
400| inf inf nan inf inf inf 7.50e-02
500| 1.22e-02 1.69e-02 1.65e-08 1.17e+04 1.17e+04 0.00e+00 9.32e-02
600| 9.81e-03 8.99e-03 5.34e-09 1.17e+04 1.17e+04 0.00e+00 1.10e-01
700| 6.54e-03 7.23e-03 2.95e-09 1.17e+04 1.17e+04 0.00e+00 1.26e-01
800| 4.44e-03 4.80e-03 1.04e-09 1.17e+04 1.17e+04 0.00e+00 1.43e-01
900| 3.59e-03 3.09e-03 2.61e-09 1.17e+04 1.17e+04 0.00e+00 1.60e-01
1000| 2.52e-03 2.45e-03 1.24e-09 1.17e+04 1.17e+04 0.00e+00 1.75e-01
1100| 1.69e-03 1.67e-03 1.06e-09 1.17e+04 1.17e+04 0.00e+00 1.90e-01
1200| 1.49e-03 1.18e-03 3.23e-10 1.17e+04 1.17e+04 0.00e+00 2.07e-01
1300| 1.04e-03 9.57e-04 4.27e-10 1.17e+04 1.17e+04 0.00e+00 2.22e-01
1400| 6.28e-04 7.16e-04 7.82e-11 1.17e+04 1.17e+04 0.00e+00 2.38e-01
1500| 8.12e-04 4.52e-04 3.11e-10 1.17e+04 1.17e+04 0.00e+00 2.56e-01
1600| 3.83e-04 4.25e-04 7.66e-11 1.17e+04 1.17e+04 0.00e+00 2.71e-01
1700| 3.94e-04 3.07e-04 1.33e-10 1.17e+04 1.17e+04 0.00e+00 2.86e-01
1800| 4.28e-04 2.02e-04 4.11e-11 1.17e+04 1.17e+04 0.00e+00 3.05e-01
1900| 1.67e-04 1.96e-04 7.63e-11 1.17e+04 1.17e+04 0.00e+00 3.21e-01
2000| 2.68e-04 1.27e-04 2.96e-11 1.17e+04 1.17e+04 0.00e+00 3.38e-01
2100| 2.04e-04 1.08e-04 2.65e-11 1.17e+04 1.17e+04 0.00e+00 3.57e-01
2200| 1.00e-04 9.33e-05 3.22e-12 1.17e+04 1.17e+04 0.00e+00 3.77e-01
2240| 8.15e-05 8.79e-05 1.91e-12 1.17e+04 1.17e+04 0.00e+00 3.83e-01
----------------------------------------------------------------------------
Status: Solved
Timing: Total solve time: 3.83e-01s
Lin-sys: nnz in L factor: 24213, avg solve time: 1.01e-04s
Cones: avg projection time: 3.89e-06s
----------------------------------------------------------------------------
Error metrics:
dist(s, K) = 1.3217e-14, dist(y, K*) = 0.0000e+00, s'y/m = 3.0304e-15
|Ax + s - b|_2 / (1 + |b|_2) = 8.1460e-05
|A'y + c|_2 / (1 + |c|_2) = 8.7927e-05
|c'x + b'y| / (1 + |c'x| + |b'y|) = 1.9135e-12
----------------------------------------------------------------------------
c'x = 11707.1375, -b'y = 11707.1375
============================================================================
Below is the output of running Convex on a 2-variable least-squares problem over the simplex, i.e.,
I'm not familiar enough with the internals of Convex.jl to know if the failure has something to do with the way the problem is reformulated, or if it's a numerical issue with SCS. In either case, the problem seems simple enough that it should be solvable.
Here is the code:
The data can be downloaded here.