# Tunneling algorithm?

**URL:** <https://discourse.julialang.org/t/tunneling-algorithm/23174>\
**Category:** General Usage\
**Tags:** optimization\
**Created:** [April 15, 2019, 9:17pm UTC](https://discourse.julialang.org/t/tunneling-algorithm/23174 "2019-04-15T21:17:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [April 15, 2019, 9:17pm UTC](https://discourse.julialang.org/t/tunneling-algorithm/23174/1 "2019-04-15T21:17:14Z")

</div>

Hi everybody, i’m looking for the existence of the implementation of a [tunneling algorithm](https://en.wikipedia.org/wiki/Stochastic_tunneling) in julia, or a wrapper to a solver that does that, any ideas?

---

<div class="post-metadata">

**Author:** ![aaowens](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aaowens/32/12101_2.png) [@aaowens](https://discourse.julialang.org/u/aaowens)\
**Post date:** [April 15, 2019, 9:24pm UTC](https://discourse.julialang.org/t/tunneling-algorithm/23174/2 "2019-04-15T21:24:47Z")

</div>

Maybe [https://github.com/robertfeldt/BlackBoxOptim.jl](https://github.com/robertfeldt/BlackBoxOptim.jl) has what you need?

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [April 15, 2019, 9:33pm UTC](https://discourse.julialang.org/t/tunneling-algorithm/23174/3 "2019-04-15T21:33:12Z")

</div>

i’m looking at it, i’m also looking at Optim.jl, as my function is differenciable

---

<div class="post-metadata">

**Author:** ![aaowens](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aaowens/32/12101_2.png) [@aaowens](https://discourse.julialang.org/u/aaowens)\
**Post date:** [April 15, 2019, 9:55pm UTC](https://discourse.julialang.org/t/tunneling-algorithm/23174/4 "2019-04-15T21:55:14Z")

</div>

The gradient based algorithms in Optim.jl find local minima, and I think you wanted a global optimization algorithm.

You could also look at [GitHub - JuliaOpt/NLopt.jl: Package to call the NLopt nonlinear-optimization library from the Julia language](https://github.com/JuliaOpt/NLopt.jl) . Some of its global optimization algorithms use the derivatives (Ex. [NLopt Algorithms - NLopt Documentation](https://nlopt.readthedocs.io/en/latest/NLopt_Algorithms/#stogo) )

---

<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:** [April 15, 2019, 10:19pm UTC](https://discourse.julialang.org/t/tunneling-algorithm/23174/5 "2019-04-15T22:19:32Z")

</div>

IIUC, this should be easy to implement in Turing.jl with a custom distribution that has a custom “logpdf” value.

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [April 16, 2019, 1:06am UTC](https://discourse.julialang.org/t/tunneling-algorithm/23174/6 "2019-04-16T01:06:31Z")

</div>

It’s weird to say this, but while the global optimization is my goal, I’m using that algorithm just as a starting point.to a bi level minimization algorithm in thermodynamics ([this paper](https://www.sciencedirect.com/science/article/pii/S0098135411002365)), but i will try all the available options mentioned in this post, thanks!

> [@aaowens](#):
>
> The gradient based algorithms in Optim.jl find local minima

the tunneling is to bypass those local minima, but maintaining the best solution. in theory, all phase equilibria can be resolved with a global optimization, but the calculations are too expensive

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 16, 2019, 6:32am UTC](https://discourse.julialang.org/t/tunneling-algorithm/23174/7 "2019-04-16T06:32:28Z")

</div>

What is the dimensionality of your problem? In practice, these algorithms run into all the usual problems with MCMC (tuning, O(n^2) performance degradation, etc). Which is not to say that they are not useful in some cases, but in practice they can be tricky.

> [@longemen3000](#):
>
> I’m using that algorithm just as a starting point.to a bi level minimization algorithm in thermodynamics

I did not look at the paper, but in general two-stage algorithms are usually less efficient than doing everything in a single pass.

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [April 16, 2019, 3:54pm UTC](https://discourse.julialang.org/t/tunneling-algorithm/23174/8 "2019-04-16T15:54:24Z")

</div>

the problem’s size are tipically small (2+Nspecies), where the amount of species can vary from one (pure compound) to 50 aprox (some oil mixtures). one problem is that the optimization procedure is just for one point (phase equilibria in that point) and there is a need to solve this problem multiple times with different parameters (Parametron.jl can be useful, i heard).  
Also, the equations are hard to evaluate.  
The mayority of phase equilibria solvers suppose ideality, so use other techniques, (inicialization using ideal gases, for example), but those fail at complicated points (like in Liquid-Liquid equilibria) and are limited to two specified phases (there are solvers for liquid-vapor and liquid-liquid, but you have to use those solvers knowing in advance what equilibrium phase you are expected to find).  
The magic of the solver of the paper is that is phase independent, so only the basic starting points (a pressure, a temperature and a vector of mole fractions) are necessary.  
The inicialization is to verify if the starting point is a stable phase, if the objective function in some moment is negative, then the routine starts adding addicional phases. if not, the phase is considered stable.  
In this post, however, a lot of options given can be alternatives to that inicialization phase, so i will try combinations of them to see what works best 😁
