Metaheuristics.jl

repository·master·Indexed 43 days ago

https://github.com/jmejia8/metaheuristics.jl

A high-performance Julia package for global optimization supporting single-objective, multi-objective, and combinatorial problems. It implements a wide range of algorithms including NSGA-II, NSGA-III, PSO, Differential Evolution (DE), Simulated Annealing (SA), and GRASP. The library provides tools for performance indicators (HV, IGD), multi-criteria decision-making (MCDM), and supports batch evaluation for parallel computing.

Tokens
19.8K
Snippets
66
Records
93
Agent score
55%

What's inside Metaheuristics.jl

  1. Use Performance Indicators to assess algorithms

    master

    Metaheuristics.jl provides a suite of performance indicators to evaluate the quality of evolutionary optimization algorithms.

    Important: Minimization Assumption All indicators in Metaheuristics.jl assume a minimization problem. If your problem is a maximization problem, you must transform it before using these indicators.

    Available indicator categories include:

    • Pareto Front Utilities: General utilities for Pareto fronts.
    • Accuracy Indicators: gd (Generational Distance), gd_plus, igd (Inverted Generational Distance), and igd_plus to assess how close approximations are to the true Pareto front.
    • Diversity/Distribution Indicators: spacing, covering ($C$-metric), and hypervolume.
    • Distance/Hausdorff Indicators: deltap ($\Delta_p$) and epsilon_indicator ($\varepsilon$-indicator).
  2. Use Single-objective Optimization Algorithms

    master

    The metaheuristics.jl package provides a variety of algorithms designed for single-objective optimization problems. These algorithms include evolutionary, swarm-based, and physics-inspired metaheuristics.

    Available algorithms include:

    • Evolutionary Centers Algorithm (ECA): For global optimization.
    • Differential Evolution (DE): An evolutionary algorithm based on vector differences.
    • Particle Swarm Optimization (PSO): Population-based technique inspired by bird flocks and fish schooling.
    • Artificial Bee Colony (ABC): Efficient for numerical function optimization.
    • Chaotic Gravitational Search Algorithm (CGSA): Uses chaotic gravitational constants.
    • Simulated Annealing (SA): Physics-inspired optimization.
    • Whale Optimization Algorithm (WOA): Mimics humpback whale social behavior.
    • BCA (Bilevel Centers Algorithm): Specifically for bilevel optimization problems (note: this is part of the BilevelHeuristics.jl ecosystem).
    • MCCGA: Machine-coded Compact Genetic Algorithms for real-valued optimization.
    • GA: Genetic Algorithms.
    • $\varepsilon$DE: Constrained Differential Evolution (Note: Gradient-based mutation is currently not implemented).
    • SHADE and CSO.
  3. Represent N-Queens solutions using PermutationSpace

    master

    When solving the N-Queens problem, using a PermutationSpace(N) is more efficient than a binary matrix (BitArraySpace(N*N)). A permutation-based representation ensures that no two queens share the same row or column, significantly reducing the search space cardinality by eliminating horizontal and vertical attacks by design.

    using Metaheuristics
    N = 8
    # Compare search space sizes
    cardinality(BitArraySpace(N*N))
    cardinality(PermutationSpace(N))
  4. Enable batch evaluation for parallel computing

    master

    Algorithms marked with ✅ in the Batch Evaluation column support simultaneous evaluation of multiple solutions. This is useful for parallel computing (threads/distributed systems), GPU acceleration, or handling expensive function evaluations.

    To enable this feature, set parallel_evaluation=true in the Options object.

    # Example configuration (conceptual)
    options = Options(parallel_evaluation=true)
  5. Use Greedy Randomized Adaptive Search Procedure (GRASP)

    master

    GRASP is a metaheuristic that combines a construction phase with a local search phase. It involves using a greedy randomized constructor to build solutions and then refining them.

    Key components include:

    • Metaheuristics.GreedyRandomizedConstructor: The logic for constructing solutions.
    • Metaheuristics.construct: The method used to build a solution.
    • Metaheuristics.compute_cost: The method used to evaluate the cost of a solution.
  6. How the optimization process works in Metaheuristics.jl

    master

    When the optimize function is called, the library follows a specific lifecycle consisting of three main stages:

    1. Initialization: The initialize! function is called to create a State object. This typically involves generating an initial population based on the provided parameters and problem bounds.
    2. Main optimization loop: The library enters a loop that continues as long as status.stop == false. In each iteration, it calls:
      • update_state!: To evolve the population or update parameters.
      • stop_criteria!: To check if the algorithm should terminate (e.g., based on iteration count or function evaluations).
    3. Final Stage: Once the loop terminates, final_stage! is called to perform final cleanup, such as extracting the best solution from a population or handling infeasible solutions.