On Tuesday, September 30, 2014 02:37:38 AM [email protected] wrote:
> However, the optimization fails, since the function I construct seems to be 
> incorrectly specified for the Optim package to work:
> > using Optim
> > fminbox(f2, 1, 0, 2)  # minimize over interval [0, 2], start at 1
> 
> `fminbox` has no method matching fminbox(::Function)

If you say
    methods(fminbox)
you'll see you have to pass a `DifferentiableFunction`.

> > optimize(f2, 0, 2)  # minimize over interval [0, 2] using Brent's method
> 
> `eps` has no method matching eps(::Type{Int64})

This one has nothing to do with your function, and is a bug in Optimize that 
should be fixed:

julia> f(x) = (x-1.5)^2
f (generic function with 1 method)

julia> optimize(f, 0, 2)
ERROR: `eps` has no method matching eps(::Type{Int64})


You can work around it by specifying your range this way:
    optimize(f, 0.0, 2.0)

However, far better would be if you or someone fixes the original function. 
Here's how you'd go about discovering how to do this:
julia> @which optimize(f, 0, 2)
optimize{T<:Real}(f::Function,lower::T<:Real,upper::T<:Real) at 
/home/tim/.julia/v0.4/Optim/src/optimize.jl:510

julia> edit("/home/tim/.julia/v0.4/Optim/src/optimize.jl",510)

and then define variant of `optimize` where `T <: Integer` converts lower and 
upper to Float64. Once you've got a working version, do a `git commit -a` 
inside the Optim folder and a `Pkg.submit("Optim")` from julia.

--Tim

Reply via email to