# Trust-region constrained optimization

**URL:** <https://discourse.julialang.org/t/trust-region-constrained-optimization/93077>\
**Category:** Optimization (Mathematical)\
**Created:** [January 17, 2023, 9:10am UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077 "2023-01-17T09:10:18Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![cvanaret](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cvanaret/32/11594_2.png) [@cvanaret](https://discourse.julialang.org/u/cvanaret)\
**Post date:** [January 19, 2023, 4:08pm UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/21 "2023-01-19T16:08:40Z")

</div>

Wild guess, but the three extra variables could be slack variables that transform inequality constraints into equalities.

---

<div class="post-metadata">

**Author:** ![tmigot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tmigot/32/23914_2.png) [@tmigot](https://discourse.julialang.org/u/tmigot)\
**Post date:** [January 19, 2023, 4:56pm UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/22 "2023-01-19T16:56:00Z")

</div>

Hi @shce !

_What are those three zero components at the end of x?_  
As @cvanaret guessed, Percival.jl is actually adding slack variables to your inequality constraints before solving, which explains why the dimension is augmented.

_Why is the last component of the initial condition not present in the vector?_  
Well spotted, that was a bug, I think if you update your packages now, this should be fixed.

_Moreover, when I try to specifically set the initial guess with the `x=x0` keyword argument_  
Again well spotted, Percival was expecting a vector of the new size (with slack variables there). I will try to fix this for the next release (the main branch should work though).

---

<div class="post-metadata">

**Author:** ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)\
**Post date:** [January 19, 2023, 5:34pm UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/23 "2023-01-19T17:34:27Z")

</div>

It does works now! 🥳 I mark your previous answer as the solution.

Thank you very much for your quick replies and fixes.

If anyone thinks there is a better approach to what I want to accomplish, feel free to reply (even it is already solved) or contact me privately.

---

<div class="post-metadata">

**Author:** ![cvanaret](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cvanaret/32/11594_2.png) [@cvanaret](https://discourse.julialang.org/u/cvanaret)\
**Post date:** [January 20, 2023, 9:45am UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/24 "2023-01-20T09:45:11Z")

</div>

I would have been curious to see how Percival compares to [filterSQP](https://neos-server.org/neos/solvers/nco:filter/AMPL.html), a state-of-the-art trust-region filter SQP method. I don’t think there’s a Julia binding though.

---

<div class="post-metadata">

**Author:** ![fastwave](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fastwave/32/14725_2.png) [@fastwave](https://discourse.julialang.org/u/fastwave)\
**Post date:** [January 20, 2023, 11:14am UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/25 "2023-01-20T11:14:14Z")

</div>

If the constraint defines a differentiable manifold, then I would use Manopt.jl . Obviously it does not allow inequality constraints. I find that understanding the manifold structure of the constraint has a huge advantage for efficiency.

---

<div class="post-metadata">

**Author:** ![pjssilva](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pjssilva/32/4238_2.png) [@pjssilva](https://discourse.julialang.org/u/pjssilva)\
**Post date:** [January 20, 2023, 1:03pm UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/26 "2023-01-20T13:03:11Z")

</div>

Hi, if you need any help with NLPModelsAlgencan.jl, please let me know. It should work well with NLPModels and with JuMP using the NLPModelsJuMP.jl.

---

<div class="post-metadata">

**Author:** ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)\
**Post date:** [January 20, 2023, 3:04pm UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/27 "2023-01-20T15:04:06Z")

</div>

Hi @pjssilva , where can I find a more detailed description of GENCAN (both the optimization method and the package)?

---

<div class="post-metadata">

**Author:** ![cgeoga](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cgeoga/32/216186_2.png) [@cgeoga](https://discourse.julialang.org/u/cgeoga)\
**Post date:** [January 20, 2023, 3:24pm UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/28 "2023-01-20T15:24:14Z")

</div>

I’m surprised this hasn’t been mentioned yet, but Artelys KNITRO ([GitHub - jump-dev/KNITRO.jl: Julia interface to the Artelys Knitro solver](https://github.com/jump-dev/KNITRO.jl)) handles whatever nonlinear constraints you want. It has several trust region algorithms to choose from. I solve low-dimensional but ugly problems and algorithm 4 has a special place in my heart. It also has a lot of tools for pre-solving certain parts of your problem, and so the JuMP wrapper I’ve linked above would be a great option because JuMP is smart enough to identify quadratic expressions in your objective and stuff as well, so you could quite easily exploit all these fancy options.

Even the academic licenses are pretty expensive (although people pay much more for MATLAB Without blinking…), but if 300 unknowns is enough for you then there is a six month trial you could use.

---

<div class="post-metadata">

**Author:** ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)\
**Post date:** [January 20, 2023, 3:52pm UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/29 "2023-01-20T15:52:25Z")

</div>

I’m not sure if I’m able to use commercial code in this project (I would need to check), but I will definitely give it a try for my personal projects and prototyping. Thank you very much

---

<div class="post-metadata">

**Author:** ![pjssilva](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pjssilva/32/4238_2.png) [@pjssilva](https://discourse.julialang.org/u/pjssilva)\
**Post date:** [January 20, 2023, 3:58pm UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/30 "2023-01-20T15:58:42Z")

</div>

The main references for GENCAN are:

E. G. Birgin and J. M. Martínez, A box-constrained optimization algorithm with negative  
curvature directions and spectral projected gradients, Computing [Suppl] 15, pp. 49–60, 2001.

E. G. Birgin and J. M. Mart´ınez, Large-scale active-set box-constrained optimization method  
with spectral projected gradients, Computational Optimization and Applications 23, pp. 101–  
125, 2002.

M. Andretta, E. G. Birgin and J. M. Martínez, Practical active-set Euclidian trust-region  
method with spectral projected gradients for bound-constrained minimization, Optimization  
54, pp. 305–325, 2005.

GENCAN is now part of Algencan and it is called by it if the problem only has bound constraints. It is also used by Algencan to solve the inner subproblems in an Augmented Lagrangian method when solving problems with general constraints.

The website for the original Algencan library that we wrap in NLPModelsAlgencan.jl is

[https://www.ime.usp.br/~egbirgin/tango/codes.php#algencan](https://www.ime.usp.br/~egbirgin/tango/codes.php#algencan)

Best,

Paulo

---

<div class="post-metadata">

**Author:** ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)\
**Post date:** [January 20, 2023, 4:32pm UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/31 "2023-01-20T16:32:37Z")

</div>

Thank you very much. I was struggling with finding the documentation of the package. It turns out it is available in the directory: [NLPModelsAlgencan.jl/docs/src at master · pjssilva/NLPModelsAlgencan.jl · GitHub](https://github.com/pjssilva/NLPModelsAlgencan.jl/tree/master/docs/src)

Have you considered including it in a wiki?

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [January 20, 2023, 5:39pm UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/32 "2023-01-20T17:39:04Z")

</div>

> [@shce](#):
>
> Have you considered including it in a wiki?

I guess the link is: [Home · NLPModelsAlgencan.jl](https://pjssilva.github.io/NLPModelsAlgencan.jl/dev/)

A link to it in README.md file is missing, though, @pjssilva.

---

<div class="post-metadata">

**Author:** ![pjssilva](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pjssilva/32/4238_2.png) [@pjssilva](https://discourse.julialang.org/u/pjssilva)\
**Post date:** [January 21, 2023, 8:14pm UTC](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077/33 "2023-01-21T20:14:33Z")

</div>

Just added a simple docs badge. Thanks.

[Previous page](https://discourse.julialang.org/t/trust-region-constrained-optimization/93077.md?page=1)
