Skip to main content

Gene Expression Programming engine for discovering elegant mathematical formulas

Project description

GEPEvolver

Gene Expression Programming engine for discovering elegant mathematical formulas.

Installation

pip install gepevolver

Or from source:

git clone https://github.com/worldbridgerstudios/GEPEvolver
cd GEPEvolver
pip install -e .

What Is This?

A Gene Expression Programming (GEP) engine based on Cândida Ferreira's 2001 architecture, enhanced with Frozen Glyphs — a system that constrains the search space to elegant primitives.

The Key Insight

Instead of searching over raw numbers (where GEP might find 43913 and you have to realize it's 66×666-43), we constrain terminals to elegant atoms:

  • Cubes: 1³, 2³, 3³, ...
  • Triangulars: T(3), T(4), T(8), T(11), T(36)
  • Transcendentals: π, e, φ

Any formula GEP produces is automatically elegant because the atoms ARE elegant.

Quick Start

from gepevolver import GlyphSet, evolve_with_glyphs

# Use preset glyph set
glyphs = GlyphSet.cubes_and_triangulars()

# Evolve expression for target value
result, population, engine = evolve_with_glyphs(
    glyph_set=glyphs,
    target=137.036,  # Fine structure constant inverse
    pop_size=300,
    head_len=12,
    generations=1000,
)

print(f"Expression: {result.expression}")
print(f"Value: {result.value}")
print(f"Error: {abs(result.value - 137.036) / 137.036 * 100:.4f}%")

Custom Glyph Sets

from gepevolver import GlyphSet

# Create custom terminals
glyphs = GlyphSet.custom([
    ('a', 'T₁₆', 136),      # T(16) = 136
    ('b', '36', 36),
    ('c', '66', 66),
    ('p', 'π', 3.14159265),
    ('f', 'φ', 1.61803399),
])

# Or build programmatically
glyphs = GlyphSet("my_set")
glyphs.add('a', 'T₁₆', 136, formula='T(16)')
glyphs.add('b', 'cubed', 27, formula='3³')

Custom Operators

from gepevolver import GlyphSet, GlyphGEP, Operator, DEFAULT_OPERATORS

# Define custom operator
T_op = Operator(
    symbol='T',
    arity=1,
    func=lambda n: int(n) * (int(n) + 1) // 2,
    display='T'
)

# Create operator set
operators = {**DEFAULT_OPERATORS, 'T': T_op}

# Use with engine
glyphs = GlyphSet.custom([('a', '16', 16)])
engine = GlyphGEP(glyphs, operators)

Preset Glyph Sets

GlyphSet.cubes(n=10)              # 1³ through 10³
GlyphSet.triangulars()            # T(1) through T(11)
GlyphSet.transcendentals()        # π, e, φ
GlyphSet.cubes_and_triangulars()  # Combined set with transcendentals

Package Structure

gepevolver/
├── __init__.py    # Public API exports
├── engine.py      # GlyphGEP engine and evolution
├── glyphs.py      # GlyphSet and Glyph classes
└── karva.py       # Karva encoding utilities

Theory

Based on:

  • Ferreira (2001): Gene Expression Programming (arXiv:cs/0102027)
  • Nicomachus (~100 CE): Σk³ = T(n)² — cubes collapse to squared triangulars

The triangular numbers appear to be fundamental atoms of number-theoretic structure.

License

CC0 1.0 Universal — Public Domain


The glyphs freeze elegance. GEP finds the pattern.

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

gep_evolver-0.2.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

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

gep_evolver-0.2.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file gep_evolver-0.2.0.tar.gz.

File metadata

  • Download URL: gep_evolver-0.2.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for gep_evolver-0.2.0.tar.gz
Algorithm Hash digest
SHA256 26a4d92420f7d96eeb169b46cb1268440a9e3b38930e9e1897281aed8c7c01a9
MD5 36b93fdd0906e3c6d40e226dd78b01aa
BLAKE2b-256 71aa8457c4ae539250a73d9ab05cd8a1dc7dbc930005b9842217f769cd7e0f52

See more details on using hashes here.

File details

Details for the file gep_evolver-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: gep_evolver-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for gep_evolver-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f7263363fc22c9e2df3779a8066e4be66aeff07db270ea053b1e8aff3865bcc
MD5 7e186fa18ba401b34a33f9ed560daa79
BLAKE2b-256 0cf53f6007bc2ec752e0b62eaf9d6f96fc40af7bd9929cf2a398fee5536b4b70

See more details on using hashes here.

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