-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERROR: AssertionError: target[2]=-1.6719276998174588 is out of [-4.920818753952375, -2.9208187539523753] #194
Comments
Sorry to hear this. Can you show some more info about your problem setup and the call to bboptimize etc so we can help you find the problem? |
This is how I'm starting the algorithm
Please let me know if I can help somehow in this.. I tried to look at the actual code, nothing very suspicious. BTW, the separable_nes worked without errors (but I'd like to use generating_set_search, much more convenient for my task). And actually all the algorithms worked before, when range values were positive. Now range values are negative. |
I assume you mean Seems it depends on your fitness function then since this works for me: using BlackBoxOptim
SearchRange = [(-3.60206, -1.60206), (-4.92082, -2.92082)]
NumDimensions = 2
Method = :generating_set_search
MaxTime = 5
function somefitness2d(x)
return (1.0 - x[1])^2 + 100.0 * (1.3 + x[2] - x[1]^4)^2
end
opt0 = bbsetup(somefitness2d; Method, SearchRange, MaxTime, NumDimensions)
res0 = bboptimize(opt0)
...
bf0 = best_fitness(res0) # returns 6744.284995235647 So I need more info about your fitness function in order to try to help you. There doesn't seem to be some obvious problem in BBO with negative search ranges. |
As a temporary solution you can always try to invert the search range and then negate the values in your fitness function. Example for above: using BlackBoxOptim
SearchRange = [(-3.60206, -1.60206), (-4.92082, -2.92082)]
InvertedSearchRange = map(t -> (-last(t), -first(t)), SearchRange)
NumDimensions = 2
Method = :generating_set_search
MaxTime = 5
function inverting_somefitness2d(x)
x = -1.0 .* x
return (1.0 - x[1])^2 + 100.0 * (1.3 + x[2] - x[1]^4)^2
end
opt0 = bbsetup(inverting_somefitness2d; Method, SearchRange = InvertedSearchRange, MaxTime, NumDimensions)
res0 = bboptimize(opt0) which finds the exact same best candidate (of course you have to invert it back). |
So you are not providing some initial solutions to your search? Since if you do and they are not in the given search range bounds that might lead to problems. The ability to provide initial solutions was recently introduced and might not be as tested. |
Actually I can replicate your problem if I initialise the search with an initial solution outside of the search range: using BlackBoxOptim
SearchRange = [(-3.60206, -1.60206), (-4.92082, -2.92082)]
NumDimensions = 2
Method = :generating_set_search
MaxTime = 5
function somefitness2d(x)
return (1.0 - x[1])^2 + 100.0 * (1.3 + x[2] - x[1]^4)^2
end
opt0 = bbsetup(somefitness2d; Method, SearchRange, MaxTime, NumDimensions)
outlier = [-10.0, -10.0]
res0 = bboptimize(opt0, outlier)
...
Starting optimization with optimizer GeneratingSetSearcher(BlackBoxOptim.ConstantDirectionGen)
0.00 secs, 2 evals, 0 steps, fitness=510319.642458021
ERROR: AssertionError: target[1]=-4.277614948471471 is out of [-3.60206, -1.60206]
Stacktrace:
[1] apply!(eo::RandomBound{ContinuousRectSearchSpace}, target::Vector{Float64}, ref::Vector{Float64})
@ BlackBoxOptim ~/.julia/packages/BlackBoxOptim/jCUUF/src/genetic_operators/embedding/random_bound.jl:34
[2] step!(gss::BlackBoxOptim.GeneratingSetSearcher{BlackBoxOptim.ProblemEvaluator{Float64, Float64, TopListArchive{Float64, ScalarFitnessScheme{true}}, FunctionBasedProblem{typeof(somefitness2d), ScalarFitnessScheme{true}, ContinuousRectSearchSpace, Nothing}}, BlackBoxOptim.ConstantDirectionGen, RandomBound{ContinuousRectSearchSpace}})
@ BlackBoxOptim ~/.julia/packages/BlackBoxOptim/jCUUF/src/generating_set_search.jl:127
[3] step!
@ ~/.julia/packages/BlackBoxOptim/jCUUF/src/opt_controller.jl:280 [inlined]
[4] run!(ctrl::BlackBoxOptim.OptRunController{BlackBoxOptim.GeneratingSetSearcher{BlackBoxOptim.ProblemEvaluator{Float64, Float64, TopListArchive{Float64, ScalarFitnessScheme{true}}, FunctionBasedProblem{typeof(somefitness2d), ScalarFitnessScheme{true}, ContinuousRectSearchSpace, Nothing}}, BlackBoxOptim.ConstantDirectionGen, RandomBound{ContinuousRectSearchSpace}}, BlackBoxOptim.ProblemEvaluator{Float64, Float64, TopListArchive{Float64, ScalarFitnessScheme{true}}, FunctionBasedProblem{typeof(somefitness2d), ScalarFitnessScheme{true}, ContinuousRectSearchSpace, Nothing}}})
@ BlackBoxOptim ~/.julia/packages/BlackBoxOptim/jCUUF/src/opt_controller.jl:321
[5] run!(oc::BlackBoxOptim.OptController{BlackBoxOptim.GeneratingSetSearcher{BlackBoxOptim.ProblemEvaluator{Float64, Float64, TopListArchive{Float64, ScalarFitnessScheme{true}}, FunctionBasedProblem{typeof(somefitness2d), ScalarFitnessScheme{true}, ContinuousRectSearchSpace, Nothing}}, BlackBoxOptim.ConstantDirectionGen, RandomBound{ContinuousRectSearchSpace}}, FunctionBasedProblem{typeof(somefitness2d), ScalarFitnessScheme{true}, ContinuousRectSearchSpace, Nothing}})
@ BlackBoxOptim ~/.julia/packages/BlackBoxOptim/jCUUF/src/opt_controller.jl:470
[6] bboptimize(optctrl::BlackBoxOptim.OptController{BlackBoxOptim.GeneratingSetSearcher{BlackBoxOptim.ProblemEvaluator{Float64, Float64, TopListArchive{Float64, ScalarFitnessScheme{true}}, FunctionBasedProblem{typeof(somefitness2d), ScalarFitnessScheme{true}, ContinuousRectSearchSpace, Nothing}}, BlackBoxOptim.ConstantDirectionGen, RandomBound{ContinuousRectSearchSpace}}, FunctionBasedProblem{typeof(somefitness2d), ScalarFitnessScheme{true}, ContinuousRectSearchSpace, Nothing}}, x0::Vector{Float64}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ BlackBoxOptim ~/.julia/packages/BlackBoxOptim/jCUUF/src/bboptimize.jl:75
[7] bboptimize(optctrl::BlackBoxOptim.OptController{BlackBoxOptim.GeneratingSetSearcher{BlackBoxOptim.ProblemEvaluator{Float64, Float64, TopListArchive{Float64, ScalarFitnessScheme{true}}, FunctionBasedProblem{typeof(somefitness2d), ScalarFitnessScheme{true}, ContinuousRectSearchSpace, Nothing}}, BlackBoxOptim.ConstantDirectionGen, RandomBound{ContinuousRectSearchSpace}}, FunctionBasedProblem{typeof(somefitness2d), ScalarFitnessScheme{true}, ContinuousRectSearchSpace, Nothing}}, x0::Vector{Float64})
@ BlackBoxOptim ~/.julia/packages/BlackBoxOptim/jCUUF/src/bboptimize.jl:65
[8] top-level scope
@ REPL[9]:1 So this seems it could be the problem also in your case. |
Ok, I've now added checking of the initial starting points as well as tests for this: If you try your problem on latest master you should hopefully see an ArgumentError raised. |
Thanks for looking into this! I'm not providing any initial starting point actually (but will do in future). The function evaluation is not easy to reproduce (setup may take days). I will try to shift the search range into positive field, will see how it is working.. I'm doing log10 transformation for range and all the variables already (that's why the range is negative), so it should be quite straightforward.. |
And I'm using master branch already.. will update. |
Ok, then it is hard for me to debug. My guess is that for your problem there are optima very close to the bounding box (Search range border) so when candidate solutions are combined they step out of the box and are not properly bounded. This should not happen since the RandomBounding operator should be applied after the other (genetic) operators have been applied but apparently it doesn't in your case. This is in line with XNES (and its close "cousins") working since for it/them one currently cannot enforce a search range bounding box. Can you check if the optima returned by for example DXNES is outside of the Search range? |
Can you please pull latest from this branch and run on your problem: https://github.com/robertfeldt/BlackBoxOptim.jl/tree/random_bound_assertion_error I added some logging to try to pinpoint where this goes wrong for your problem. Only on generating_set_search though so please use that on your problem and report back, thanks. |
|
ok, it doesn't even get into the generating set searcher. Very strange. Hard for me to debug at a distance... |
Please check the inverted search range and see what happens then. |
Finally I implemented a shift for all the range values to the positive aria. Now everything looks like working as expected. |
Glad to hear it. I still don't understand why it doesn't work in the negative range for your case but if you get more info in the future don't hesitate to re-open this issue. I'm closing it for now. |
Again, after some time I got this; this time it was 1D case, positive range..
|
this was with adaptive_de_rand_1_bin_radiuslimited solver |
Yeah, it is the same assertion error but since I haven't seen this for any other fitness function it is very hard to debug further. Is there some way you could share the fitness function you are using here or is this very hard / impossible? Since I'm not yet sure where to look it is hard to introduce logging in all the "right" places so debugging this at a distance is very hard, sorry. |
Will try to make a fitness function which would be possible to share. And which creates same issues. |
I just had the same issue running version 0.6.1 with the default optimizer. But if the default search range is (-1., 1.) I actually started with an initial solution outside of that range. The problem did not reappear after I chose an initial solution within the specified search space. |
Hello,
I tried
adaptive_de_rand_1_bin
,adaptive_de_rand_1_bin_radiuslimited
andgenerating_set_search
so far, all with similar results.example of the stack trace:
The text was updated successfully, but these errors were encountered: