[ANN] Metaheuristics.jl

After several years of development, I share with you Metaheuristics.jl

This package implements state-of-the-art metaheuristic algorithms for single and multi-objective optimization. The aim of this package is to provide easy to use (and fast) metaheuristics for numerical global optimization.

Metaheuristics.jl includes:

  • Popular algorithms such as Differential Evolution, PSO, NSGA-II, NSGA-III, and more…
  • Performance Indicators such as IGD, hypervolume, among others.
  • Test Problems for single and multi-objective optimization.
  • Some visualization features in terminal via UnicodePlots.jl

Example 1

Objective function:

julia> f(x) = 10length(x) + sum( x.^2 - 10cos.(2Ο€*x)  )
f (generic function with 1 method)

Bounds for x∈ [-5,5]⁡ :

julia> bounds = [-5ones(5) 5ones(5)]
5Γ—2 Matrix{Float64}:
 -5.0  5.0
 -5.0  5.0
 -5.0  5.0
 -5.0  5.0
 -5.0  5.0

Optimize:

julia> result = optimize(f, bounds)
+=========== RESULT ==========+
  iteration: 1429
    minimum: 0
  minimizer: [1.8792427588475406e-10, 1.6562253377998926e-9, -2.2532566630145983e-9, 1.649414863704028e-9, 4.005275371381464e-9]
    f calls: 49981
 total time: 0.2483 s
+============================+

Example 2

julia> f, bounds, front = Metaheuristics.TestProblems.ZDT3();

julia> optimize(f, bounds, NSGA2())
+=========== RESULT ==========+
  iteration: 500
...
non-dominated solution(s):
                           F space
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” 
        2 β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ 
          β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ 
          β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ 
          β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ 
          β”‚β‘€β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ 
          β”‚β’£β’€β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ 
          β”‚β €β ˜β ²β €β €β €β €β €β‘„β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ 
   f_2    β”‚β €β €β €β €β €β €β €β €β ˆβ’†β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ 
          β”‚β €β €β €β €β €β €β €β €β €β ˆβ ’β‘„β €β €β €β €β €β €β‘€β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ 
          β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’±β‘€β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ 
          │⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠻⠍⠉⠉⠉⠉⠉⠉⒭⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉│ 
          β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β ˜β‘„β €β €β €β €β €β €β €β €β €β €β €β”‚ 
          β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β ™β €β €β €β €β €β €β €β’°β €β €β €β”‚ 
          β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β ˆβ’‡β €β €β”‚ 
       -1 β”‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β”‚ 
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ 
          0                                      0.9
                             f_1
    f calls: 50000
  feasibles: 100 / 100 in final population
 total time: 1.4626 s
+============================+

Comments and suggestions are welcome.

27 Likes

Congratulations on the package! I see you have some constraint handling in some of the algorithms. I think this might be the first Julia package for metaheuristics that can handle equality and inequality constraints natively. Would be great to create a wrapper for Metaheuristics in Nonconvex.jl.

6 Likes

Thanks for your comment. Good suggestion!

1 Like

Looks like a great package!

Very often I need to optimize expensive black-box functions, and having an optimizer that offers multi-threaded, simultaneous evaluation of multiple candidate solutions significantly reduces execution time. Please consider adding this option to your population-based optimizers.

3 Likes

That is a great suggestion. The evaluation of multiple solutions will be included in future versions.

2 Likes