Skip to main content

No project description provided

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

galgopy-0.1.0.tar.gz (156.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

galgopy-0.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

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

Hashes for galgopy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c37353e3118aa41d6bea1abaca65f95ded07734ce150a13d3138baeac916bb4f
MD5 074f67e535cd869a8d765a001ceffab5
BLAKE2b-256 062def497b846fcb1b7af7482ca62b82865b72f5a630c9d9ba238dc3c74d22bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for galgopy-0.1.0.tar.gz:

Publisher: python-publish.yml on vec2pt/galgopy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for galgopy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5de7445fba9723ae740df8783a5d2506b52cd12172775e76fade5a5569ec25d
MD5 54f69f0f2f2c80e67f6b6e2495d60f9a
BLAKE2b-256 92cbfb0ff88bdb815b1d0b96b4a5732501864876e1ff19760052156ab8a3414c

See more details on using hashes here.

Provenance

The following attestation bundles were made for galgopy-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on vec2pt/galgopy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page