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.
Metadata
Release files for pyreda 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyreda-0.1.5.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyreda-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / pyreda-0.1.5.tar.gz
| Download URL | pyreda-0.1.5.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3f04ad07dfe50115960cd7d87382d1fa7e9e2e15d94635e6189d7ff32b02df3
|
|
BLAKE2b-256 checksum How to use checksums |
f371c365f8e64c8bf98196e7fbe324f13bbf0fd19784cc2fc31c78a8270786af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.12
|
Release files / pyreda-0.1.5-py3-none-any.whl
| Download URL | pyreda-0.1.5-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a69c2f497a2e2710179fccec6e14c1420d0cf3a427f73f6f77467b3fb4bdef3
|
|
BLAKE2b-256 checksum How to use checksums |
fb148efecab768026655707333eadaf42b220081da5cb521a566a4bc92706eab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.12
|