# Optim.jl and Fminbox errors

**URL:** https://discourse.julialang.org/t/optim-jl-and-fminbox-errors/5242
**Category:** General Usage
**Created:** [August 5, 2017, 4:39pm UTC](https://discourse.julialang.org/t/optim-jl-and-fminbox-errors/5242 "2017-08-05T16:39:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![improbable22](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/improbable22/32/5464_2.png) [@improbable22](https://discourse.julialang.org/u/improbable22)
#### Post date: [August 5, 2017, 4:39pm UTC](https://discourse.julialang.org/t/optim-jl-and-fminbox-errors/5242/1 "2017-08-05T16:39:29Z")

</div>

I’m having trouble getting Optim.jl’s box minimization to work. From the example [in the docs](http://julianlsolvers.github.io/Optim.jl/stable/user/minimization/) the error I get is here:

```julia
julia> od = OnceDifferentiable(f, g!, initial_x)
ERROR: MethodError: Cannot `convert` an object of type Array{Float64,1} to an object of type Function
[...]
Stacktrace:
 [1] Optim.OnceDifferentiable(::Function, ::Function, ::Array{Float64,1}) at /Users/me/.julia/v0.6/Optim/src/types.jl:101

```

If I delete the `initial_x` there (although [issue 449](https://github.com/JuliaNLSolvers/Optim.jl/issues/449) says I need it?) then I get different errors:

```julia
julia> od = OnceDifferentiable(f, g!)#, initial_x)
Optim.OnceDifferentiable(f, g!, Optim.fg!)

julia> results = Optim.optimize(od, initial_x, lower, upper, Fminbox{GradientDescent}())
ERROR: TypeError: Type{...} expression: expected UnionAll, got Type{Optim.Fminbox}

```

Am I doing something wrong or is this a bug?

I have just run Pkg.update() and am on Julia 0.6.0.

---

<div class="post-metadata">

### Author: ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)
#### Post date: [August 5, 2017, 5:14pm UTC](https://discourse.julialang.org/t/optim-jl-and-fminbox-errors/5242/2 "2017-08-05T17:14:31Z")

</div>

It all works fine with me. Please post a complete code snippet that generates the error.

---

<div class="post-metadata">

### Author: ![improbable22](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/improbable22/32/5464_2.png) [@improbable22](https://discourse.julialang.org/u/improbable22)
#### Post date: [August 5, 2017, 7:16pm UTC](https://discourse.julialang.org/t/optim-jl-and-fminbox-errors/5242/3 "2017-08-05T19:16:32Z")

</div>

OK I think I found the problem! I was stuck on Optim v0.7.8, because of ReverseDiff:

```julia
julia> Pkg.add("Optim.jl")
INFO: Installing LineSearches v0.1.5
INFO: Installing Optim v0.7.8
INFO: Installing PositiveFactorizations v0.0.4
INFO: Package database updated

julia> Pkg.pin("Optim", v"0.9.3")
INFO: Creating Optim branch pinned.c4e0116a.tmp
ERROR: Unsatisfiable requirements detected for package ForwardDiff:
├─version range [0.5.0,∞) required by package Optim, whose only allowed version is 0.9.3:
│ ├─version 0.9.3 set by fixed requirement (package is checked out, dirty or pinned)
│ └─version range [0.0.0-,∞) set by an explicit requirement
└─version range [0.3.2,0.5.0) required by package ReverseDiff, whose allowed version range is [0.0.0-,∞):
  └─version range [0.0.0-,∞) set by an explicit requirement
The intersection of the requirements is empty.

```

After `Pkg.rm("ReverseDiff")` I could upgrade, and now it works.
