JuMP / CPLEX: solution_summary() seemingly returns something wrong

I am trying to do some copositivity detection using a MILP with which I find an optimal solution as expected. However, solution_summary() says that no solution exists. Here is an MWE:

using JuMP
using CPLEX

function mymain()
    # params
    n = 3
    Q = [1 -1 0; -1 1 1; 0 1 0]

    # model
    model = JuMP.direct_model( CPLEX.Optimizer() )
    @variable(model, x[i=1:n] >= 0)
    @variable(model, y[i=1:n], Bin)
    @variable(model, λ >= 0)
    @objective(model, Max, λ)
    @constraint( model, lambdaUB[i=1:n],  sum( Q[i,:][j] * x[j] for j in 1:n) <= -λ + 100 * (1-y[i]) )  
    @constraint( model, xUB[i=1:n], x[i] <= y[i])
    @constraint( model, lambdaLB, sum(y) >= 1)

    # solve
    optimize!(model)

    # solution summary
    println("termination status: ", termination_status(model))
    println("xvals: ", value.(x))
    println("yvals: ", value.(y))
    println("λ: ", value.(λ))
    solution_summary(model)     # returns CPLEX Error 1217: No solution exists.

    return
end
mymain()

with the output:

termination status: OPTIMAL
xvals: [0.0, 0.0, 0.0]
yvals: [1.0, 0.0, 0.0]
λ: 0.0
CPLEX Error  1217: No solution exists.
CPLEX Error  1217: No solution exists.

It took me some time to realize that the model works as expected given only the output from solution_summary(). Is the output of the latter function an expected result?

What happens if you return the solution summary so that it actually gets displayed?

So calling solution_summary(model) doesn’t actually do anything. You need display(solution_summary(model)) or to return it.

If changed your function to return the model. Then calling solution_summary(model) in the REPL gives:

julia> solution_summary(model)
CPLEX Error  1217: No solution exists.
CPLEX Error  1217: No solution exists.
* Solver : CPLEX

* Status
  Result count       : 1
  Termination status : OPTIMAL
  Message from the solver:
  "integer optimal solution"

* Candidate solution (result #1)
  Primal status      : FEASIBLE_POINT
  Dual status        : NO_SOLUTION
  Objective value    : 0.00000e+00
  Objective bound    : 0.00000e+00
  Relative gap       : 0.00000e+00
  Dual objective value : 0.00000e+00

* Work counters
  Solve time (sec)   : 7.25889e-03
  Simplex iterations : 0
  Barrier iterations : 0
  Node count         : 0

The errors come from querying things like SimplexIterations:

julia> MOI.get(backend(model), MOI.SimplexIterations())
CPLEX Error 1217: No solution exists.
0

where CPLEX says “I didn’t solve it with simplex.”

There is very little we can do to filter the error messages:

julia> cpx = unsafe_backend(model)
Ptr{Nothing} @0x00007f812b69ec50

julia> CPXgetitcnt(cpx.env, cpx.lp)
CPLEX Error 1217: No solution exists.
0

So I’m not sure if this is fixable.

1 Like