Skip to main content

Evolutionary-Optimization

A generic evolutionary algorithm for function optimization.

Introduction

This package allows the user to optimise a function using an evolutionary algorithm. An evolutionary algorithm uses the principles of evolution to find optimal solutions.

Using the Package

Getting Started

To get started with this package install this package:

pip install evolutionary-optimization-algorithm

Running Experiments

To run the code type the following in your terminal. The default experiment is a simple optimization of the $x^{2}$ using integers.

run_evolution

The parameters used for the run can be edited within the main.py file.

Personalising Experiments

To personalise your experiment you can either use the prebuilt phenotypes and genotypes using our interface, or you can build your own. To do so, you simply need to create a new phenotype / genotype class that inherits from the corresponding abstract class and implement the methods to suit your needs. You can mimic the structure of the main script to run your own experiments, like so:

    genotype_class = Genotype.get_genotype(Genotypes.<your_phenotype>)
    phenotype_class = Phenotype.get_phenotype(Phenotypes.<your_genotype>)
    fitness_function_class = FitnessFunction.get_fitness_function(FitnessFunctions.<your_fitness_function>)
    fitness_function_instance = fitness_function_class()

    evolutionary_algorithm = Evolution(
        phenotype=phenotype_class(genotype_class()),
        number_of_individuals=<desired_number_of_individuals>,
        number_of_generations=<desired_number_of_generations>,
        fitness_function=fitness_function_instance,
        ratio_of_elite_individuals=<desired_elitism_ratio>
    )

You can also plot your fitness over time and the phenotype over time:

    evolutionary_algorithm.plot_fitness_score_over_time()
    phenotype_function_points_tuple = generate_points_for_function(
        phenotype=evolutionary_algorithm.population.best_individual,
        bottom_plotting_limit=-10,
        upper_plotting_limit=10,
        number_of_points=100,
    )
    evolutionary_algorithm.plot_phenotype_function_and_best_individuals(phenotype_function_points_tuple)

or plot a gif of the algorithm over time:

    evolutionary_algorithm.create_gif(phenotype_function_points_tuple)

Metadata

Release files for evolutionary-optimization-algorithm 3.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for evolutionary-optimization-algorithm 3.0.5
File Size Uploaded
evolutionary-optimization-algorithm-3.0.5.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for evolutionary-optimization-algorithm 3.0.5
File Interpreter ABI Platform
evolutionary_optimization_algorithm-3.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 44.2 kB

Release files / evolutionary-optimization-algorithm-3.0.5.tar.gz

Download URL evolutionary-optimization-algorithm-3.0.5.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
160719bebed183d4612c3a843056a67e4e9d533592257bd1d880d2b7c9e85bd2
BLAKE2b-256 checksum
How to use checksums
d3275697800e9e35e813cbd704496f70fca7670555579c4543f357dbe07ae2ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.8.12 Linux/5.13.0-1023-aws

Release files / evolutionary_optimization_algorithm-3.0.5-py3-none-any.whl

Download URL evolutionary_optimization_algorithm-3.0.5-py3-none-any.whl
Size 29.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50dd184c1e377d7c9abd87333a3afb45fef7902b30b4c74e8ee1053a4251e69e
BLAKE2b-256 checksum
How to use checksums
595e55ee65c17d2c8bfe14ad6d97dd28e24d1c79bfc7de9eebf3e9941bf1eed9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.8.12 Linux/5.13.0-1023-aws

Release history Release notifications | RSS feed

This release

3.0.5 This release

2 release files

3.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page