Skip to content
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

Providing initial solution #202

Open
ghost opened this issue Jul 17, 2022 · 1 comment
Open

Providing initial solution #202

ghost opened this issue Jul 17, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 17, 2022

Dear Robert,

A great thanks for providing such a great optimisation algorithm which I use extensively. From your example it is not clear to me how to include the initial guess in my problem:

`SearchRange = SEARCHRANGE(optim, optionHypix)

InitialGuess = [0.3, 0.1,0.0031593277198464265, 0.5, 3.0, 0.8]

Optimization = BlackBoxOptim.bboptimize(X -> OF_HYPIX(..., X, ...); SearchRange=SearchRange, NumDimensions=optim.NparamOpt, TraceMode=:silent, MaxFuncEvals=paramHypix.opt.NmaxFuncEvals)

X = BlackBoxOptim.best_candidate(Optimization)`

Many thanks for any help you may provide and hoping you are enjoying the warm Sweedish summer,
Joseph

@robertfeldt
Copy link
Owner

Hmm, my code from the README still works so I don't really see the problem here. You provide an initial guess as the second argument to bboptimize. I replicate my README code in a new Julia 1.8 here and maybe it helps you find where you go wrong:

julia> versioninfo()
Julia Version 1.8.0
Commit 5544a0fab76 (2022-08-17 13:38 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 8 on 8 virtual cores
Environment:
  JULIA_NUM_THREADS = 8

(@v1.8) pkg> add BlackBoxOptim#master
...

julia> myproblem(x) = (x[1] - 3.14)^2 + (x[2] - 7.2)^4
myproblem (generic function with 1 method)

julia> optimum = [3.14, 7.2]
2-element Vector{Float64}:
 3.14
 7.2

julia> good_guess = [3.0, 7.2]
2-element Vector{Float64}:
 3.0
 7.2

julia> using BlackBoxOptim

julia> res1 = bboptimize(myproblem, good_guess; NumDimensions = 2, SearchRange = (-10.0, 10.0));
...

Best candidate found: [3.14, 7.2]

Fitness: 0.000000000

julia> two_good_guesses = [good_guess, [3.1, 7.3]]
2-element Vector{Vector{Float64}}:

[3.0, 7.2]
 [3.1, 7.3]

julia> res2 = bboptimize(myproblem, two_good_guesses; NumDimensions = 2, SearchRange = (-10.0, 10.0));
...

julia> @assert isapprox(best_fitness(res2), myproblem(optimum); atol = 1e-30)

Please check this code also on your side and then adapt to your own use case. Get back to me if doesn't solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant