galgopy
A lightweight Python package providing a basic but flexible implementation of the Genetic Algorithm (GA) for optimization tasks. It can be easily integrated into other projects or extended with custom selection, crossover, and mutation strategies.
Installation
galgopy is available on PyPI:
pip install galgopy
Usage
Sphere Function Optimization example
import numpy as np
from galgopy.crossover import IntermediateRecombination
from galgopy.ga import GA
from galgopy.mutation import UniformMutation
from galgopy.selection import TournamentSelection
ga = GA(
population_size=100,
chromosome_size=2,
gene_bounds=(-5.12, 5.12),
fitness_func=lambda x: -np.sum(np.square(x)),
mutation=UniformMutation(individual_rate=0.1, gene_bounds=(-5.12, 5.12)),
crossover=IntermediateRecombination(),
selection=TournamentSelection(),
)
# The course of 50 generations.
for _ in range(50):
next(ga)
# Result
best_chromosome, _ = ga.best_chromosome()
print(
f"Result:\t{best_chromosome}",
"Global minimum:\t[0. 0.]",
sep="\n",
)
More examples
More examples can be found in the examples directory.
- Booth Function Optimization
- One Max Problem
- String generation
- Travelling salesman problem (TSP)
License
This project is licensed under the MIT License.
Metadata
Release files for galgopy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| galgopy-0.1.1.tar.gz | 109.1 kB | With provenance | Details for galgopy-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| galgopy-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for galgopy-0.1.1-py3-none-any.whl |
Total release size: 122.0 kB
Release files / galgopy-0.1.1.tar.gz
| Download URL | galgopy-0.1.1.tar.gz |
|---|---|
| Size | 109.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d25045e6556f3fea4e2129352bdde1ed2ad8e3a4d70233142bc21774e25fdcf
|
|
BLAKE2b-256 checksum How to use checksums |
d54775fed9b612a2b1f4b4ead73f8838bb274bfea6c08128039d404211c58013
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2025.
Transparency logRelease files / galgopy-0.1.1-py3-none-any.whl
| Download URL | galgopy-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64e8d0d3f82570e044c7580536882c051c8ab5f418e31ece20122245a102b847
|
|
BLAKE2b-256 checksum How to use checksums |
a595b83e788301b521a1a3216826e5972c587584986ed7b65f62f6c4edf13c1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2025.
Transparency logSecurity for galgopy 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for galgopy-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.