# Solver does not return solution with ALMOST\_OPTIMAL status

**URL:** https://discourse.julialang.org/t/solver-does-not-return-solution-with-almost-optimal-status/126280
**Category:** Optimization (Mathematical)
**Tags:** question, jump
**Created:** [February 25, 2025, 9:21am UTC](https://discourse.julialang.org/t/solver-does-not-return-solution-with-almost-optimal-status/126280 "2025-02-25T09:21:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![priantop](https://avatars.discourse-cdn.com/v4/letter/p/e47774/32.png) [@priantop](https://discourse.julialang.org/u/priantop)
#### Post date: [February 25, 2025, 9:21am UTC](https://discourse.julialang.org/t/solver-does-not-return-solution-with-almost-optimal-status/126280/1 "2025-02-25T09:21:53Z")

</div>

Hi,

I am running a large LP model using COPT solver ([COPT.jl](https://github.com/COPT-Public/COPT.jl))  
where the termination status is IMPRECISE, below is the log snippet

```julia
Using Cardinal Optimizer v7.2.4 on Windows
Hardware has 32 cores and 64 threads. Using instruction set X86_NATIVE (1)
Minimizing an LP problem

The original problem has:
    110698176 rows, 60517201 columns and 358904946 non-zero elements
The presolved problem has:
    26450603 rows, 65175827 columns and 179126383 non-zero elements

Starting barrier solver using 32 threads

Problem info:
Dualized in presolve: Yes
Range of matrix coefficients: [9e-03,2e+02]
Range of rhs coefficients: [1e-02,8e+05]
Range of bound coefficients: [3e+00,1e+02]
Range of cost coefficients: [1e-03,2e+06]

Factor info:
Number of free columns: 4905282
Number of dense columns: 7
Number of matrix entries: 1.999e+08
Number of factor entries: 7.165e+09
Number of factor flops: 2.660e+13

Iter Primal.Obj Dual.Obj Compl Primal.Inf Dual.Inf Time
   0 +1.78101669e+12 -2.29757821e+09 4.06e+13 9.03e+07 5.99e+02 1093s
.
.
.
 557 -4.00115605e+09 -4.00115804e+09 2.79e+03 2.17e-03 3.24e-05 77954s

Barrier status: IMPRECISE
Primal objective: -4.00115605e+09
Dual objective: -4.00115804e+09
Duality gap (abs/rel): 2.00e+03 / 4.99e-07
Primal infeasibility (abs/rel): 2.17e-03 / 2.61e-09
Dual infeasibility (abs/rel): 3.24e-05 / 1.62e-11

Solving finished
Status: Imprecise Objective: 0.0000000000e+00 Iterations: 0 Time: 77975.05s

```

when I tried querying the objective or any variable, it returns out of bounds error

```julia
julia> objective_value(m.model)
ERROR: Result index of attribute MathOptInterface.ObjectiveValue(1) out of bounds. There are currently 0 solution(s) in the model.

julia> value(m.model[:total_cost])
ERROR: Result index of attribute MathOptInterface.VariablePrimal(1) out of bounds. There are currently 0 solution(s) in the model.

```

as for the solution status and summary

```julia
julia> termination_status(m.model)
ALMOST_OPTIMAL::TerminationStatusCode = 7

julia> solution_summary(m.model; verbose=true)
* Solver : COPT

* Status
  Result count : 0
  Termination status : ALMOST_OPTIMAL
  Message from the solver:
  "The LP problem is solved to optimality with relaxed tolerances."

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

* Work counters
  Solve time (sec) : 7.79827e+04
  Simplex iterations : 0
  Barrier iterations : 557
  Node count : 0

```

Is this solver or solution-status related?  
I would expect that since the solver found a “close enough” solution, the solver could produce a solution candidate, but that is not case

Perhaps any other way to force JuMP/solver to use the “close enough” solution?

Thanks!

---

<div class="post-metadata">

### Author: ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)
#### Post date: [February 25, 2025, 12:11pm UTC](https://discourse.julialang.org/t/solver-does-not-return-solution-with-almost-optimal-status/126280/2 "2025-02-25T12:11:32Z")

</div>

The `Result count` in JuMP is zero. It does not see a solution and therefore you cannot query one. You could try adjusting the [feasiblity tolerance](https://guide.coap.online/copt/en-doc/parameter.html) of the solver.

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [February 25, 2025, 7:35pm UTC](https://discourse.julialang.org/t/solver-does-not-return-solution-with-almost-optimal-status/126280/3 "2025-02-25T19:35:41Z")

</div>

Based on the code in COPT.jl, it looks like this is a property of the solver:

> <https://github.com/COPT-Public/COPT.jl/blob/fd4de57281552bfd87808a422ee246ca667bfbdc/src/MOI/MOI_wrapper.jl#L3072-L3076>

They will return a solution only if `HasLpSol` is true. Since the solution is imprecise, I assume they have decided not to return a solution to the user.

---

<div class="post-metadata">

### Author: ![priantop](https://avatars.discourse-cdn.com/v4/letter/p/e47774/32.png) [@priantop](https://discourse.julialang.org/u/priantop)
#### Post date: [February 27, 2025, 9:53am UTC](https://discourse.julialang.org/t/solver-does-not-return-solution-with-almost-optimal-status/126280/4 "2025-02-27T09:53:13Z")

</div>

Aha okay!  
Thanks very much!

Since the solver terminated while the gap is 2e3 (lower than the feasibility tolerance), the solver returns nothing
