# Which solver/model library can be used recursively / reentrantly

**URL:** <https://discourse.julialang.org/t/which-solver-model-library-can-be-used-recursively-reentrantly/51294>\
**Category:** Optimization (Mathematical)\
**Tags:** question, package, jump\
**Created:** [December 5, 2020, 11:47am UTC](https://discourse.julialang.org/t/which-solver-model-library-can-be-used-recursively-reentrantly/51294 "2020-12-05T11:47:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xyz1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xyz1/32/19984_2.png) [@xyz1](https://discourse.julialang.org/u/xyz1)\
**Post date:** [December 5, 2020, 11:47am UTC](https://discourse.julialang.org/t/which-solver-model-library-can-be-used-recursively-reentrantly/51294/1 "2020-12-05T11:47:32Z")

</div>

Hello, my code currently consists of a recursive function _f_ and I am planning on using an optimization solver (global optimization for integer programming with binary variables) for solving a sub-problem of the function _f_.

Because the function is recursive in nature and also designed so that it is expected to be run concurrently multiple-times independently by separate thraeds, my question is whether it is possible to use a solver inside that function and if then what library would you recommend.

The actual implementation consist of _f_ that has inside a minimalization of recursively called _f_ (which contains other minimalization problem in itself). It is not very deep recursion and the minimalization acts only on not-too-many variables. I’ve read somewhere that e.g. GLPK does not support re-entrancy so is there any way in Julia to do this?

---

<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 6, 2020, 12:34am UTC](https://discourse.julialang.org/t/which-solver-model-library-can-be-used-recursively-reentrantly/51294/2 "2020-12-06T00:34:34Z")

</div>

Hi there! Since this is your first time posting, take a moment to read to suggestions at: [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757)

In particular, it’s easier to provide an answer if you can make your question more concrete, e.g., by supplying a minimal example of the code you have tried, or an implementation of a toy model.

You can also use the search feature of discourse to look for similar questions.

For example, there might be some issues with `@theads` and the solvers:

> [@Multithreading unstable with JuMP](https://discourse.julialang.org/t/multithreading-unstable-with-jump/49494/16):
>
> I have tested your suggestion of making the variable assignment inside the loop local. On another model with actual data this gives incorrect results. If a race condition arises then use of local may be not be a good idea. It may have worked for your specific case, but in the MWE above it is mixing up something. Locks can be used in a race condition, but this tend to slowdown the program. If possible, I would prefer to code it in a way that race condition is avoided. I also got into problem wit…

There is also this post on StackOverflow:

> <https://stackoverflow.com/questions/64177415/create-jump-model-with-multi-threading-in-julia>

---

<div class="post-metadata">

**Author:** ![xyz1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xyz1/32/19984_2.png) [@xyz1](https://discourse.julialang.org/u/xyz1)\
**Post date:** [December 9, 2020, 8:47pm UTC](https://discourse.julialang.org/t/which-solver-model-library-can-be-used-recursively-reentrantly/51294/3 "2020-12-09T20:47:48Z")

</div>

Thank you for your help and time. I figured out there is a way how to rewrite it differently and more easily which makes this question pointless.
