MOSEK / Mosek.jl

Interface to the Mosek solver in Julia
MIT License
49 stars 28 forks source link

Mosek.jl fails JuMP nonlinear test #24

Closed ulfworsoe closed 9 years ago

ulfworsoe commented 9 years ago

Mosek reports "nonconvex problem" during first test in

JuMP/test/nonlinear.jl

Trace:

ERROR: Mosek.MosekError(1291,"The optimization problem is nonconvex.")
 in optimize at /home/ulfw/.julia/Mosek/src/msk_functions.jl:2498
 in optimize! at /home/ulfw/.julia/Mosek/src/MosekSolverInterface.jl:660
 in solvenlp at /home/ulfw/.julia/JuMP/src/nlp.jl:485
 in solve at /home/ulfw/.julia/JuMP/src/solvers.jl:6
 in anonymous at /home/ulfw/.julia/JuMP/test/nonlinear.jl:32
 in context at /home/ulfw/.julia/FactCheck/src/FactCheck.jl:282
 in anonymous at /home/ulfw/.julia/JuMP/test/nonlinear.jl:14
 in facts at /home/ulfw/.julia/FactCheck/src/FactCheck.jl:261
 in include at ./boot.jl:242
 in include_from_node1 at ./loading.jl:128
 in include at ./boot.jl:242
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:300
 in _start at ./client.jl:382
 in _start_3B_3993 at /usr/local/julia/bin/../lib/julia/sys.so
while loading /home/ulfw/.julia/JuMP/test/nonlinear.jl, in expression starting on line 12
while loading /home/ulfw/.julia/JuMP/test/runtests.jl, in expression starting on line 28
mlubin commented 9 years ago

That's most likely because we test with some nonconvex problems. We'll have to reorganize the tests a bit to only test Mosek on the convex problems. CC @IainNZ

IainNZ commented 9 years ago

None of the tests need to be nonconvex, so I'll probably just fix it that way

mlubin commented 9 years ago

Working on this now. Mosek seems to be returning MSK_SOL_STA_UNKNOWN for the following test problem:

using Mosek, JuMP
m = Model(solver=MosekSolver())
@defVar(m, 0.5 <= x <=  2)
@defVar(m, 0.0 <= y <= 30)
@setObjective(m, Min, (x+y)^2)
@addNLConstraint(m, x + y >= 1)
status = solve(m)
@show status

The iterations look fine though:

ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   2.8e+01  4.5e+00  1.0e+01  0.00e+00   6.250000000e+00   -3.250000000e+00  1.0e+00  0.01  
1   4.3e+00  6.9e-01  2.3e+00  -8.75e-01  1.427096107e+01   7.710997485e+00   1.8e-01  0.01  
2   2.0e+00  3.2e-01  2.7e+00  5.81e-01   3.847813553e+00   -6.300554270e+00  1.5e-01  0.01  
3   2.1e-02  3.3e-03  2.5e-01  5.24e-01   1.445683123e+00   3.260988886e-01   8.6e-03  0.01  
4   1.8e-03  2.9e-04  3.7e-02  9.95e-01   1.002343555e+00   8.424114144e-01   1.2e-03  0.01  
5   1.7e-05  2.7e-06  3.5e-04  1.00e+00   1.000381567e+00   9.988732098e-01   1.2e-05  0.01  
6   8.4e-08  1.3e-08  1.7e-06  1.00e+00   1.000001908e+00   9.999943477e-01   5.8e-08  0.01  
7   4.2e-10  6.7e-11  8.7e-09  1.00e+00   1.000000010e+00   9.999999717e-01   2.9e-10  0.01  
Interior-point optimizer terminated. Time: 0.01.
mlubin commented 9 years ago

@ulfworsoe, this test still seems to be failing. Any idea why the strange return status?

ulfworsoe commented 9 years ago

That looks a bit funny... From the log it looks like the status should be at least NEAR_OPTIMAL. Do you have the return value from Mosek.optimize()?

mlubin commented 9 years ago

I added some debugging statements to Mosek.jl:

optimize(m.task) => 0
soldef => 2
prosta => 0
solsta => 0
ulfworsoe commented 9 years ago

I cannot rule out that it is a bug in the solver that sets a wrong status. I will try to debug it.

mlubin commented 9 years ago

It could also be a bug in the NLP wrapper I wrote.

ulfworsoe commented 9 years ago

A very quick test: If I insert

  solutionsummary(task_,MSK_STREAM_LOG)
  println(getsolsta(task_,MSK_SOL_ITR))

in the Mosek.optimize() function, immediately after the native function has been called, I can see that the interior-point solution is optimal, and that solution status for MSK_SOL_ITR is 1 (optimal). Is it possible that you accidentally modify the task so the status changes after optimize()?

ulfworsoe commented 9 years ago

It looks like you ask for the integer solution, MSK_SOL_ITG, rather than the interior, MSK_SOL_ITR.

mlubin commented 9 years ago

Right, getsoldef is returning MSK_SOL_ITG:

solutiondef(m.task,MSK_SOL_ITG) => true
solutiondef(m.task,MSK_SOL_BAS) => true
solutiondef(m.task,MSK_SOL_ITR) => true
ulfworsoe commented 9 years ago

Yes, I can see that. I am not sure where those solutions come from... Do you at any point input an initial solution or somthing like that?

mlubin commented 9 years ago

Yes, JuMP always gives a starting point: https://github.com/JuliaOpt/Mosek.jl/blob/master/src/MosekSolverInterface.jl#L719 It looks like this logic needs to be tweaked?

ulfworsoe commented 9 years ago

You could check if solution is defined and not unknown, perhaps? Problem is that MOSEK will not delete an inputted solution.