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

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

I think you should use optimize!().

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!!!

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

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.

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
and it seems is ok for the version 0.6.x

I don’t get it!

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.

yes, sure, I did!

there is no MWE! Well, I mean, simply I installed the package by:
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!

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.

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.

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

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, which has julia 0.6 in the REQUIRE file.

1 Like

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> 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> Pkg.rm("Optim")

julia> Pkg.add("Optim")

Thank you so much Michael. Now it works.:slight_smile:

Thank you so much Fredrik for your reply.

I will see! Thanks anyway