# Bonmin + HSL?

**URL:** <https://discourse.julialang.org/t/bonmin-hsl/63338>\
**Category:** Optimization (Mathematical)\
**Created:** [June 21, 2021, 11:17pm UTC](https://discourse.julialang.org/t/bonmin-hsl/63338 "2021-06-21T23:17:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)\
**Post date:** [June 21, 2021, 11:17pm UTC](https://discourse.julialang.org/t/bonmin-hsl/63338/1 "2021-06-21T23:17:28Z")

</div>

Hi everyone,

I’m trying to use the Bonmin solver with IPOPT+HSL. Can you take a look at the following example and let me know if there is anything that should be fixed? It works fine if I delete the _linear\_solver option_ and _Ipopt+HSL_ works just fine as well.

```julia
using JuMP, Ipopt
using AmplNLWriter, Bonmin_jll
m = Model(() -> AmplNLWriter.Optimizer(Bonmin_jll.amplexe))

set_optimizer_attribute(m, "bonmin.nlp_solver", "Ipopt")
set_optimizer_attribute(m, "linear_solver", "ma86")

@variable(m, x <= 5)
@variable(m, y <= 45)

@objective(m, Max, x + y)
JuMP.optimize!(m)
termination_status(m)

```

Any advice would be appreciated. Thank you.

---

<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:** [June 22, 2021, 12:07am UTC](https://discourse.julialang.org/t/bonmin-hsl/63338/2 "2021-06-22T00:07:58Z")

</div>

I haven’t tried using HSL through Bonmin\_jll.

What’s the error? What happens if you use a `.opt` file?

---

<div class="post-metadata">

**Author:** ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)\
**Post date:** [June 22, 2021, 2:27pm UTC](https://discourse.julialang.org/t/bonmin-hsl/63338/3 "2021-06-22T14:27:00Z")

</div>

Hi, I tested with `bonmin.opt` and it gives me the same error:

```julia
Bonmin 1.8.8 using Cbc 2.10.5 and Ipopt 3.13.4
bonmin: 
Cbc3007W No integer variables - nothing to do
Exception of type: OPTION_INVALID in file "IpAlgBuilder.cpp" at line 349:
 Exception message: Selected linear solver HSL_MA86 not available.
Tried to obtain HSL_MA86 from shared library "libhsl.dylib", but the following error occured:
dlopen(libhsl.dylib, 2): Symbol not found: __gfortran_os_error_at
  Referenced from: /usr/local/lib//libhsl.dylib
  Expected in: flat namespace
 in /usr/local/lib//libhsl.dylib

        "Aborted"
A failure has occured but no starting point exists
Ipopt exited with error code -12 Invalid option
OTHER_ERROR::TerminationStatusCode = 24

```

while the following Ipopt + HSL example works fine

```julia
using JuMP, Ipopt
m = Model(Ipopt.Optimizer)
set_optimizer_attribute(m, "linear_solver", "ma86")
@variable(m, x <= 5)
@variable(m, y <= 45)
@objective(m, Max, x + y)
JuMP.optimize!(m)

```

then I get

```julia
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit https://github.com/coin-or/Ipopt
******************************************************************************

This is Ipopt version 3.13.4, running with linear solver ma86.

Number of nonzeros in equality constraint Jacobian...: 0
Number of nonzeros in inequality constraint Jacobian.: 0
Number of nonzeros in Lagrangian Hessian.............: 0

[...]

Total CPU secs in IPOPT (w/o function evaluations) = 0.297
Total CPU secs in NLP function evaluations = 0.039

EXIT: Optimal Solution Found.

```

---

<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:** [June 22, 2021, 8:28pm UTC](https://discourse.julialang.org/t/bonmin-hsl/63338/4 "2021-06-22T20:28:08Z")

</div>

This works for me on Mac (I tweaked the example to check that the integers were being handled correctly, and to ensure that Ipopt was needed to solve it, not just Cbc):

```Julia
julia> using JuMP, AmplNLWriter, Bonmin_jll

julia> model = Model() do
           AmplNLWriter.Optimizer(Bonmin_jll.amplexe)
       end
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: AmplNLWriter

julia> set_optimizer_attribute(model, "bonmin.nlp_solver", "Ipopt")
"Ipopt"

julia> set_optimizer_attribute(model, "linear_solver", "ma86")
"ma86"

julia> @variable(model, x <= 5.4, Int)
x

julia> @variable(model, y <= 45)
y

julia> @NLobjective(model, Max, x - (x + y)^2)

julia> optimize!(model)
Bonmin 1.8.8 using Cbc 2.10.5 and Ipopt 3.13.4
bonmin: linear_solver=ma86
bonmin.nlp_solver=Ipopt

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit https://github.com/coin-or/Ipopt
******************************************************************************

NLP0012I 
              Num Status Obj It time Location
NLP0014I 1 OPT -5.4000001 5 0.007621
NLP0014I 2 OPT -5 4 0.005226
NLP0014I 3 INFEAS -5 0 0
NLP0014I * 1 INFEAS -5 0 0 resolve robustness
NLP0014I 5 OPT -5 3 0.004068
NLP0012I 
              Num Status Obj It time Location
NLP0014I 1 OPT -5 8 0.00947
Cbc0004I Integer solution of -5 found after 3 iterations and 0 nodes (0.02 seconds)
Cbc0001I Search completed - best objective -5, took 3 iterations and 0 nodes (0.02 seconds)
Cbc0032I Strong branching done 1 times (4 iterations), fathomed 0 nodes and fixed 1 variables
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost

 	"Finished"

```

## Questions

- What’s your `versioninfo()`?
- Did you follow these instructions? [GitHub - jump-dev/Ipopt.jl: A Julia interface to the Ipopt nonlinear solver](https://github.com/jump-dev/Ipopt.jl#hsl-ma27-ma86-ma97)
- How did you compile ma86? Looks like there is a mismatch with the gfortran version.

---

<div class="post-metadata">

**Author:** ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)\
**Post date:** [June 22, 2021, 9:13pm UTC](https://discourse.julialang.org/t/bonmin-hsl/63338/5 "2021-06-22T21:13:49Z")

</div>

@odow Thank you for your comments and help.

Yes, I followed the instructions there and here’s my version info:

```julia
julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 

```

I found two leads that might have something to do with this:

1. This happens on VS code - Julia REPL & VS code - terminal, but not on iTerm (terminal).  
When I ran the toy code on iTerm, it worked.
2. In my error message, the directory has two slashes after `/usr/local/lib`

```julia
dlopen(libhsl.dylib, 2): Symbol not found: __gfortran_os_error_at
  Referenced from: /usr/local/lib//libhsl.dylib
  Expected in: flat namespace
 in /usr/local/lib//libhsl.dylib

```

---

<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:** [June 22, 2021, 9:41pm UTC](https://discourse.julialang.org/t/bonmin-hsl/63338/6 "2021-06-22T21:41:11Z")

</div>

Try updating Ipopt (`] up Ipopt`) then restart Julia. (Or, just don’t go `using Ipopt` in your code.)

I released a new version a few days ago because it was doing some funky stuff with the `LD_LIBRARY_PATH`: [GitHub - jump-dev/Ipopt.jl: Julia interface to the Ipopt nonlinear solver](https://github.com/jump-dev/Ipopt.jl#readme).

---

<div class="post-metadata">

**Author:** ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)\
**Post date:** [June 22, 2021, 10:58pm UTC](https://discourse.julialang.org/t/bonmin-hsl/63338/7 "2021-06-22T22:58:25Z")

</div>

Oh, my bad. I should’ve checked the updates first. It works well with the updated version. Thank you so much!

---

<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:** [June 22, 2021, 11:01pm UTC](https://discourse.julialang.org/t/bonmin-hsl/63338/8 "2021-06-22T23:01:35Z")

</div>

Great! Modulo the update, I’m very pleased Bonmin is easy to use from JuMP and getting some use!

---

<div class="post-metadata">

**Author:** ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)\
**Post date:** [June 22, 2021, 11:20pm UTC](https://discourse.julialang.org/t/bonmin-hsl/63338/9 "2021-06-22T23:20:21Z")

</div>

Yes, I should do that. It’s amazing to be able to switch among different solvers while using extremely intuitive JuMP syntax. Thank you for the great work!
