Metaheuristics.jl
Metaheuristics is a Julia package implementing metaheuristic algorithms for global optimization that does not require for the optimized function to be differentiable.
Installation: OptimizationMetaheuristics.jl
To use this package, install the OptimizationMetaheuristics package:
import Pkg;
Pkg.add("OptimizationMetaheuristics");Global Optimizer
Without Constraint Equations
A Metaheuristics Single-Objective algorithm is called using one of the following:
Evolutionary Centers Algorithm:
ECA()Differential Evolution:
DE()with 5 different strategiesDE(strategy=:rand1)- default strategyDE(strategy=:rand2)DE(strategy=:best1)DE(strategy=:best2)DE(strategy=:randToBest1)
Particle Swarm Optimization:
PSO()Artificial Bee Colony:
ABC()Gravitational Search Algorithm:
CGSA()Simulated Annealing:
SA()Whale Optimization Algorithm:
WOA()
Metaheuristics also performs Multiobjective optimization, but this is not yet supported by Optimization.
Each optimizer sets default settings based on the optimization problem, but specific parameters can be set as shown in the original Documentation
Additionally, Metaheuristics common settings which would be defined by Metaheuristics.Options can be simply passed as special keyword arguments to solve without the need to use the Metaheuristics.Options struct.
Lastly, information about the optimization problem such as the true optimum is set via Metaheuristics.Information and passed as part of the optimizer struct to solve e.g., solve(prob, ECA(information = Metaheuristics.Information(f_optimum = 0.0)))
The currently available algorithms and their parameters are listed here.
Reexported Metaheuristics.jl API
using OptimizationMetaheuristics brings Metaheuristics.jl's algorithm names into scope, so that solve(prob, ECA()) works without a separate using Metaheuristics. These names are owned and documented by Metaheuristics.jl; this package only re-exports them.
- Single objective:
ECA,DE,PSO,ABC,CGSA,SA,WOA,GA,SHADE,RDEx,εDE,MCCGA,BRKGA,CSO,GRASP,VND,VNS - Multi objective and constrained:
NSGA2,NSGA3,SMS_EMOA,SPEA2,MOEAD_DE,CCMO - The
Metaheuristicsmodule itself
Metaheuristics' configuration objects keep the qualified spelling the examples above use — Metaheuristics.Options, Metaheuristics.Information — because Options is far too generic a name to put into every namespace. Its own Metaheuristics.optimize driver and its multi-criteria decision-making surface are not re-exported either.
DE, GA and NSGA2 are also exported by Evolutionary.jl. If you load both OptimizationMetaheuristics and OptimizationEvolutionary, qualify those three.
Anything else from Metaheuristics.jl must be imported from Metaheuristics directly.
Notes
The algorithms in Metaheuristics are performing global optimization on problems without constraint equations. However, lower and upper constraints set by lb and ub in the OptimizationProblem are required.
Examples
The Rosenbrock function can be optimized using the Evolutionary Centers Algorithm ECA() as follows:
using OptimizationBase, OptimizationMetaheuristics
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
x0 = zeros(2)
p = [1.0, 100.0]
f = OptimizationFunction(rosenbrock)
prob = OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
sol = solve(prob, ECA(), maxiters = 100000, maxtime = 1000.0)retcode: Default
u: 2-element Vector{Float64}:
1.0
1.0Per default Metaheuristics ignores the initial values x0 set in the OptimizationProblem. In order to for Optimization to use x0 we have to set use_initial=true:
sol = solve(prob, ECA(), use_initial = true, maxiters = 100000, maxtime = 1000.0)retcode: Default
u: 2-element Vector{Float64}:
1.0
1.0With Constraint Equations
While Metaheuristics.jl supports such constraints, Optimization.jl currently does not relay these constraints.