# Help Couenne

**URL:** <https://discourse.julialang.org/t/help-couenne/16825>\
**Category:** Optimization (Mathematical)\
**Created:** [October 26, 2018, 2:21pm UTC](https://discourse.julialang.org/t/help-couenne/16825 "2018-10-26T14:21:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![muriloasouza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muriloasouza/32/4650_2.png) [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Post date:** [October 26, 2018, 2:21pm UTC](https://discourse.julialang.org/t/help-couenne/16825/1 "2018-10-26T14:21:30Z")

</div>

Hello, i’m using Couenne to solve a MINLP problem. It has been running for days now, and during this time, i keep getting messages like this:

```julia
Cbc0010I After 26300 nodes, 3934 on tree, 1e+050 best solution, best possible 1 (324734.74 seconds)
Cbc0010I After 26400 nodes, 3918 on tree, 1e+050 best solution, best possible 1.0000347 (325483.56 s
econds)
Optimality Based BT: 0 improved bounds
Optimality Based BT: 21 improved bounds
Cbc0010I After 26500 nodes, 3915 on tree, 1e+050 best solution, best possible 2 (369102.49 seconds)

```

In my problem, i’m trying to minimize this:

```julia
@variable(m, a[i=1:Nt], Bin)
@objective(m, Min, sum(a[i] for i = 1:Nt))

```

Can anyone explain to me what does that mean? For example, in the first one, it has already solved 26300 problems in the BB tree? and what does 3934 on tree and 1e+050 means? Is the best value of my objective function found so far 1?

This makes sense to me, because i know that if any of those `a[i] = 1` i have a viable solution.

But as you can see, in the last message, the best possible is 2. How can this be?

---

<div class="post-metadata">

**Author:** ![muriloasouza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muriloasouza/32/4650_2.png) [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Post date:** [October 31, 2018, 11:15am UTC](https://discourse.julialang.org/t/help-couenne/16825/2 "2018-10-31T11:15:42Z")

</div>

I need to ask something else…

I’ve tested my code with 2 different obj functions.

For obj function 1: It runs for a long time and i got those messages i posted in the first topic. (It didn’t finished runnig, i had to stop the code);  
For obj function 2: It says my problem is infeasible.

How is this possible? doesn’t make sense to me.

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [October 31, 2018, 12:24pm UTC](https://discourse.julialang.org/t/help-couenne/16825/3 "2018-10-31T12:24:25Z")

</div>

Could you provide the full code?

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [October 31, 2018, 12:39pm UTC](https://discourse.julialang.org/t/help-couenne/16825/4 "2018-10-31T12:39:14Z")

</div>

The following works fine for me and solves in 0.000749s:

```julia
using JuMP
using CouenneNL

m = Model(solver=CouenneNLSolver())
Nt = 5
@variable(m, a[i=1:Nt], Bin)
@objective(m, Min, sum(a[i] for i = 1:Nt))
status = solve(m)
@assert status == :Optimal

```

This is on Julia 1.0.1. `toml` files here: [https://gist.github.com/tkoolen/5db3908615fbcd7e663d430f0d71176d](https://gist.github.com/tkoolen/5db3908615fbcd7e663d430f0d71176d).

---

<div class="post-metadata">

**Author:** ![muriloasouza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muriloasouza/32/4650_2.png) [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Post date:** [October 31, 2018, 2:17pm UTC](https://discourse.julialang.org/t/help-couenne/16825/5 "2018-10-31T14:17:19Z")

</div>

I could, but i would need to attach a function i made and some data i wrote in a .txt file too, so you could run the code. Anyway this can be done here?

Btw, the CouenneNLSolver is already updated to work in Julia 1.0.1? I remember it only used to work in Julia 0.6.

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [October 31, 2018, 3:28pm UTC](https://discourse.julialang.org/t/help-couenne/16825/6 "2018-10-31T15:28:58Z")

</div>

I’m using [GitHub - rdeits/CouenneNL.jl](https://github.com/rdeits/CouenneNL.jl) instead, which is just a thin wrapper around AmplNLWriter, doesn’t require you to build from source, and has been updated for 1.0.

`1e+050 best solution` really means that no feasible point has been found (there is no incumbent). `best possible 2` means that a lower bound on the objective value of 2 has been established by the solver (which does not necessarily require finding a feasible point).

> [@muriloasouza](#):
>
> I’ve tested my code with 2 different obj functions.
> 
> For obj function 1: It runs for a long time and i got those messages i posted in the first topic. (It didn’t finished runnig, i had to stop the code);  
> For obj function 2: It says my problem is infeasible.

Feasibility does not depend on the objective function, so if you’re getting infeasible back for one objective function there’s no sense in trying a different one.

Try removing some constraints and see which ones cause the problem to become infeasible. You also might want to try reducing the size of your problem as you’re debugging the formulation.

---

<div class="post-metadata">

**Author:** ![muriloasouza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muriloasouza/32/4650_2.png) [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Post date:** [October 31, 2018, 3:31pm UTC](https://discourse.julialang.org/t/help-couenne/16825/7 "2018-10-31T15:31:41Z")

</div>

Allright, thanks for the info! I’ll try to reduce the size of my problem to see if i can get it to work!

EDIT: Trying to install that to use in Julia 1.0.1, but i keep getting this error:

```julia
julia> Pkg.add("CouenneNL")
WARNING: Base.Pkg is deprecated, run `using Pkg` instead
 in module Main
  Updating registry at `C:\Users\Muril\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
ERROR: The following package names could not be resolved:
 * CouenneNL (not found in project, manifest or registry)
Please specify by known `name=uuid`.
Stacktrace:
 [1] pkgerror(::String) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\shar
e\julia\stdlib\v0.7\Pkg\src\Types.jl:120
 [2] #ensure_resolved#42(::Bool, ::Function, ::Pkg.Types.EnvCache, ::Array{Pkg.Types.PackageSpec,1})
 at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\Pkg
\src\Types.jl:890
 [3] #ensure_resolved at .\none:0 [inlined]
 [4] #add_or_develop#13(::Symbol, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{
(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at C:\cygwin\home\A
dministrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\Pkg\src\API.jl:59
 [5] #add_or_develop at .\none:0 [inlined]
 [6] #add_or_develop#12 at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\shar
e\julia\stdlib\v0.7\Pkg\src\API.jl:29 [inlined]
 [7] #add_or_develop at .\none:0 [inlined]
 [8] #add_or_develop#11(::Base.Iterators.Pairs{Symbol,Symbol,Tuple{Symbol},NamedTuple{(:mode,),Tuple
{Symbol}}}, ::Function, ::Array{String,1}) at C:\cygwin\home\Administrator\buildbot\worker\package_w
in64\build\usr\share\julia\stdlib\v0.7\Pkg\src\API.jl:28
 [9] add(::String) at .\none:0
 [10] top-level scope at none:0

```

---

<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, 2018, 9:02pm UTC](https://discourse.julialang.org/t/help-couenne/16825/8 "2018-10-31T21:02:38Z")

</div>

Follow the instructions at  
[https://github.com/rdeits/CouenneNL.jl#installation](https://github.com/rdeits/CouenneNL.jl#installation)

---

<div class="post-metadata">

**Author:** ![muriloasouza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muriloasouza/32/4650_2.png) [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Post date:** [November 14, 2018, 2:21pm UTC](https://discourse.julialang.org/t/help-couenne/16825/9 "2018-11-14T14:21:55Z")

</div>

Hello, i have reduced the size of my problem, and i finally got an answer (not a right answer, but i know why its wrong, and i’m trying to fix that). But it only works with these values:

```julia
hsmin = 3;
hsmax = 23;
@variable(m, hsmin <= hs[i=1:Nt] <= hsmax, Int)

```

I understand if i reduce the value of `hsmax`, i’m reducing the search space of my problem, and could make it infeasible (but from my experience, it shouldnt be infeasible anyway). I tried increasing it, and it gave me an infeasible result too.

`hsmax` can only accept odd values here, i tried from `5, 7, ..., 25, 27, 29`. And it only works if i use `23`.

Any ideas what could be causing this?

---

<div class="post-metadata">

**Author:** ![muriloasouza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muriloasouza/32/4650_2.png) [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Post date:** [November 19, 2018, 2:55pm UTC](https://discourse.julialang.org/t/help-couenne/16825/10 "2018-11-19T14:55:38Z")

</div>

Is there anyway i can stop Couenne and get in return the integer solution it found so far?

Since it started to get close to this solution, is starting to take so long to finish. For example, i got this:

```julia
Cbc0010I After 95800 nodes, 5974 on tree, 4.1972143 best solution, best possible 4.0000773 (5266.99
seconds)

```

and after a long time running…

```julia
Cbc0010I After 223400 nodes, 10717 on tree, 4.1972143 best solution, best possible 4.062431 (9952.79
 seconds)

```

I was thinking something like, if the integer solution found differs, say x%, from the best possible, i want to stop it and get the results. Or maybe a time limit after it has found an integer solution.

---

<div class="post-metadata">

**Author:** ![muriloasouza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muriloasouza/32/4650_2.png) [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Post date:** [December 5, 2018, 2:37pm UTC](https://discourse.julialang.org/t/help-couenne/16825/11 "2018-12-05T14:37:27Z")

</div>

Trying to use Couenne in Julia 1.0, and i’m getting this error:

```julia
[Info: Precompiling CouenneNL [5724587f-3074-5673-b62c-b97e3475008a]
ERROR: LoadError: syntax: extra token "MathProgBase" after end of expression
Stacktrace:
 [1] include at .\boot.jl:317 [inlined]
 [2] include_relative(::Module, ::String) at .\loading.jl:1041
 [3] include(::Module, ::String) at .\sysimg.jl:29
 [4] top-level scope at none:2
 [5] eval at .\boot.jl:319 [inlined]
 [6] eval(::Expr) at .\client.jl:389
 [7] top-level scope at .\none:3
in expression starting at C:\Users\Muril\.julia\dev\CouenneNL\src\CouenneNL.jl:11
ERROR: LoadError: Failed to precompile CouenneNL [5724587f-3074-5673-b62c-b97e3475008a] to C:\Users\
Muril\.julia\compiled\v1.0\CouenneNL\3v98H.ji.
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] macro expansion at .\logging.jl:313 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at .\loading.jl:1187
 [4] macro expansion at .\logging.jl:311 [inlined]
 [5] _require(::Base.PkgId) at .\loading.jl:944
 [6] require(::Base.PkgId) at .\loading.jl:855
 [7] macro expansion at .\logging.jl:311 [inlined]
 [8] require(::Module, ::Symbol) at .\loading.jl:837
 [9] include_string(::Module, ::String, ::String) at .\loading.jl:1005
 [10] (::getfield(Atom, Symbol("##123#127")){String,String,Module})() at C:\Users\Muril\.julia\packa
ges\Atom\Fha1N\src\eval.jl:120
 [11] withpath(::getfield(Atom, Symbol("##123#127")){String,String,Module}, ::String) at C:\Users\Mu
ril\.julia\packages\CodeTools\hB4Hy\src\utils.jl:30
 [12] withpath at C:\Users\Muril\.julia\packages\Atom\Fha1N\src\eval.jl:46 [inlined]
 [13] #122 at C:\Users\Muril\.julia\packages\Atom\Fha1N\src\eval.jl:117 [inlined]
 [14] hideprompt(::getfield(Atom, Symbol("##122#126")){String,String,Module}) at C:\Users\Muril\.jul
ia\packages\Atom\Fha1N\src\repl.jl:84
 [15] macro expansion at C:\Users\Muril\.julia\packages\Atom\Fha1N\src\eval.jl:116 [inlined]
 [16] macro expansion at C:\Users\Muril\.julia\packages\Media\ItEPc\src\dynamic.jl:24 [inlined]
 [17] (::getfield(Atom, Symbol("##121#125")))(::Dict{String,Any}) at C:\Users\Muril\.julia\packages\
Atom\Fha1N\src\eval.jl:105
 [18] handlemsg(::Dict{String,Any}, ::Dict{String,Any}) at C:\Users\Muril\.julia\packages\Atom\Fha1N
\src\comm.jl:168
 [19] (::getfield(Atom, Symbol("##22#25")){Array{Any,1}})() at .\task.jl:259
in expression starting at C:\Users\Muril\Desktop\Murilo\UFPE\Dissertação\Julia\Arquivos Feitos 1.0.1
\otimização_sistema_4_barras.jl:1

```

How can i fix it?

---

<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:** [December 5, 2018, 3:41pm UTC](https://discourse.julialang.org/t/help-couenne/16825/12 "2018-12-05T15:41:07Z")

</div>

Do you have the latest version? Run `] up CouenneNL`

---

<div class="post-metadata">

**Author:** ![muriloasouza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muriloasouza/32/4650_2.png) [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Post date:** [December 5, 2018, 3:50pm UTC](https://discourse.julialang.org/t/help-couenne/16825/13 "2018-12-05T15:50:31Z")

</div>

```julia
(v1.0) pkg> up Couenne
  Updating registry at `C:\Users\Muril\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
ERROR: The following package names could not be resolved:
 * Couenne (not found in project or manifest)
Please specify by known `name=uuid`.

```

I just followed the instructions in that link you provided (wich worked for Julia 0.6.3):

```julia
julia> Pkg.clone("https://github.com/rdeits/CouenneNL.jl")

julia> Pkg.build("CouenneNL")

```

---

<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:** [December 5, 2018, 4:09pm UTC](https://discourse.julialang.org/t/help-couenne/16825/14 "2018-12-05T16:09:41Z")

</div>

The package is called `CouenneNL` not `Couenne`.

---

<div class="post-metadata">

**Author:** ![muriloasouza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muriloasouza/32/4650_2.png) [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Post date:** [December 5, 2018, 4:12pm UTC](https://discourse.julialang.org/t/help-couenne/16825/15 "2018-12-05T16:12:31Z")

</div>

Sorry, my bad.

```julia
(v1.0) pkg> up CouenneNL
  Updating registry at `C:\Users\Muril\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
 Installed Widgets ─ v0.4.4
  Updating `C:\Users\Muril\.julia\environments\v1.0\Project.toml`
 [no changes]
  Updating `C:\Users\Muril\.julia\environments\v1.0\Manifest.toml`
  [cc8bc4a8] ↑ Widgets v0.4.3 ⇒ v0.4.4

```

The error persists. I can use Couenne in 0.6.3, but not in 1.0.

---

<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:** [December 5, 2018, 4:27pm UTC](https://discourse.julialang.org/t/help-couenne/16825/16 "2018-12-05T16:27:29Z")

</div>

I can’t reproduce this. Try  
`] rm CouenneNL`  
`] add https://github.com/rdeits/CouenneNL.jl`

---

<div class="post-metadata">

**Author:** ![muriloasouza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muriloasouza/32/4650_2.png) [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Post date:** [December 5, 2018, 4:53pm UTC](https://discourse.julialang.org/t/help-couenne/16825/17 "2018-12-05T16:53:24Z")

</div>

Ok, i think it worked now… but i’m getting this error:

```julia
ERROR: LoadError: UndefVarError: q not defined

```

Wich is really weird, because i don’t have any variable named `q`.

---

<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:** [December 5, 2018, 5:07pm UTC](https://discourse.julialang.org/t/help-couenne/16825/18 "2018-12-05T17:07:36Z")

</div>

Hmm, weird. Not sure. The `q` seems like it is an error in your code. Close Julia, open a new REPL, and then check that `using CouenneNL` works without error.

If you run into trouble, read [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757) and then post a minimum working example demonstrating the problem.

---

<div class="post-metadata">

**Author:** ![muriloasouza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muriloasouza/32/4650_2.png) [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Post date:** [December 10, 2018, 3:20pm UTC](https://discourse.julialang.org/t/help-couenne/16825/19 "2018-12-10T15:20:26Z")

</div>

Well, i just went back to 0.6.3, couldn’t make it work in 1.0. I’ll try again later when i have more free time.

I got a question about Couenne again… is there any chance the optimal solution it found, isn’t really the best solution at all? I ask this, because, in my problem, i know there is a better solution than the one Couenne is giving me. Has anyone experienced this kind of issue?

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [December 10, 2018, 4:59pm UTC](https://discourse.julialang.org/t/help-couenne/16825/20 "2018-12-10T16:59:34Z")

</div>

> [@muriloasouza](#):
>
> is there any chance the optimal solution it found, isn’t really the best solution at all?

Theoretically, no. In practice, there may be numerical issues that e.g. cause one of the lower-bound LPs to falsely claim infeasibility, causing the BnB algorithm to wrongly eliminate a part of the search space. Also, be sure to check that it’s not just due to the optimality gap tolerance you’re using.

[Next page](https://discourse.julialang.org/t/help-couenne/16825.md?page=2)
