robertfeldt / BlackBoxOptim.jl

Black-box optimization for Julia
Other
439 stars 56 forks source link

TopListArchive parameter F should not be restricted #114

Closed BeastyBlacksmith closed 5 years ago

BeastyBlacksmith commented 5 years ago

Currently I get the following error:

TypeError: in TopListArchive, in F, expected F<:Number, got Type{NTuple{5,Float64}}
TopListArchive(::ParetoFitnessScheme{5,Float64,true,typeof(sum)}, ::Int64, ::Int64) at archive.jl:78
make_evaluator(::FunctionBasedProblem{ParetoFitnessScheme{5,Float64,true,typeof(sum)},RangePerDimSearchSpace,Nothing}, ::Nothing, ::DictChain{Symbol,Any}) at opt_controller.jl:9
BlackBoxOptim.OptRunController(::DiffEvoOpt{FitPopulation{NTuple{5,Float64}},RadiusLimitedSelector,BlackBoxOptim.AdaptiveDiffEvoRandBin{3},RandomBound{RangePerDimSearchSpace}}, ::FunctionBasedProblem{ParetoFitnessScheme{5,Float64,true,typeof(sum)},RangePerDimSearchSpace,Nothing}, ::DictChain{Symbol,Any}) at opt_controller.jl:97
run!(::BlackBoxOptim.OptController{DiffEvoOpt{FitPopulation{NTuple{5,Float64}},RadiusLimitedSelector,BlackBoxOptim.AdaptiveDiffEvoRandBin{3},RandomBound{RangePerDimSearchSpace}},FunctionBasedProblem{ParetoFitnessScheme{5,Float64,true,typeof(sum)},RangePerDimSearchSpace,Nothing}}) at opt_controller.jl:435
#bboptimize#75(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:FitnessScheme, :SearchRange, :ϵ),Tuple{ParetoFitnessScheme{5,Float64,true,typeof(sum)},Array{Tuple{Float64,Float64},1},Float64}}}, ::Function, ::Function, ::Dict{Symbol,Any}) at bboptimize.jl:70
#bboptimize at none:0 [inlined]
(::getfield(BlackBoxOptim, Symbol("#kw##bboptimize")))(::NamedTuple{(:FitnessScheme, :SearchRange, :ϵ),Tuple{ParetoFitnessScheme{5,Float64,true,typeof(sum)},Array{Tuple{Float64,Float64},1},Float64}}, ::typeof(bboptimize), ::Function) at none:0
#ODEshoot_opt!#153(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Vesicle{Float64}, ::Tuple{Float64,Float64}, ::Array{Tuple{Float64,Float64},1}) at opt_shooting_methods.jl:113
ODEshoot_opt!(::Vesicle{Float64}, ::Tuple{Float64,Float64}, ::Array{Tuple{Float64,Float64},1}) at opt_shooting_methods.jl:113
top-level scope at none:0

Which seems to me that TopListArchive has type parameter F<:Number for multi objective optimization this tends to be a container though.

alyst commented 5 years ago

Could you pls show your code that constructs the optimization problem? TopListArchive is for scalar optimization only, as are most of the optimization methods except borg_moea(), which uses EpsBoxArchive. So TopListArchive{F<:Number} constraint is correct, but maybe we need to introduce some early checks to ensure that multiobjective problems are solved with the right methods.

BeastyBlacksmith commented 5 years ago

I wrote

function ODEshoot_opt!( vesicle, tspan, parameterRanges; kwargs... )
    opt = bboptimize(
        (p)-> shape_fitness(p, vesicle, tspan);
        Method = :borg_moea,
        FitnessScheme = ParetoFitnessScheme{5}(is_minimizing=true),
        SearchRange = parameterRanges,
        TraceMode = :silent,
        ϵ = 0.05,
        kwargs...
    )
    return opt
end

and called it via

res = VesicleForms.ODEshoot_opt!( copy(VesicleForms.prolate0_9), tspan, [(1e-3,1e2),(-1e2,-1e-3),(1e-1,1e1),(1e-1,1e1),(1e-1,1e2)] )
alyst commented 5 years ago

Thanks! From your trace it looks like bboptimize() doesn't pick up Method=:borg_moea and uses the default (:adaptive_de_rand_1_bin_radiuslimited) instead. However, your example works for me on Julia v1.0.3 for BBO master. What versions are you using?

Also, could you please add 3 @show commands into bboptimize.jl/bbsetup() (assuming you've checked out BBO for developing):

function bbsetup(functionOrProblem, parameters::Parameters = EMPTY_PARAMS; kwargs...)
    @show kwargs2dict(kwargs)
....
    problem, params = setup_problem(functionOrProblem, chain(DefaultParameters, parameters))
    @show params
....
    optimizer_func = chain(SingleObjectiveMethods, MultiObjectiveMethods)[params[:Method]]
    @show optimizer_func
....

and post the output of your script here?

BeastyBlacksmith commented 5 years ago

To be honest, i can't reproduce the error on current master and tagged version 0.4.0. So I'm closing this and sorry for disturbing.