Skip to content

Commit

Permalink
use rosenbrock for example since it gives smoother fitness progressio…
Browse files Browse the repository at this point in the history
…n so shows the interface in a better way
  • Loading branch information
robertfeldt committed Mar 19, 2020
1 parent 772b2c3 commit 45a3222
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions examples/vega_lite_fitness_graph_frontend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ function callback(oc)
end

# Func to optimize.
function rastrigin(x)
D = length(x)
10 * D + sum(abs2, x) - 10 * sum(xx -> cos(2π * xx), x)
function rosenbrock(x)
sum(i -> 100*abs2(x[i+1] - x[i]^2) + abs2(x[i] - 1), Base.OneTo(length(x)-1))
end

# Now optimize for 2 minutes.
# Go to http://127.0.0.1:8081 to view fitness progress!
res = bboptimize(rastrigin;
SearchRange=(-5.12,5.12), NumDimensions = 50,
res = bboptimize(rosenbrock;
SearchRange=(-10.0,10.0), NumDimensions = 500,
PopulationSize=100, MaxTime=2*60.0,
CallbackFunction = callback, CallbackInterval = 2.0);
println("Best fitness = ", best_fitness(res))

0 comments on commit 45a3222

Please sign in to comment.