# Getting output after solver timeout reached

**URL:** <https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324>\
**Category:** Optimization (Mathematical)\
**Tags:** optimization, couenne\
**Created:** [May 19, 2022, 6:57pm UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324 "2022-05-19T18:57:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Viktor\_Pavlovic](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/viktor_pavlovic/32/36401_2.png) [@Viktor\_Pavlovic](https://discourse.julialang.org/u/Viktor_Pavlovic)\
**Post date:** [May 19, 2022, 6:57pm UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324/1 "2022-05-19T18:57:45Z")

</div>

Hello all, I have recently started using Couenne to solve MINLPs and have now encountered problems where I don’t obtain a solution in a reasonable amount of time. I am wondering if I can get set a time limit and obtain the best feasible solution for my problem. Right now if I set a time limit of say 10 minutes, when I try to access the values of the solution I get an error because the problem wasn’t solved globally in the time period.

When running the solver I see two things, first I see  
Couenne: new cutoff value 2.4950000000e+01

Then,  
Cbc0010I After 1600 nodes, 437 on tree, 1e+50 best solution, best possible 23.235597

At the end I see  
Lower bound: 23.2862  
Upper bound: 24.95 (gap: 6.85%)  
So the upper bound matches the cutoff value. Is there a way to get the values of the variables that would provide me the upper bound value? So that even if I timeout and don’t get the best answer I still have something.

Thanks

---

<div class="post-metadata">

**Author:** ![mtanneau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mtanneau/32/17787_2.png) [@mtanneau](https://discourse.julialang.org/u/mtanneau)\
**Post date:** [May 19, 2022, 10:07pm UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324/2 "2022-05-19T22:07:02Z")

</div>

Are you using Couenne through JuMP? If so, the [recommended way](https://jump.dev/JuMP.jl/stable/manual/solutions/#Recommended-workflow) to query solutions is to check that a primal solution indeed exists.

Normally, if a solver has found a feasible solution (even if it was not able to prove global optimality), it _should_ let you query it. In your case, you want to check that `primal_status(model) == FEASIBLE_POINT`.

If, for some reason, the solver log suggests that a feasible solution has been found, but the above check fails, there may be an issue in either Couenne itself or its wrapper.

Can you provide a reproducible example? (you can have a look [here](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/) for guidelines on how to do that)

---

<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:** [May 19, 2022, 10:13pm UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324/3 "2022-05-19T22:13:24Z")

</div>

If you’re calling through AmplNLWriter, then it depends on whether Couenne writes a `.sol` file before existing, and what the contents of that are.

Can you post the results of calling `solution_summary` after `optimize!`? That should tell us what happened.

```julia
optimize!(model)
solution_summary(model)

```

---

<div class="post-metadata">

**Author:** ![u176875](https://avatars.discourse-cdn.com/v4/letter/u/5fc32e/32.png) [@u176875](https://discourse.julialang.org/u/u176875)\
**Post date:** [October 27, 2022, 4:21pm UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324/4 "2022-10-27T16:21:02Z")

</div>

Hi @odow: Can you please take a look at my Julia/JuMP - Couenne issue that I just posted in here?  
I was using AmplNLWriter. Thanks in advance.

> <https://stackoverflow.com/questions/74225064/julia-jump-couenne-how-to-get-intermediate-or-best-feasible-solutions-when-ti>

---

<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:** [October 27, 2022, 5:30pm UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324/5 "2022-10-27T17:30:11Z")

</div>

Di you have a reproducible example?

---

<div class="post-metadata">

**Author:** ![u176875](https://avatars.discourse-cdn.com/v4/letter/u/5fc32e/32.png) [@u176875](https://discourse.julialang.org/u/u176875)\
**Post date:** [October 28, 2022, 1:08am UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324/6 "2022-10-28T01:08:28Z")

</div>

Hi Oscar: Thank you for your reply to here and in stackoverflow. My code involves thousands of integer variables and loading external data. I will work on creating a small sample problem, reproducing this scenario.

---

<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:** [October 28, 2022, 1:26am UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324/7 "2022-10-28T01:26:03Z")

</div>

You could also use `JuMP.write_to_file(model, "problem.nl")` instead of `optimize!` and then upload that.

---

<div class="post-metadata">

**Author:** ![u176875](https://avatars.discourse-cdn.com/v4/letter/u/5fc32e/32.png) [@u176875](https://discourse.julialang.org/u/u176875)\
**Post date:** [October 31, 2022, 5:19pm UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324/8 "2022-10-31T17:19:20Z")

</div>

Hi Oscar @odow : I tried to put the nl file here. But the size (44381 lines) exceeds the limit on # of characters allowed. How to upload the nl file? I am going to reduce the problem size and give you a small-size example.

---

<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:** [October 31, 2022, 7:11pm UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324/9 "2022-10-31T19:11:02Z")

</div>

Can you open an issue here: [Issues · jump-dev/AmplNLWriter.jl · GitHub](https://github.com/jump-dev/AmplNLWriter.jl/issues)? GitHub let’s you upload text files as attachments.

---

<div class="post-metadata">

**Author:** ![u176875](https://avatars.discourse-cdn.com/v4/letter/u/5fc32e/32.png) [@u176875](https://discourse.julialang.org/u/u176875)\
**Post date:** [October 31, 2022, 8:03pm UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324/10 "2022-10-31T20:03:07Z")

</div>

Good idea. Sure. I am going there to create an issue ticket.

x-ref for future readers: [Julia/JuMP: Couenne primal\_status=FEASIBLE\_POINT, termination\_status=LOCALLY\_SOLVED but solutions are empty · Issue #160 · jump-dev/AmplNLWriter.jl · GitHub](https://github.com/jump-dev/AmplNLWriter.jl/issues/160)
