No project description provided
Project description
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.
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 galgopy-0.1.0.tar.gz.
File metadata
- Download URL: galgopy-0.1.0.tar.gz
- Upload date:
- Size: 156.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c37353e3118aa41d6bea1abaca65f95ded07734ce150a13d3138baeac916bb4f
|
|
| MD5 |
074f67e535cd869a8d765a001ceffab5
|
|
| BLAKE2b-256 |
062def497b846fcb1b7af7482ca62b82865b72f5a630c9d9ba238dc3c74d22bd
|
Provenance
The following attestation bundles were made for galgopy-0.1.0.tar.gz:
Publisher:
python-publish.yml on vec2pt/galgopy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
galgopy-0.1.0.tar.gz -
Subject digest:
c37353e3118aa41d6bea1abaca65f95ded07734ce150a13d3138baeac916bb4f - Sigstore transparency entry: 597681934
- Sigstore integration time:
-
Permalink:
vec2pt/galgopy@7d02ec9ca292eb84696d1fe8662b5d3197075337 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/vec2pt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7d02ec9ca292eb84696d1fe8662b5d3197075337 -
Trigger Event:
release
-
Statement type:
File details
Details for the file galgopy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: galgopy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5de7445fba9723ae740df8783a5d2506b52cd12172775e76fade5a5569ec25d
|
|
| MD5 |
54f69f0f2f2c80e67f6b6e2495d60f9a
|
|
| BLAKE2b-256 |
92cbfb0ff88bdb815b1d0b96b4a5732501864876e1ff19760052156ab8a3414c
|
Provenance
The following attestation bundles were made for galgopy-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on vec2pt/galgopy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
galgopy-0.1.0-py3-none-any.whl -
Subject digest:
e5de7445fba9723ae740df8783a5d2506b52cd12172775e76fade5a5569ec25d - Sigstore transparency entry: 597681938
- Sigstore integration time:
-
Permalink:
vec2pt/galgopy@7d02ec9ca292eb84696d1fe8662b5d3197075337 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/vec2pt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7d02ec9ca292eb84696d1fe8662b5d3197075337 -
Trigger Event:
release
-
Statement type: