# Key BlackBoxOptim not found

**URL:** <https://discourse.julialang.org/t/key-blackboxoptim-not-found/65919>\
**Category:** Performance\
**Tags:** parallel, optimization\
**Created:** [August 6, 2021, 1:31am UTC](https://discourse.julialang.org/t/key-blackboxoptim-not-found/65919 "2021-08-06T01:31:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mengxiaoliu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mengxiaoliu/32/23601_2.png) [@mengxiaoliu](https://discourse.julialang.org/u/mengxiaoliu)\
**Post date:** [August 6, 2021, 1:31am UTC](https://discourse.julialang.org/t/key-blackboxoptim-not-found/65919/1 "2021-08-06T01:31:45Z")

</div>

Hello,  
I am examining the parallel computing speed in BlackBoxOptim by optimizing the Rosebrock function using codes adapted from [rosenbrock\_parallel.jl](https://github.com/robertfeldt/BlackBoxOptim.jl/blob/83c811671c00fffdcaadf042ad07ee2e2194ecbf/examples/rosenbrock_parallel.jl) by @robertfeldt. The code I run is as follows:

```julia
using Distributed
@everywhere using CSV
@everywhere using Tables
@everywhere using BlackBoxOptim
for i = 1:56
  addprocs(1)
  println("Number of workers: ", nworkers())
  opt = bbsetup(BlackBoxOptim.rosenbrock; SearchRange = (-5.0, 5.0), Workers = workers(), NumDimensions = 20000, MaxFuncEvals = 10, TraceMode = :silent)
  el = @elapsed res = bboptimize(opt)
  t = round(el, digits=3)
  v = [i; t]
  println("workers: "v[1], "; time: ", v[2])
end

```

I encounter the following error message:

> KeyError: key BlackBoxOptim [a134a8b2-14d6-55f6-9291-3336d3ab0209] not found

Could anyone tell me how to fix it? Thanks so much!

---

<div class="post-metadata">

**Author:** ![mengxiaoliu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mengxiaoliu/32/23601_2.png) [@mengxiaoliu](https://discourse.julialang.org/u/mengxiaoliu)\
**Post date:** [August 6, 2021, 2:49pm UTC](https://discourse.julialang.org/t/key-blackboxoptim-not-found/65919/2 "2021-08-06T14:49:00Z")

</div>

I think I have found the solution. The addprocs() function should be placed before loading all the other packages, so instead of putting the other packages outside the loop, my code should be like:

```julia
using Distributed
for i = 1:56
  addprocs(1)
    @everywhere using CSV
    @everywhere using Tables
    @everywhere using BlackBoxOptim
  println("Number of workers: ", nworkers())
  opt = bbsetup(BlackBoxOptim.rosenbrock; SearchRange = (-5.0, 5.0), Workers = workers(), NumDimensions = 20000, MaxFuncEvals = 10, TraceMode = :silent)
  el = @elapsed res = bboptimize(opt)
  t = round(el, digits=3)
  v = [i; t]
  println("workers: "v[1], "; time: ", v[2])
end

```
