# \#nlopt

**URL:** https://discourse.julialang.org/tag/nlopt/868.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Early optimizer termination](https://discourse.julialang.org/t/early-optimizer-termination/130710)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 6\
**Last updated:** [July 14, 2025, 9:16pm UTC](https://discourse.julialang.org/t/early-optimizer-termination/130710 "2025-07-14T21:16:07Z")

</div>

Hi I am using NLOP and MMA for optimization. The optimizer stops the optimization and reach the Xtol\_rel while I have large gradients which should make optimizer keep going. Could you please help me understand what is th…

---

## [Dual\_ftol\_rel keyword not allowed in Optimization.jl](https://discourse.julialang.org/t/dual-ftol-rel-keyword-not-allowed-in-optimization-jl/129480)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 1\
**Last updated:** [May 30, 2025, 5:58pm UTC](https://discourse.julialang.org/t/dual-ftol-rel-keyword-not-allowed-in-optimization-jl/129480 "2025-05-30T17:58:29Z")

</div>

Hi there, I’m trying out different solvers for my problem which requires evaluation of non-linear constraints. Currently I’m trying NLopt thought Optimization in particular LD\_CCSAQ solver. However, its taking forever a…

---

## [NLOPT constraint violation](https://discourse.julialang.org/t/nlopt-constraint-violation/128851)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 6\
**Last updated:** [May 24, 2025, 9:11pm UTC](https://discourse.julialang.org/t/nlopt-constraint-violation/128851 "2025-05-24T21:11:49Z")

</div>

Hi I am using NLOP for topology optimization. First I did the deterministic topology optimization with constraint on volume, Now I am adding another constraint. As I checked the values for constraint it seems that the d…

---

## [Equation constraints not working in NLopt](https://discourse.julialang.org/t/equation-constraints-not-working-in-nlopt/116883)

<div class="topic-metadata">

**Author:** [@dannygold](https://discourse.julialang.org/u/dannygold)\
**Replies:** 5\
**Last updated:** [July 16, 2024, 5:46pm UTC](https://discourse.julialang.org/t/equation-constraints-not-working-in-nlopt/116883 "2024-07-16T17:46:09Z")

</div>

I’m trying to optimize a likelihood function of three parameters (call them a, b, and c) using the NLopt package. Currently, I have the following: opt = Opt(:LN\_COBYLA, length(θ₀)) function c(result::Vector, x::Vector…

---

## [NLOPT forced stop with two constraints](https://discourse.julialang.org/t/nlopt-forced-stop-with-two-constraints/115371)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 3\
**Last updated:** [June 9, 2024, 12:06am UTC](https://discourse.julialang.org/t/nlopt-forced-stop-with-two-constraints/115371 "2024-06-09T00:06:51Z")

</div>

Hi I am using NLOPT with two inequality constraints. It can do the optmization when I suppress the second constraint but with two constraints it stops after 1st iteration with forced stop. I also run objective function …

---

## [NLopt Constraint](https://discourse.julialang.org/t/nlopt-constraint/114856)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 4\
**Last updated:** [May 28, 2024, 10:27pm UTC](https://discourse.julialang.org/t/nlopt-constraint/114856 "2024-05-28T22:27:28Z")

</div>

Hi, I am using Nlopt for optimization. my objective function depends on three variables like x1,x2,x3 also I have a constraint which depends on all three variable. I want to do the optimization just for x3 variable. shou…

---

## [Nlopt forced stop](https://discourse.julialang.org/t/nlopt-forced-stop/114727)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 2\
**Last updated:** [May 26, 2024, 1:05am UTC](https://discourse.julialang.org/t/nlopt-forced-stop/114727 "2024-05-26T01:05:00Z")

</div>

Hi, I am using Nlopt for a gradient based optimization. It stopes after 4 iterations and returns forced stop and the output is not converged. Could you please tell me how can I find the problem which makes optimizer to f…

---

## [How to get evaluation number in optimization using NLopt](https://discourse.julialang.org/t/how-to-get-evaluation-number-in-optimization-using-nlopt/114020)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 7\
**Last updated:** [May 8, 2024, 10:40pm UTC](https://discourse.julialang.org/t/how-to-get-evaluation-number-in-optimization-using-nlopt/114020 "2024-05-08T22:40:05Z")

</div>

Hi, I am using Nlopt to do the optimization. in this case i have defined a function for optimization. inside this function the optimizer reads another functions to calculate the objective and gradients. I also want to ge…

---

## [How to print solver status and reason for termination for NLopt and Optimization.jl](https://discourse.julialang.org/t/how-to-print-solver-status-and-reason-for-termination-for-nlopt-and-optimization-jl/111308)

<div class="topic-metadata">

**Author:** [@structural](https://discourse.julialang.org/u/structural)\
**Replies:** 1\
**Last updated:** [March 7, 2024, 7:48pm UTC](https://discourse.julialang.org/t/how-to-print-solver-status-and-reason-for-termination-for-nlopt-and-optimization-jl/111308 "2024-03-07T19:48:18Z")

</div>

I am searching for a minimum using NLopt.LN\_SBPLX. The optimizer stops prematurely after ~100 iterations without throwing any errors or printing any messages. display(sol) simply returns the last parameter vector that wa…

---

## [NLOPT While loop problem](https://discourse.julialang.org/t/nlopt-while-loop-problem/104882)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 14\
**Last updated:** [October 22, 2023, 1:41am UTC](https://discourse.julialang.org/t/nlopt-while-loop-problem/104882 "2023-10-22T01:41:23Z")

</div>

Hi All, I am using gridap for topology optimization. I have defined function of optimization using MMA as below using NLopt function gf\_p\_optimize(p\_init; r, β, η, TOL = 1e-4, fem\_params) ##################### Opti…

---

## [Any breaking changes in NLopt v1.0.0?](https://discourse.julialang.org/t/any-breaking-changes-in-nlopt-v1-0-0/102988)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 2\
**Last updated:** [August 20, 2023, 2:05pm UTC](https://discourse.julialang.org/t/any-breaking-changes-in-nlopt-v1-0-0/102988 "2023-08-20T14:05:35Z")

</div>

NLopt v1.0.0 just got tagged (:tada:). See Release v1.0.0 · JuliaOpt/NLopt.jl · GitHub. Were there any breaking changes compared to the previous stable version, v0.6.5? This is not transparent from looking at the commit…

---

## [Topology optimization using NLopt](https://discourse.julialang.org/t/topology-optimization-using-nlopt/101032)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 4\
**Last updated:** [July 1, 2023, 8:28pm UTC](https://discourse.julialang.org/t/topology-optimization-using-nlopt/101032 "2023-07-01T20:28:24Z")

</div>

Hi, I am doing a topology optimization using Nlop. I have two question i really appreciate your helps. after defining objective and gradients by using below line nlopt understand to minimize the objective function? …

---

## [BoundaError with NLopt in JuMP with a user-defined function and its gradient](https://discourse.julialang.org/t/boundaerror-with-nlopt-in-jump-with-a-user-defined-function-and-its-gradient/99598)

<div class="topic-metadata">

**Author:** [@naouess](https://discourse.julialang.org/u/naouess)\
**Replies:** 1\
**Last updated:** [May 30, 2023, 7:28pm UTC](https://discourse.julialang.org/t/boundaerror-with-nlopt-in-jump-with-a-user-defined-function-and-its-gradient/99598 "2023-05-30T19:28:19Z")

</div>

Hello, I am solving an NLP in JuMP with several nonlinear user-defined functions as constraints. I provide the functions and their gradients in the following way: for j in 1:24 register(m, Symbol("myfunc\_$j"), length(…

---

## [How to create an user-defined function with multiple vector as inputs](https://discourse.julialang.org/t/how-to-create-an-user-defined-function-with-multiple-vector-as-inputs/99068)

<div class="topic-metadata">

**Author:** [@PatrickeTownsend](https://discourse.julialang.org/u/PatrickeTownsend)\
**Replies:** 1\
**Last updated:** [May 18, 2023, 8:40pm UTC](https://discourse.julialang.org/t/how-to-create-an-user-defined-function-with-multiple-vector-as-inputs/99068 "2023-05-18T20:40:21Z")

</div>

Hello, I’m new to JuMP module and also Julia. I’m trying to perform a trajectory optimization with Hermite-Simpson direct collocation method. I’ve trying to create a function for the dynamic equations, but I’m still get…

---

## [MathOptInterface.OTHER\_ERROR when trying to use ISRES of NLopt through JuMP](https://discourse.julialang.org/t/mathoptinterface-other-error-when-trying-to-use-isres-of-nlopt-through-jump/87420)

<div class="topic-metadata">

**Author:** [@knkn1711](https://discourse.julialang.org/u/knkn1711)\
**Replies:** 1\
**Last updated:** [September 17, 2022, 11:41pm UTC](https://discourse.julialang.org/t/mathoptinterface-other-error-when-trying-to-use-isres-of-nlopt-through-jump/87420 "2022-09-17T23:41:49Z")

</div>

I am trying to minimize a nonlinear function with nonlinear inequality constraints with NLopt and JuMP. In my test code below, I am minimizing a function with a known global minima. Local optimizers such as LD\_MMA fail…

---

## [Problem setting the Local Optimizer](https://discourse.julialang.org/t/problem-setting-the-local-optimizer/86257)

<div class="topic-metadata">

**Author:** [@Yagiz\_Dereboy](https://discourse.julialang.org/u/Yagiz_Dereboy)\
**Replies:** 4\
**Last updated:** [August 26, 2022, 6:56am UTC](https://discourse.julialang.org/t/problem-setting-the-local-optimizer/86257 "2022-08-26T06:56:24Z")

</div>

I have problem with the Augmented Lagrangian Method. With my syntax algorithm does not move and gets a forced stop. I am almost sure problem is with the setting of the local optimizer. I am not very familiar with the Jul…

---

## [NLopt return flag: is there a simple way to check for success?](https://discourse.julialang.org/t/nlopt-return-flag-is-there-a-simple-way-to-check-for-success/84637)

<div class="topic-metadata">

**Author:** [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Replies:** 2\
**Last updated:** [July 23, 2022, 4:35am UTC](https://discourse.julialang.org/t/nlopt-return-flag-is-there-a-simple-way-to-check-for-success/84637 "2022-07-23T04:35:50Z")

</div>

NLopt.optimize returns a tuple (objvalue, xopt, flag), and flag is a symbol that can hold strings such as FTOL\_REACHED or SUCCESS. The C API mentions that positive return values indicate success. Is there a similar way t…

---

## [NLopt :FORCED\_STOP when objective function has wrong signature (missing gradient arg)](https://discourse.julialang.org/t/nlopt-forced-stop-when-objective-function-has-wrong-signature-missing-gradient-arg/82742)

<div class="topic-metadata">

**Author:** [@pierre-haessig](https://discourse.julialang.org/u/pierre-haessig)\
**Replies:** 2\
**Last updated:** [June 21, 2022, 9:00pm UTC](https://discourse.julialang.org/t/nlopt-forced-stop-when-objective-function-has-wrong-signature-missing-gradient-arg/82742 "2022-06-21T21:00:01Z")

</div>

Hello, I just faced a small usability issue using NLopt.jl. I believe the issue is common enough (e.g. forum post from Oct 2020 https://discourse.julialang.org/t/nlopt-forced-stop) that it may suggest a better error cat…

---

## [Solving Nonlinear constrained optimization](https://discourse.julialang.org/t/solving-nonlinear-constrained-optimization/75982)

<div class="topic-metadata">

**Author:** [@AhmedAlreweny](https://discourse.julialang.org/u/AhmedAlreweny)\
**Replies:** 6\
**Last updated:** [February 14, 2022, 3:37pm UTC](https://discourse.julialang.org/t/solving-nonlinear-constrained-optimization/75982 "2022-02-14T15:37:21Z")

</div>

Hello, I have been recently struggling to solve a NLP in julia. The problem can be written as: min f(x) st c(x)=0 It is important to mention that the objective function is a discretized integrat…

---

## [User-defined gradient and hessian ADNLPModels.jl](https://discourse.julialang.org/t/user-defined-gradient-and-hessian-adnlpmodels-jl/75940)

<div class="topic-metadata">

**Author:** [@AhmedAlreweny](https://discourse.julialang.org/u/AhmedAlreweny)\
**Replies:** 0\
**Last updated:** [February 7, 2022, 9:31am UTC](https://discourse.julialang.org/t/user-defined-gradient-and-hessian-adnlpmodels-jl/75940 "2022-02-07T09:31:13Z")

</div>

Hello, I am trying to solve a nonlinear optimization problem using NLPModels.jl. As seen from here, the model takes only the objective function and the constraints and compute the gradient and hessian using ForwardDiff.…

---

## [Improve performance of a code with very large % of Garbage Collection](https://discourse.julialang.org/t/improve-performance-of-a-code-with-very-large-of-garbage-collection/75548)

<div class="topic-metadata">

**Author:** [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Replies:** 19\
**Last updated:** [February 1, 2022, 10:31pm UTC](https://discourse.julialang.org/t/improve-performance-of-a-code-with-very-large-of-garbage-collection/75548 "2022-02-01T22:31:13Z")

</div>

Hello, I am trying to squeeze performance of the following code as much as possible. When I benchmark it, I get a very large number for the garbage collection statistic (see below). Does anyone have any recommendation fo…

---

## [Entropy maximization with nonlinear constraint](https://discourse.julialang.org/t/entropy-maximization-with-nonlinear-constraint/73104)

<div class="topic-metadata">

**Author:** [@mvsoom](https://discourse.julialang.org/u/mvsoom)\
**Replies:** 4\
**Last updated:** [December 14, 2021, 11:55pm UTC](https://discourse.julialang.org/t/entropy-maximization-with-nonlinear-constraint/73104 "2021-12-14T23:55:50Z")

</div>

I’m trying to solve the following entropy maximization problem: \\max\_p -\\sum\_{ij} p\_{ij} \\log p\_{ij} s.t. p \\in \\mathbb{R}^{n \\times n} \\\\ p\_{ij} = p\_{ji} \\\\ 0 \\leq p\_{ij} \\leq 1 ~ \\forall (i,j) \\\\ \\sum\_{ij} p\_{ij} …

---

## [NLP parameters inside a multithreaded loop](https://discourse.julialang.org/t/nlp-parameters-inside-a-multithreaded-loop/72622)

<div class="topic-metadata">

**Author:** [@Joao\_Guilherme\_Santo](https://discourse.julialang.org/u/Joao_Guilherme_Santo)\
**Replies:** 2\
**Last updated:** [December 6, 2021, 12:06am UTC](https://discourse.julialang.org/t/nlp-parameters-inside-a-multithreaded-loop/72622 "2021-12-06T00:06:51Z")

</div>

I am not sure if this is a JuMP or NLopt issue but whenever I try to do a loop with a NLP inside defining a parameter in each iteration, it only works if I am using a single thread. For example, the code below does not …

---

## [NLopt:FORCED\_STOP for vector-valued constraint](https://discourse.julialang.org/t/nlopt-forced-stop-for-vector-valued-constraint/72117)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 1\
**Last updated:** [November 27, 2021, 11:00pm UTC](https://discourse.julialang.org/t/nlopt-forced-stop-for-vector-valued-constraint/72117 "2021-11-27T23:00:22Z")

</div>

The following code tries to solve Ax = b subject to x \>= 0 using the NLopt package. using NLopt A = \[0.0372 0.2869; 0.6861 0.7071; 0.6233 0.6245; 0.6344 0.6170\] b = \[0.8587; 0.1781; 0.0747; 0.8405\] function myfunc(x::Ve…

---

## [Is NLopt thread safe?](https://discourse.julialang.org/t/is-nlopt-thread-safe/71398)

<div class="topic-metadata">

**Author:** [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Replies:** 6\
**Last updated:** [November 12, 2021, 10:25pm UTC](https://discourse.julialang.org/t/is-nlopt-thread-safe/71398 "2021-11-12T22:25:33Z")

</div>

I’ve got a constrained optimization situation where restarting NLopt from multiple initial points tends to be a good idea. I’d like to simply do @threads and split them over several threads, but I don’t know if this is s…
