A Python Library for Building the Genetic Algorithm.
Project description
pyreda
pyreda is a Python library for implementing and running Genetic Algorithms (GAs). It provides an easy-to-use interface to configure and execute GAs with customizable parameters for selection, crossover, and mutation.
Features
- Customizable fitness functions
- Support for tournament selection
- One-point crossover
- Bit-flip mutation
- Configurable mutation rates and number of generations
Installation
You can install pyreda via pip:
pip install pyreda
Usage
Here’s a basic example of how to use pyreda to run a genetic algorithm:
import SimpleGA from pyreda
from pyreda import SimpleGA
import numpy as np
Define a custom fitness function
# Example: Sum of all genes
def custom_fitness(individual):
return np.sum(individual)
Create an instance of the SimpleGA class
ga = SimpleGA.SimpleGA(
population_size=10, # Size of the population
gene_length=5, # Length of each individual
fitness_function=custom_fitness, # Fitness function to evaluate individuals
mutation_rate=0.01, # Mutation rate
generations=20 # Number of generations to evolve
)
Parameters:
population_size: Number of individuals in the population.
gene_length: Length of the individual’s gene sequence.
fitness_function: Function to evaluate the fitness of an individual.
mutation_rate: Probability of mutation for each gene.
generations: Number of generations for the algorithm to run.
Run the genetic algorithm
ga.run()
Contributing
If you’d like to contribute to the development of pyreda, please fork the repository and submit a pull request. We welcome improvements and bug fixes.
License
pyreda is licensed under the MIT License. See the LICENSE file for details.
Contact
For questions or support, please contact Reda Ghanem at reda.ghanem66@gmail.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyreda-0.1.5.tar.gz.
File metadata
- Download URL: pyreda-0.1.5.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3f04ad07dfe50115960cd7d87382d1fa7e9e2e15d94635e6189d7ff32b02df3
|
|
| MD5 |
9461b44906146f588b4ef09b95e6c266
|
|
| BLAKE2b-256 |
f371c365f8e64c8bf98196e7fbe324f13bbf0fd19784cc2fc31c78a8270786af
|
File details
Details for the file pyreda-0.1.5-py3-none-any.whl.
File metadata
- Download URL: pyreda-0.1.5-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a69c2f497a2e2710179fccec6e14c1420d0cf3a427f73f6f77467b3fb4bdef3
|
|
| MD5 |
3e83406296bd1fe0535a19ad581b8b10
|
|
| BLAKE2b-256 |
fb148efecab768026655707333eadaf42b220081da5cb521a566a4bc92706eab
|