# How to use NLopt with juniper and Alpine

**URL:** https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857
**Category:** Optimization (Mathematical)
**Created:** [May 10, 2021, 7:53am UTC](https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857 "2021-05-10T07:53:21Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![manoj.centura](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manoj.centura/32/216443_2.png) [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)
#### Post date: [May 10, 2021, 7:53am UTC](https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857/1 "2021-05-10T07:53:21Z")

</div>

Hi,  
Can we use NLopt with juniper/Alpine or any other solver for solving MINLP?  
Thanks,  
Manoj

---

<div class="post-metadata">

### Author: ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)
#### Post date: [May 10, 2021, 7:56am UTC](https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857/2 "2021-05-10T07:56:57Z")

</div>

Yes in theory but my experience has been that an error is thrown sometimes when a node is infeasible in Juniper so it may need a try-catch somewhere.

---

<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 10, 2021, 7:57am UTC](https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857/3 "2021-05-10T07:57:54Z")

</div>

Why NLopt instead of Ipopt?

---

<div class="post-metadata">

### Author: ![manoj.centura](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manoj.centura/32/216443_2.png) [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)
#### Post date: [May 10, 2021, 8:15am UTC](https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857/4 "2021-05-10T08:15:39Z")

</div>

Ipopt is not generating a feasible solution after 3600 second with Juniper and alpine.

---

<div class="post-metadata">

### Author: ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)
#### Post date: [May 10, 2021, 8:19am UTC](https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857/5 "2021-05-10T08:19:35Z")

</div>

How expensive are your functions? Are you using second order Ipopt or first order?

---

<div class="post-metadata">

### Author: ![manoj.centura](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manoj.centura/32/216443_2.png) [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)
#### Post date: [May 10, 2021, 8:21am UTC](https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857/6 "2021-05-10T08:21:31Z")

</div>

I am defining model as  
```  
optimizer = Juniper.Optimizer  
nl\_solver = optimizer\_with\_attributes(NLopt.Optimizer, “algorithm” =\> 1)

mip\_solver = optimizer\_with\_attributes(Gurobi.Optimizer)  
model = Model(optimizer\_with\_attributes(optimizer, “nl\_solver”=\>nl\_solver, “mip\_solver”=\>mip\_solver ,“mip\_gap”=\>25))```

but getting error as  
ERROR: LoadError: UndefVarError: NLopt not defined  
Stacktrace:  
[1] maincalc() at D:\Received\_doc\From\_dhana\Dev julia projectdeflection\Bulk\_Sequencer\_latest\_05\_08\_2021.jl:1524  
[2] top-level scope at D:\Received\_doc\From\_dhana\Dev julia projectdeflection\Bulk\_Sequencer\_latest\_05\_08\_2021.jl:1637  
[3] top-level scope at util.jl:156  
in expression starting at D:\Received\_doc\From\_dhana\Dev julia projectdeflection\Bulk\_Sequencer\_latest\_05\_08\_2021.jl:1636

---

<div class="post-metadata">

### Author: ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)
#### Post date: [May 10, 2021, 8:21am UTC](https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857/7 "2021-05-10T08:21:50Z")

</div>

You may also want to experiment with the traversing strategy [Options · Juniper](https://lanl-ansi.github.io/Juniper.jl/stable/options/#traverse_strategy::Symbol-%5B:BFS%5D).

---

<div class="post-metadata">

### Author: ![manoj.centura](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manoj.centura/32/216443_2.png) [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)
#### Post date: [May 10, 2021, 8:24am UTC](https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857/8 "2021-05-10T08:24:05Z")

</div>

I am new to the field.  
my constraints are the order of 5. how to use ipot with second order and first?

---

<div class="post-metadata">

### Author: ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)
#### Post date: [May 10, 2021, 8:27am UTC](https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857/9 "2021-05-10T08:27:25Z")

</div>

You have to set the `hessian_approximation` option to `"exact"` for second order or `"limited-memory"` for first order. Are you sure your problem isn’t just infeasible?

---

<div class="post-metadata">

### Author: ![blegat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blegat/32/217090_2.png) [@blegat](https://discourse.julialang.org/u/blegat)
#### Post date: [May 10, 2021, 11:18am UTC](https://discourse.julialang.org/t/how-to-use-nlopt-with-juniper-and-alpine/60857/10 "2021-05-10T11:18:01Z")

</div>

> [@manoj.centura](#):
>
> ERROR: LoadError: UndefVarError: NLopt not defined

This error means that you are missing a line `using NLopt`
