# \#optim

**URL:** https://discourse.julialang.org/tag/optim/112.md?match_all_tags=true&page=4&tags%5B%5D=optim

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

**Page:** 5

---

## [Strange errors occurred when I optimized with Zygote and Optim](https://discourse.julialang.org/t/strange-errors-occurred-when-i-optimized-with-zygote-and-optim/47461)

<div class="topic-metadata">

**Author:** [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Replies:** 3\
**Last updated:** [October 4, 2020, 7:09am UTC](https://discourse.julialang.org/t/strange-errors-occurred-when-i-optimized-with-zygote-and-optim/47461 "2020-10-04T07:09:01Z")

</div>

Why do I get a bivariate gradient function when I optimize the objective function?How can I solve it? using Zygote using Optim using RecursiveArrayTools #This is the target function that I’m optimizing function ge…

---

## [Functor usage for Optim.jl](https://discourse.julialang.org/t/functor-usage-for-optim-jl/45778)

<div class="topic-metadata">

**Author:** [@stevengogogo](https://discourse.julialang.org/u/stevengogogo)\
**Replies:** 4\
**Last updated:** [August 31, 2020, 3:32pm UTC](https://discourse.julialang.org/t/functor-usage-for-optim-jl/45778 "2020-08-31T15:32:07Z")

</div>

Dear Community, I got a question about functor usage with Optim.jl. I’m currently writing a Julian package for biological modeling. To organize parameters of the biological process, I chose function-like object (funct…

---

## [Syntax for custom cost function for ODE parameter estimation](https://discourse.julialang.org/t/syntax-for-custom-cost-function-for-ode-parameter-estimation/43467)

<div class="topic-metadata">

**Author:** [@vaglino](https://discourse.julialang.org/u/vaglino)\
**Replies:** 3\
**Last updated:** [August 1, 2020, 12:04pm UTC](https://discourse.julialang.org/t/syntax-for-custom-cost-function-for-ode-parameter-estimation/43467 "2020-08-01T12:04:55Z")

</div>

Hi, I’m trying to write my own cost function for parameter estimation of an ode model. I am trying to weight the loss by the time t. Based on the documentation I came up with the following, but I’m unsure about the cor…

---

## [Convert Optim objective value back to a Float](https://discourse.julialang.org/t/convert-optim-objective-value-back-to-a-float/43942)

<div class="topic-metadata">

**Author:** [@tyleransom](https://discourse.julialang.org/u/tyleransom)\
**Replies:** 6\
**Last updated:** [July 30, 2020, 7:32pm UTC](https://discourse.julialang.org/t/convert-optim-objective-value-back-to-a-float/43942 "2020-07-30T19:32:16Z")

</div>

I am working with the code in this gist. In the file test\_autochoice\_mew2.jl , I have the following pieces of code: \[...\] T = promote\_type(promote\_type(promote\_type(eltype(X),eltype(b)),eltype(Z)),eltype(W)) \[...\] ℓ …

---

## [Loop for minimizing functions with a varying number of arguments](https://discourse.julialang.org/t/loop-for-minimizing-functions-with-a-varying-number-of-arguments/42816)

<div class="topic-metadata">

**Author:** [@sergevic](https://discourse.julialang.org/u/sergevic)\
**Replies:** 12\
**Last updated:** [July 11, 2020, 12:03am UTC](https://discourse.julialang.org/t/loop-for-minimizing-functions-with-a-varying-number-of-arguments/42816 "2020-07-11T00:03:56Z")

</div>

I have to build a loop where each iteration consists in building a function to minimize. At each iteration, the number of arguments is variable. To start, I have two matrices: X=rand(150,100) Y=rand(150,1) At each ite…

---

## [Conjugate Gradient optimization with set of functions](https://discourse.julialang.org/t/conjugate-gradient-optimization-with-set-of-functions/42070)

<div class="topic-metadata">

**Author:** [@sergevic](https://discourse.julialang.org/u/sergevic)\
**Replies:** 9\
**Last updated:** [June 27, 2020, 3:40am UTC](https://discourse.julialang.org/t/conjugate-gradient-optimization-with-set-of-functions/42070 "2020-06-27T03:40:20Z")

</div>

This post is related to a previous post of mine and I prefered to expose the problem separatey. I have to optimize a set of functions with conjugate gradient optimization, but I have to define the whole set of functions …

---

## [Parallel computing using Optim](https://discourse.julialang.org/t/parallel-computing-using-optim/41948)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 5\
**Last updated:** [June 25, 2020, 3:55pm UTC](https://discourse.julialang.org/t/parallel-computing-using-optim/41948 "2020-06-25T15:55:49Z")

</div>

Hello, I’m running the program below on a 32 cpu/64 thread system without much of anything else running on it. If I use anything beyond 16 cores then the execution time in the second run is effectively flat. This is t…

---

## [Plotting the evolution of the optimization using Optim.jl](https://discourse.julialang.org/t/plotting-the-evolution-of-the-optimization-using-optim-jl/41978)

<div class="topic-metadata">

**Author:** [@cmey](https://discourse.julialang.org/u/cmey)\
**Replies:** 3\
**Last updated:** [June 25, 2020, 1:52pm UTC](https://discourse.julialang.org/t/plotting-the-evolution-of-the-optimization-using-optim-jl/41978 "2020-06-25T13:52:19Z")

</div>

Hi! What’s a good strategy to plot the evolution of the solution x during the optimization using Optim.jl? Note: I’m looking for the value of the solution, not the value of the objective function nor the value of the gr…

---

## [Speeding up repeated optimizations within a large loop](https://discourse.julialang.org/t/speeding-up-repeated-optimizations-within-a-large-loop/41901)

<div class="topic-metadata">

**Author:** [@asyadav](https://discourse.julialang.org/u/asyadav)\
**Replies:** 7\
**Last updated:** [June 25, 2020, 7:22am UTC](https://discourse.julialang.org/t/speeding-up-repeated-optimizations-within-a-large-loop/41901 "2020-06-25T07:22:59Z")

</div>

Hi there! I’m trying to solve an economic model with many discrete and continuous choices and a fairly large state space. My approach essentially boils down to solving several constrained optimization problems, using Opt…

---

## [Finding saddle point](https://discourse.julialang.org/t/finding-saddle-point/21168)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 36\
**Last updated:** [May 29, 2020, 3:35pm UTC](https://discourse.julialang.org/t/finding-saddle-point/21168 "2020-05-29T15:35:51Z")

</div>

I’m trying to find the saddle point of a function. I’ve programmed a function saddle below (but if you know of a library to find saddle points, please let me know). The idea is that the input function should be specified…

---

## [Optimization using Optim and Roots](https://discourse.julialang.org/t/optimization-using-optim-and-roots/39301)

<div class="topic-metadata">

**Author:** [@optimist](https://discourse.julialang.org/u/optimist)\
**Replies:** 9\
**Last updated:** [May 24, 2020, 10:43pm UTC](https://discourse.julialang.org/t/optimization-using-optim-and-roots/39301 "2020-05-24T22:43:55Z")

</div>

Hello, I am a new user of Julia and the Optim package, and I am looking for some guidance on a simple piece of code. I have given my simple implementation of the equivalent of Excel XIRR (extended internal rate of retur…

---

## [\[RFC/ANN\] ComponentArrays.jl for building composable models without a modeling language](https://discourse.julialang.org/t/rfc-ann-componentarrays-jl-for-building-composable-models-without-a-modeling-language/38001)

<div class="topic-metadata">

**Author:** [@jonniedie](https://discourse.julialang.org/u/jonniedie)\
**Replies:** 22\
**Last updated:** [April 25, 2020, 8:59pm UTC](https://discourse.julialang.org/t/rfc-ann-componentarrays-jl-for-building-composable-models-without-a-modeling-language/38001 "2020-04-25T20:59:17Z")

</div>

Hey everyone. ComponentArrays.jl is my first package and I’m looking for some feedback and to gauge interest before I think about going down the path of registering it. I wrote this package mostly for myself for my work …

---

## [Avoid repeated memory allocation by defining an Array{Float64} outside of optimize() using Optim.jl, ForwardDiff.jl](https://discourse.julialang.org/t/avoid-repeated-memory-allocation-by-defining-an-array-float64-outside-of-optimize-using-optim-jl-forwarddiff-jl/37357)

<div class="topic-metadata">

**Author:** [@Maximilian](https://discourse.julialang.org/u/Maximilian)\
**Replies:** 7\
**Last updated:** [April 24, 2020, 6:58pm UTC](https://discourse.julialang.org/t/avoid-repeated-memory-allocation-by-defining-an-array-float64-outside-of-optimize-using-optim-jl-forwarddiff-jl/37357 "2020-04-24T18:58:01Z")

</div>

I am using Optim.jl with an objective that is computed by multipliying, transposing and inverting some matrices (maximum size of about 500x500). However, I have only a few parameters (maximum 200), each one having a fixe…

---

## [Procedural Nonlinear Constaint Generation - String to NLconstraint](https://discourse.julialang.org/t/procedural-nonlinear-constaint-generation-string-to-nlconstraint/34799)

<div class="topic-metadata">

**Author:** [@r-b0](https://discourse.julialang.org/u/r-b0)\
**Replies:** 9\
**Last updated:** [March 30, 2020, 1:53am UTC](https://discourse.julialang.org/t/procedural-nonlinear-constaint-generation-string-to-nlconstraint/34799 "2020-03-30T01:53:29Z")

</div>

I am implementing a large scale nonlinear program solver using the JuMP interface to IPOPT. The Nonlinear Modeling section of JuMP v0.21.0 documentation clearly explicates that all expressions used in NLconstraint and N…

---

## [DifferentialEquations.jl ERROR: UndefVarError: CostVData not defined](https://discourse.julialang.org/t/differentialequations-jl-error-undefvarerror-costvdata-not-defined/35939)

<div class="topic-metadata">

**Author:** [@PharmCat](https://discourse.julialang.org/u/PharmCat)\
**Replies:** 5\
**Last updated:** [March 16, 2020, 9:18pm UTC](https://discourse.julialang.org/t/differentialequations-jl-error-undefvarerror-costvdata-not-defined/35939 "2020-03-16T21:18:38Z")

</div>

I try to otimize function with DifferentialEquations.jl + Optim.jl like in documetation, but I have: ERROR: UndefVarError: CostVData not defined using DifferentialEquations, Plots, Optim, LossFunctions, Random, DiffE…

---

## [Gradient-based methods are not moving some parameters](https://discourse.julialang.org/t/gradient-based-methods-are-not-moving-some-parameters/34549)

<div class="topic-metadata">

**Author:** [@cosmia](https://discourse.julialang.org/u/cosmia)\
**Replies:** 3\
**Last updated:** [February 13, 2020, 4:16pm UTC](https://discourse.julialang.org/t/gradient-based-methods-are-not-moving-some-parameters/34549 "2020-02-13T16:16:34Z")

</div>

Hi all, I have a maximum likelihood estimator in which I need to integrate using a mixture of two normal distributions with zero mean. Without getting into much details, this entails estimating 3 parameters of the distri…

---

## [2D Lotka Volterra parameter estimation with only 1D data](https://discourse.julialang.org/t/2d-lotka-volterra-parameter-estimation-with-only-1d-data/13838)

<div class="topic-metadata">

**Author:** [@gregory](https://discourse.julialang.org/u/gregory)\
**Replies:** 7\
**Last updated:** [February 6, 2020, 2:28pm UTC](https://discourse.julialang.org/t/2d-lotka-volterra-parameter-estimation-with-only-1d-data/13838 "2020-02-06T14:28:37Z")

</div>

I am testing this with a toy problem first using a simple 2D Lotka Volterra. I feed in the actual params and then make some pseudo time series data. I then want to pretend I only have knowledge of 1 population and feed t…

---

## [Maximum Likelihood Multivariate Model](https://discourse.julialang.org/t/maximum-likelihood-multivariate-model/33156)

<div class="topic-metadata">

**Author:** [@Maximilian](https://discourse.julialang.org/u/Maximilian)\
**Replies:** 15\
**Last updated:** [January 10, 2020, 12:09am UTC](https://discourse.julialang.org/t/maximum-likelihood-multivariate-model/33156 "2020-01-10T00:09:06Z")

</div>

I am trying to optimize a likelihood function for the multivariate case. This is the code I am using using Optim, LinearAlgebra, ForwardDiff #observed covariance cov\_obs = \[1.3629 0.408729 0.581832 0.…

---

## [Optim.jl with autodiff and complex numbers](https://discourse.julialang.org/t/optim-jl-with-autodiff-and-complex-numbers/27684)

<div class="topic-metadata">

**Author:** [@Dandan](https://discourse.julialang.org/u/Dandan)\
**Replies:** 8\
**Last updated:** [August 18, 2019, 8:03pm UTC](https://discourse.julialang.org/t/optim-jl-with-autodiff-and-complex-numbers/27684 "2019-08-18T20:03:03Z")

</div>

Hello! I would like to use Optim.jl with the target function defined on a complex Stiefel manifold (unitary matrices) of some large size. Stiefel manifold is already implemented in Optim.jl. The problem is I can’t use …

---

## [\[ANN\] FluxOptTools](https://discourse.julialang.org/t/ann-fluxopttools/25888)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 0\
**Last updated:** [July 1, 2019, 9:17am UTC](https://discourse.julialang.org/t/ann-fluxopttools/25888 "2019-07-01T09:17:48Z")

</div>

FluxOptTools.jl This package contains some utilities to enhance training of Flux.jl models. Train using Optim Optim.jl can be used to train Flux models (if Flux is on branch sf/zygote\_updated), here’s an example how u…

---

## [Optim user-supplied gradient not working](https://discourse.julialang.org/t/optim-user-supplied-gradient-not-working/24417)

<div class="topic-metadata">

**Author:** [@tyleransom](https://discourse.julialang.org/u/tyleransom)\
**Replies:** 6\
**Last updated:** [May 21, 2019, 3:45pm UTC](https://discourse.julialang.org/t/optim-user-supplied-gradient-not-working/24417 "2019-05-21T15:45:56Z")

</div>

I’m estimating a maximum likelihood problem, and I’ve specified both the objective function and the gradient correctly. (I know this because I am able to reproduce estimates using the same exact data as a Stata example.) …

---

## [Optim.jl - No default objective type for IPNewton](https://discourse.julialang.org/t/optim-jl-no-default-objective-type-for-ipnewton/23036)

<div class="topic-metadata">

**Author:** [@ferrolho](https://discourse.julialang.org/u/ferrolho)\
**Replies:** 5\
**Last updated:** [April 12, 2019, 10:19am UTC](https://discourse.julialang.org/t/optim-jl-no-default-objective-type-for-ipnewton/23036 "2019-04-12T10:19:46Z")

</div>

Please consider the following code snippet using Optim.jl: using Optim dof = 7 fun(x) = 0.0; x0 = fill(0.1, dof) df = TwiceDifferentiable(fun, x0) lx = fill(-1.2, dof); ux = fill(+1.2, dof) dfc = TwiceDifferentiableC…

---

## [Multivariate parameter optimization in "3-states differential equations" where two of the states have measured data and one state lacks data.](https://discourse.julialang.org/t/multivariate-parameter-optimization-in-3-states-differential-equations-where-two-of-the-states-have-measured-data-and-one-state-lacks-data/23008)

<div class="topic-metadata">

**Author:** [@pandeysudan27](https://discourse.julialang.org/u/pandeysudan27)\
**Replies:** 1\
**Last updated:** [April 11, 2019, 9:41am UTC](https://discourse.julialang.org/t/multivariate-parameter-optimization-in-3-states-differential-equations-where-two-of-the-states-have-measured-data-and-one-state-lacks-data/23008 "2019-04-11T09:41:25Z")

</div>

I have three differential equations in the form of: $$\\frac{dx}{dt}=ax+y+z$$ $$\\frac{dy}{dt}=x+by+z$$ $$\\frac{dz}{dt}=x+y+cz$$ I have measured data: $$x=\[2+5randn(100)\]$$ $$y=\[0.5+2randn(100)\]$$ I do not have data…

---

## [Help with dot macro broadcasting](https://discourse.julialang.org/t/help-with-dot-macro-broadcasting/22729)

<div class="topic-metadata">

**Author:** [@mosiman](https://discourse.julialang.org/u/mosiman)\
**Replies:** 5\
**Last updated:** [April 4, 2019, 4:16am UTC](https://discourse.julialang.org/t/help-with-dot-macro-broadcasting/22729 "2019-04-04T04:16:09Z")

</div>

Hi there, I’m trying to minimize a residual function f using LsqFit.jl since it is the only package that uses Levenberg-Marquardt (trying to do a course where the instructions and assignments assume Matlab usage, and we…

---

## [Forward differentiation and differential equations with solvers like LSODA, Sundials etc](https://discourse.julialang.org/t/forward-differentiation-and-differential-equations-with-solvers-like-lsoda-sundials-etc/22371)

<div class="topic-metadata">

**Author:** [@mzhenirovskyy](https://discourse.julialang.org/u/mzhenirovskyy)\
**Replies:** 2\
**Last updated:** [March 26, 2019, 8:03pm UTC](https://discourse.julialang.org/t/forward-differentiation-and-differential-equations-with-solvers-like-lsoda-sundials-etc/22371 "2019-03-26T20:03:28Z")

</div>

I have similar questions to this thread I do explicit type conversion. When I use “standard” solver like Tsit5() everything is OK. But with solvers like lsoda() or CVODE\_BDF() I’m getting an error: Example: using Dif…

---

## [Method error in Optim inside a function](https://discourse.julialang.org/t/method-error-in-optim-inside-a-function/21194)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 0\
**Last updated:** [February 26, 2019, 12:36am UTC](https://discourse.julialang.org/t/method-error-in-optim-inside-a-function/21194 "2019-02-26T00:36:49Z")

</div>

I programmed a saddle-finding function using Optim. It works fairly well, but when I try to use box optimization, it gives me a methods error. What is the problem? This works: function saddle2(f::Function, initx, inity…

---

## [Inconsistency between standard errors from Hessian and Gradient in ForwardDiff/Optim](https://discourse.julialang.org/t/inconsistency-between-standard-errors-from-hessian-and-gradient-in-forwarddiff-optim/16769)

<div class="topic-metadata">

**Author:** [@cosmia](https://discourse.julialang.org/u/cosmia)\
**Replies:** 6\
**Last updated:** [October 26, 2018, 11:12pm UTC](https://discourse.julialang.org/t/inconsistency-between-standard-errors-from-hessian-and-gradient-in-forwarddiff-optim/16769 "2018-10-26T23:12:04Z")

</div>

I have been using Optim package with AD recently, and I am having some strange behaviour with the gradient. I am using Optim and NLSolversBase in the context of Maximum Likelihood Estimation, and passing a TwiceDifferent…

---

## [Optim.jl returns \`Stopped by an increasing objective: true\`](https://discourse.julialang.org/t/optim-jl-returns-stopped-by-an-increasing-objective-true/15428)

<div class="topic-metadata">

**Author:** [@gasagna](https://discourse.julialang.org/u/gasagna)\
**Replies:** 5\
**Last updated:** [September 26, 2018, 11:54am UTC](https://discourse.julialang.org/t/optim-jl-returns-stopped-by-an-increasing-objective-true/15428 "2018-09-26T11:54:56Z")

</div>

Hi, Under exactly what conditions does optimize in Optim.jl return Stopped by an increasing objective: true? I have a fairly complicated optimisation problem using LBFGS which terminates at some point with this stateme…

---

## [Syntactical Question about optimize](https://discourse.julialang.org/t/syntactical-question-about-optimize/14771)

<div class="topic-metadata">

**Author:** [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Replies:** 3\
**Last updated:** [September 11, 2018, 1:55pm UTC](https://discourse.julialang.org/t/syntactical-question-about-optimize/14771 "2018-09-11T13:55:23Z")

</div>

Hi, someone not knowing much about optimization here… Why does this code searching for the minimum of the two-dimensional paraboloid optimize(x-\>x\[1\]^2+x\[2\]^2,\[1.0, 1.0\]) work without given algorithm whilst this one-d…

---

## [CuArray and Optim](https://discourse.julialang.org/t/cuarray-and-optim/14053)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 9\
**Last updated:** [September 4, 2018, 6:38am UTC](https://discourse.julialang.org/t/cuarray-and-optim/14053 "2018-09-04T06:38:41Z")

</div>

I am trying to write some deconvolution code in Julia via combining LBFGS Optimization (Optim.jl), automatic differentiation (AutoGrad.jl) and Cuda support (CuArray). Julia 1.0 on Windows 10. I finally have some runnab…

[Previous page](https://discourse.julialang.org/tag/optim/112.md?match_all_tags=true&page=3&tags%5B%5D=optim)

[Next page](https://discourse.julialang.org/tag/optim/112.md?match_all_tags=true&page=5&tags%5B%5D=optim)
