Skip to main content

galgopy

PyPI - Status PyPI - Version PyPI - Python Version

galgopy title image.

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.

License

This project is licensed under the MIT License.

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)

Source distribution for galgopy 0.1.1
File Size Uploaded
galgopy-0.1.1.tar.gz 109.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for galgopy 0.1.1
File Interpreter ABI Platform
galgopy-0.1.1-py3-none-any.whl Python 3 none any Details

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 log

Release 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 log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

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