pycellga
pycellga: A Python package for improved cellular genetic algorithms - Published in JOSS (2025)
Science Score: 98.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 9 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org -
○Committers with academic emails
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Scientific Fields
Repository
Cellular Genetic Algorithms in Python.
Basic Info
- Host: GitHub
- Owner: SevgiAkten
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://sevgiakten.github.io/pycellga/
- Size: 8.87 MB
Statistics
- Stars: 3
- Watchers: 2
- Forks: 3
- Open Issues: 0
- Releases: 6
Topics
Metadata Files
README.md
pycellga: A Python Package for Improved Cellular Genetic Algorithms
pycellga is a Python package that implements cellular genetic algorithms (CGAs) for optimizing complex problems. CGAs combine the principles of cellular automata and traditional genetic algorithms, utilizing a spatially structured population organized in a grid-like topology. This structure allows each individual to interact only with its neighboring individuals, promoting diversity and maintaining a balance between exploration and exploitation during the optimization process. pycellga has machine coded operators with byte implementations. Beside it has Alpha-male CGA, Machine Coded Compact CGA and Improved CGA with Machine Coded Operators for real-valued optimization problems. The pycellga package is designed to handle a wide range of optimization problems, including binary, real-valued, and permutation-based challenges, making it a versatile tool for diverse applications in evolutionary computation.
Features
- Cellular Genetic Algorithm (
cga): Efficient implementation of CGAs with various built-in functions for diverse applications. - Improved CGA with Machine-Coded Operators: Enhanced performance in real-valued optimization problems through the use of
machine-codedbyte operators. - Synchronous Cellular Genetic Algorithm (
sync_cga): Simultaneous update of all individuals (cells) in each iteration for synchronized evolution. - Alpha Male Cellular Genetic Algorithm (
alpha_cga): Population divided into social groups, with each group consisting of females selecting the same alpha male. - Compact Cellular Genetic Algorithm (
ccga): Integrates the principles of Cellular Genetic Algorithms with those of Compact Genetic Algorithms for memory efficiency. - Machine-Coded Compact Cellular Genetic Algorithm (
mcccga): Applies machine-coded compact GA to a cellular structure for optimizing real-valued problems. - Customizable: Offers various customization options to adapt to different optimization problems.
Installation
You can install pycellga via pip:
bash
pip install pycellga
Documentation
For full documentation, visit here or click the badge below:
Usage Examples
In this section, we'll explain cga method in the optimizer and provide an example of how to use it. The package includes various ready-to-use crossover and mutation operators, along with real-valued, binary, and permutation functions that you can run directly. Examples for other methods are available in the example folder, while an example for cga is provided below.
cga (Cellular Genetic Algorithm)
cga is a type of genetic algorithm where the population is structured as a grid (or other topologies), and each individual interacts only with its neighbors. This structure helps maintain diversity in the population and can prevent premature convergence. To specialize the CGA for real-valued optimization problems, ICGA (Improved CGA) with machine-coded representation can be used, applying byte operators. The encoding and decoding of numbers follow the IEEE 754 standard for floating-point arithmetic, yielding better results for continuous functions.
Example Problem
Suppose we have a problem that we want to minimize using a Cellular Genetic Algorithm (CGA). The problem is defined as a simple sum of squares function, where the goal is to find a chromosome (vector) that minimizes the function.
The sum of squares function computes the sum of the squares of each element in the chromosome. This function reaches its global minimum when all elements of the chromosome are equal to 0. The corresponding function value at this point is 0.
ExampleProblem Class
Here’s how we can define this problem in Python using the ExampleProblem class:
```python from mpmath import power as pw from typing import List
from pycellga.optimizer import cga from pycellga.recombination.byteonepointcrossover import ByteOnePointCrossover from pycellga.mutation.bytemutationrandom import ByteMutationRandom from pycellga.selection.tournamentselection import TournamentSelection from pycellga.problems.abstract_problem import AbstractProblem from pycellga.common import GeneType
class ExampleProblem(AbstractProblem):
def __init__(self, n_var):
super().__init__(
gen_type=GeneType.REAL,
n_var=n_var,
xl=-100,
xu=100
)
def f(self, x: List[float]) -> float:
return round(sum(pw(xi, 2) for xi in x),3)
``` Usage:
```python result = cga( ncols=5, nrows=5, ngen=100, chsize=5, pcrossover=0.9, pmutation=0.2, problem=ExampleProblem(nvar=5), selection=TournamentSelection, recombination=ByteOnePointCrossover, mutation=ByteMutationRandom, seedpar=100 )
# Print the results
print("Best solution chromosome:", result.chromosome)
print("Best fitness value:", result.fitness_value)
Expected Output:
Best solution chromosome: [0.0, 0.0, 0.0, 0.0, 0.0]
Best fitness value: 0.0
```
We have provided a basic example above. If you're interested in exploring more examples, you have two options:
- Click here to see the other examples available directly in the repository.
- Please click here to see the documentation for more detailed examples and explanations.
Contributing
Contributions are welcome! Please read the contributing guidelines first.
Testing
To ensure that pycellga works as expected, we have provided a comprehensive suite of tests. Follow these steps to run the tests locally:
Install dependencies: Make sure you have installed all the necessary dependencies from
requirements.txt. You can install them using the following command:bash pip install -r requirements.txtRun tests: Navigate to the root directory of the project and run the test suite using
pytest.bash pytestThis will automatically discover and execute all the test cases.
Check code coverage (Optional): You can check the test coverage of the package using
pytest-cov. First, ensure you have installedpytest-cov:bash pip install pytest-covThen, run the tests with coverage reporting:
bash pytest --cov=pycellgaA summary of code coverage will be displayed in the terminal.
Generate coverage reports: If you want a detailed HTML report of the code coverage, run:
bash pytest --cov=pycellga --cov-report=htmlOpen the
htmlcov/index.htmlfile in a web browser to view the detailed coverage report.Add new tests (if applicable):
- If your changes introduce new features or modify existing functionality, write additional test cases to cover these changes.
- Place your tests in the appropriate subdirectory within the
testsfolder, following the naming conventiontest_<feature_name>.py.
Review testing guidelines:
- Ensure your tests follow the existing style and structure used in the project. Use descriptive function names and provide comments where necessary to clarify the test's purpose.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
Developed by Sevgi Akten Karakaya and Mehmet Hakan Satman. Inspired by traditional genetic algorithms and cellular automata principles with machine coded operators. For more information, please visit the project repository.
Citation
If you use pycellga in your research, please cite it as follows:
APA Format
Karakaya, S. A., & Satman, M.H. (2025). pycellga: A Python package for improved cellular genetic algorithms. Journal of Open Source Software, 10(105), 7322. https://doi.org/10.21105/joss.07322
BibTeX Format
For LaTeX users, please use the following BibTeX entry to cite pycellga:
```bibtex @article{karakaya2025pycellga, author = {Sevgi Akten Karakaya and Mehmet Hakan Satman}, title = {pycellga: A Python package for improved cellular genetic algorithms}, journal = {Journal of Open Source Software}, year = {2025}, volume = {10}, number = {105}, pages = {7322}, doi = {10.21105/joss.07322}, url = {https://doi.org/10.21105/joss.07322} }
Owner
- Name: Sevgi Akten
- Login: SevgiAkten
- Kind: user
- Location: Turkey
- Repositories: 11
- Profile: https://github.com/SevgiAkten
JOSS Publication
pycellga: A Python package for improved cellular genetic algorithms
Authors
Tags
genetic algorithms cellular automatonCitation (CITATION.cff)
cff-version: "1.2.0"
authors:
- family-names: Karakaya
given-names: Sevgi Akten
orcid: "https://orcid.org/0000-0001-9346-5795"
- family-names: Satman
given-names: Mehmet Hakan
orcid: "https://orcid.org/0000-0002-9402-1982"
doi: 10.5281/zenodo.14539107
message: If you use this software, please cite our article in the
Journal of Open Source Software.
preferred-citation:
authors:
- family-names: Karakaya
given-names: Sevgi Akten
orcid: "https://orcid.org/0000-0001-9346-5795"
- family-names: Satman
given-names: Mehmet Hakan
orcid: "https://orcid.org/0000-0002-9402-1982"
date-published: 2025-01-03
doi: 10.21105/joss.07322
issn: 2475-9066
issue: 105
journal: Journal of Open Source Software
publisher:
name: Open Journals
start: 7322
title: "pycellga: A Python package for improved cellular genetic
algorithms"
type: article
url: "https://joss.theoj.org/papers/10.21105/joss.07322"
volume: 10
title: "pycellga: A Python package for improved cellular genetic
algorithms"
GitHub Events
Total
- Create event: 7
- Release event: 5
- Issues event: 32
- Watch event: 1
- Issue comment event: 5
- Push event: 77
- Fork event: 2
Last Year
- Create event: 7
- Release event: 5
- Issues event: 32
- Watch event: 1
- Issue comment event: 5
- Push event: 77
- Fork event: 2
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| SevgiAkten | s****n@g****m | 265 |
| mhsatman@gmail.com | m****n@g****m | 50 |
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 64
- Total pull requests: 18
- Average time to close issues: about 1 month
- Average time to close pull requests: 2 minutes
- Total issue authors: 3
- Total pull request authors: 1
- Average comments per issue: 1.77
- Average comments per pull request: 0.0
- Merged pull requests: 18
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 18
- Pull requests: 0
- Average time to close issues: 23 days
- Average time to close pull requests: N/A
- Issue authors: 2
- Pull request authors: 0
- Average comments per issue: 0.28
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- jbytecode (36)
- SevgiAkten (18)
- jbussemaker (1)
Pull Request Authors
- jbytecode (30)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 43 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 27
- Total maintainers: 2
pypi.org: pycellga
A Python Package for Improved Cellular Genetic Algorithms
- Homepage: https://github.com/SevgiAkten/pycellga
- Documentation: https://sevgiakten.github.io/pycellga/
- License: MIT License
-
Latest release: 0.4.0
published about 1 year ago
Rankings
Maintainers (2)
Dependencies
- Deprecated ==1.2.14
- Pillow ==10.1.0
- click ==8.1.7
- contourpy ==1.2.0
- cycler ==0.12.1
- fonttools ==4.45.1
- geographiclib ==2.0
- geopy ==2.4.1
- kiwisolver ==1.4.5
- matplotlib ==3.8.2
- networkx ==2.8.8
- numpy ==1.26.2
- packaging ==23.2
- pandas ==2.1.3
- pyparsing ==3.1.1
- python-dateutil ==2.8.2
- pytz ==2023.3.post1
- six ==1.16.0
- tabulate ==0.8.10
- tsplib95 ==0.7.1
- tzdata ==2023.3
- wrapt ==1.16.0
