# Optim.jl is installed successfully, but "optimize" function is not inside, nor other functions!

**URL:** <https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878>\
**Category:** New to Julia\
**Tags:** optimization\
**Created:** [September 18, 2019, 7:02am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878 "2019-09-18T07:02:42Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hani20](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@Hani20](https://discourse.julialang.org/u/Hani20)\
**Post date:** [September 18, 2019, 7:02am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/1 "2019-09-18T07:02:42Z")

</div>

dear all,  
I am working on Julia 0.6.4. I installed Optim.jl and its binary in my directory of current project. but when I call “optimize” function of this package, I got the error:  
ERROR: UndefVarError: optimize not defined

My environment in which I use Julia knows Optim.jl but only “eval” one is defined, no other functions of this package.

could any one guide me? thanks a lot  
Hani

---

<div class="post-metadata">

**Author:** ![Ajaychat3](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@Ajaychat3](https://discourse.julialang.org/u/Ajaychat3)\
**Post date:** [September 18, 2019, 7:12am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/2 "2019-09-18T07:12:52Z")

</div>

I think you should use `optimize!()`.

---

<div class="post-metadata">

**Author:** ![Hani20](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@Hani20](https://discourse.julialang.org/u/Hani20)\
**Post date:** [September 18, 2019, 7:16am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/3 "2019-09-18T07:16:55Z")

</div>

Hi @Ajaychat3, thanks for your reply. Actually, no! well, I tried though.  
However, the function is defined as “optimize” inside the package. I am wondering why I use tab to see other modules of this package nothing is appeared, while I use for the other installed packages and I could see a list of all modules inside that specific package!!!

---

<div class="post-metadata">

**Author:** ![Ajaychat3](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@Ajaychat3](https://discourse.julialang.org/u/Ajaychat3)\
**Post date:** [September 18, 2019, 7:22am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/4 "2019-09-18T07:22:47Z")

</div>

Sorry. my mistake. It is not optimize!().

---

<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:** [September 18, 2019, 7:23am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/5 "2019-09-18T07:23:21Z")

</div>

> [@Hani20](#):
>
> could any one guide me? thanks a lot

I would be useful to

1. know the version of Optim.jl you are using,
2. see an MWE of what fails (apparently you are using some kind of IDE, but you don’t say what).

In any case, I would strongly recommend updating to Julia 1.2 and taking it from there. The version of Optim.jl that supports 0.6 is most likely to be very old.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

**Author:** ![Hani20](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@Hani20](https://discourse.julialang.org/u/Hani20)\
**Post date:** [September 18, 2019, 7:36am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/6 "2019-09-18T07:36:02Z")

</div>

Hi @Tamas_Papp,  
Thank you very much:)  
The version of Optim.jl is 0.18.1+  
I am using Atom as an IDE.  
well, I would like to upgrade the current version, however It cannot be taken by my decision, as I am supposed to work with this version!!

I also looked at the compatibility on the [https://github.com/JuliaRegistries/General/blob/master/O/Optim/Compat.toml](https://github.com/JuliaRegistries/General/blob/master/O/Optim/Compat.toml)  
and it seems is ok for the version 0.6.x

I don’t get it!

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [September 18, 2019, 7:49am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/7 "2019-09-18T07:49:32Z")

</div>

did you do `using Optim` before trying to use optimize()? This may seem like a silly answer, but without a minimum working example, we can’t rule it out.

---

<div class="post-metadata">

**Author:** ![Hani20](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@Hani20](https://discourse.julialang.org/u/Hani20)\
**Post date:** [September 18, 2019, 7:50am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/8 "2019-09-18T07:50:55Z")

</div>

yes, sure, I did!

there is no MWE! Well, I mean, simply I installed the package by:  
Pkg.add(“Optim”)  
then “using Optim”  
but after that no access to any functions inside.  
when I type “Optim.” and press tab to get the list of all functions, it gives me only:  
“Optim.eval” as an output!

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [September 18, 2019, 8:01am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/9 "2019-09-18T08:01:59Z")

</div>

It seems that Optim was probably not installed properly. I don’t recall how to check the status of packages with Julia 0.6. With recent versions, it’s `] st`. Perhaps `Pkg.status()` will do it.

---

<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:** [September 18, 2019, 8:11am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/10 "2019-09-18T08:11:45Z")

</div>

> [@Hani20](#):
>
> I would like to upgrade the current version, however It cannot be taken by my decision, as I am supposed to work with this version!!

Note that in this case your community support options are somewhat limited. Even if you get Optim.jl working (which should, of course, be feasible), most packages will be at versions that are not supported any more.

---

<div class="post-metadata">

**Author:** ![Hani20](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@Hani20](https://discourse.julialang.org/u/Hani20)\
**Post date:** [September 18, 2019, 8:14am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/11 "2019-09-18T08:14:20Z")

</div>

I did it as well. The output was:  
Optim 0.18.1+ master

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [September 18, 2019, 8:18am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/12 "2019-09-18T08:18:36Z")

</div>

Optim 0.18 requires julia 1.0 or higher. I think you need a release around 0.14.1 for it to work on julia 0.6: see [https://github.com/JuliaNLSolvers/Optim.jl/tree/v0.14.1](https://github.com/JuliaNLSolvers/Optim.jl/tree/v0.14.1), which has julia 0.6 in the REQUIRE file.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [September 18, 2019, 9:01am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/13 "2019-09-18T09:01:02Z")

</div>

From a clean install I get Optim 0.15.3 (presumably the last version compatible with Julia 0.6), and everything works as expected:

```julia
julia> Pkg.add("Optim")
[...]

julia> using Optim
INFO: Precompiling module Optim.

julia> rosenbrock(x) = (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
rosenbrock (generic function with 1 method)

julia> result = optimize(rosenbrock, zeros(2), BFGS())
Results of Optimization Algorithm
 * Algorithm: BFGS
 * Starting Point: [0.0,0.0]
 * Minimizer: [0.9999999926033423,0.9999999852005353]
 * Minimum: 5.471433e-17
 * Iterations: 16
 * Convergence: true
   * |x - x'| ≤ 0.0e+00: false 
     |x - x'| = 3.47e-07 
   * |f(x) - f(x')| ≤ 0.0e+00 |f(x)|: false
     |f(x) - f(x')| = 1.20e+03 |f(x)|
   * |g(x)| ≤ 1.0e-08: true 
     |g(x)| = 2.33e-09 
   * Stopped by an increasing objective: false
   * Reached Maximum Number of Iterations: false
 * Objective Calls: 53
 * Gradient Calls: 53

```

so there seems to be something wrong with your install. Can you try to remove the package and reinstall it?

```julia
julia> Pkg.rm("Optim")

julia> Pkg.add("Optim")

```

---

<div class="post-metadata">

**Author:** ![Hani20](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@Hani20](https://discourse.julialang.org/u/Hani20)\
**Post date:** [September 18, 2019, 9:44am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/14 "2019-09-18T09:44:01Z")

</div>

Thank you so much Michael. Now it works.🙂

---

<div class="post-metadata">

**Author:** ![Hani20](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@Hani20](https://discourse.julialang.org/u/Hani20)\
**Post date:** [September 18, 2019, 9:45am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/15 "2019-09-18T09:45:42Z")

</div>

Thank you so much Fredrik for your reply.

---

<div class="post-metadata">

**Author:** ![Hani20](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@Hani20](https://discourse.julialang.org/u/Hani20)\
**Post date:** [September 18, 2019, 9:49am UTC](https://discourse.julialang.org/t/optim-jl-is-installed-successfully-but-optimize-function-is-not-inside-nor-other-functions/28878/17 "2019-09-18T09:49:39Z")

</div>

> [@Tamas\_Papp](#):
>
> Even if you get Optim.jl working (which should, of course, be feasible), most packages will be at versions that are not supported any more.

I will see! Thanks anyway
