Skip to main content

A Python library for various optimization algorithms

Project description

MetaEvolv

MetaEvolv is a Python library that implements various evolutionary metaheuristic optimization algorithms, including ABC (Artificial Bee Colony), Clonalg (Clonal Selection Algorithm), DE (Differential Evolution), GA (Genetic Algorithm), and PSO (Particle Swarm Optimization).

Installation

To install the library:

pip install metaevolv

Implemented Algorithms

Artificial Bee Colony (ABC)

ABC is an optimization algorithm based on the foraging behavior of honeybees. It is used to find minima of an objective function.

Clonal Selection Algorithm (Clonalg)

Clonalg is an algorithm inspired by the clonal selection process of the immune system. It is used for function minimization.

Differential Evolution (DE)

DE is an evolutionary algorithm that optimizes continuous problems. It uses mutation and crossover operations to evolve a population of solutions.

Genetic Algorithm (GA)

GA is an algorithm inspired by the theory of natural evolution. It uses genetic operators like selection, crossover, and mutation to find optimal solutions.

Particle Swarm Optimization (PSO)

PSO is inspired by the behavior of bird flocks and fish schools. It optimizes an objective function by moving particles through the search space.

How to Use

To use any of the algorithms, you need to import the specific module and configure the algorithm with the desired parameters.

Example: Genetic Algorithm (GA)

Here is an example of how to use the Genetic Algorithm (GA) with MetaEvolv:

import numpy as np
from metaevolv.ga import GeneticAlgorithm, GAConfig

# Define your objective function
def objective_function(x: np.ndarray) -> float:
    return np.sum(x**2)

# Configure the genetic algorithm
config = GAConfig(
    bits=10,
    dimensions=2,
    n_population=50,
    search_range=(-10.0, 10.0),
    k=3,
    cp=0.8,
    mp=0.01,
    max_iter=100,
    selection_type='tournament',
    crossover_type='one_point',
    mutation_type='bit_by_bit',
    pc_variation='constant',
    cp_final=0.9
)

# Instantiate the genetic algorithm with the configuration
ga = GeneticAlgorithm(config, objective_function)

# Run the algorithm
ga.fit()

# Display the results
print(f"Best solution found: {ga.best_ind}")
print(f"Objective function value at the best solution: {ga.best_eval}")

License

This project is licensed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metaevolv-0.1.5.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

metaevolv-0.1.5-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file metaevolv-0.1.5.tar.gz.

File metadata

  • Download URL: metaevolv-0.1.5.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for metaevolv-0.1.5.tar.gz
Algorithm Hash digest
SHA256 492d5de673c0518a3f1c8ceee6b68748bda0ae1abce5b6d2f1ec5efa66878cbd
MD5 b1309d3e849dfe13aefbb8d6d6194f86
BLAKE2b-256 37e70ba94a6b38d1d565cdf88d754ad1b51b33494f7ef8eb7af05c7763206f86

See more details on using hashes here.

File details

Details for the file metaevolv-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: metaevolv-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for metaevolv-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 87cc09f3d4b822179a6e7b42dad5f05387b90f7513bf060d85152179817d14c6
MD5 90677f6c89d380f539aa39b9d2e44e5c
BLAKE2b-256 a8333f321aa1376070e860266d4edab40c94d2c140240b3b37edc5602b16d5ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page