Skip to main content

flux-genome

Genetic evolution engine for exploring the unexplored 82% of musical dial space

Part of the SuperInstance music constraint theory ecosystem. Uses genetic algorithms to breed novel musical traditions by evolving 25-gene genomes across three dial axes: Harmonic Tension, Rhythmic Complexity, and Spectral Density.

What It Does

Most music humanity has ever made occupies a tiny fraction of the available dial space. Jazz sits in one corner, gamelan in another, Western classical somewhere in between — but the vast majority of possible musical configurations remain unexplored. flux-genome treats musical traditions as positions on dials and uses genetic algorithms to systematically evolve into the unknown.

Each organism is a MusicalGenome — a 25-gene vector encoding a complete musical identity. Genes are grouped into three chromosomes (harmonic, rhythmic, spectral) that map directly to the SuperInstance dial model. The GeneticAlgorithm engine runs populations through selection, crossover, and mutation, logging every generation for reproducibility.

Key Features

  • 25-gene MusicalGenome — complete DNA encoding of a musical tradition across 3 chromosomes
  • 3 crossover operators — single-point, uniform, and blend crossover for diverse offspring
  • 3 mutation operators — Gaussian perturbation, tradition boundary snaps, and random gene resets
  • Tradition DNA encoding — pre-encoded genomes for known traditions (jazz, blues, gamelan, etc.)
  • Tournament selection — configurable tournament size for selection pressure tuning
  • EvolutionLog — full lineage tracking with generation-by-generation snapshots
  • Fitness scoring — custom fitness functions that evaluate genomes against dial-space targets
  • 27 tests — comprehensive test suite covering all operators and edge cases

Installation

git clone https://github.com/SuperInstance/flux-genome.git
cd flux-genome
pip install -e ".[dev]"

Requires Python 3.11+.

Quick Start

Create and evolve a population

from flux_genome.genome import MusicalGenome
from flux_genome.genetic_algorithm import GeneticAlgorithm
from flux_genome.operators.crossover import single_point_crossover, uniform_crossover
from flux_genome.operators.mutation import gaussian_mutation, boundary_mutation

# Seed population from known traditions
from flux_genome.tradition_dna import TRADITION_DNA

jazz = MusicalGenome.from_dict(TRADITION_DNA["jazz"])
gamelan = MusicalGenome.from_dict(TRADITION_DNA["gamelan"])

# Run evolution
ga = GeneticAlgorithm(
    population_size=100,
    crossover_fn=uniform_crossover,
    mutation_fn=gaussian_mutation,
    mutation_rate=0.15,
    tournament_size=5,
)

result = ga.evolve(
    seed_genomes=[jazz, gamelan],
    generations=500,
    fitness_fn=my_fitness_function,
)

print(f"Best fitness: {result.best_fitness}")
print(f"Best genome: {result.best_genome}")

Inspect evolution history

log = result.evolution_log
for gen in log.generations:
    print(f"Gen {gen.number}: best={gen.best_fitness:.4f} avg={gen.avg_fitness:.4f}")

Architecture

flux_genome/
├── genome.py              # MusicalGenome (25-gene vector, 3 chromosomes)
├── genetic_algorithm.py   # GeneticAlgorithm engine + EvolutionLog
├── population.py          # Population management, statistics
├── fitness.py             # Fitness evaluation framework
├── tradition_dna.py       # Pre-encoded tradition genomes
└── operators/
    ├── crossover.py       # single_point, uniform, blend
    └── mutation.py        # gaussian, boundary, random_reset

The 25-Gene Model

Genes are organized into three chromosomes that mirror the SuperInstance dial axes:

Chromosome Genes Dial Axis
Harmonic 0–8 Harmonic Tension
Rhythmic 9–16 Rhythmic Complexity
Spectral 17–24 Spectral Density

Each gene is a float in [0.0, 1.0], representing a normalized position on its respective dial.

API Reference

MusicalGenome

genome = MusicalGenome(genes=[...])           # 25 floats
genome = MusicalGenome.random()                # Random valid genome
genome = MusicalGenome.from_dict(tradition)    # From tradition DNA dict
genome.to_dict()                               # Serialize
genome.hammonic_genes                          # Genes 0–8
genome.rhythmic_genes                          # Genes 9–16
genome.spectral_genes                          # Genes 17–24

GeneticAlgorithm

ga = GeneticAlgorithm(
    population_size=100,
    crossover_fn=uniform_crossover,
    mutation_fn=gaussian_mutation,
    mutation_rate=0.1,
    tournament_size=5,
    elitism=2,
)
result = ga.evolve(seed_genomes, generations, fitness_fn)

EvolutionLog

result.evolution_log.generations    # List[GenerationRecord]
result.evolution_log.best_genome    # Best genome across all generations
result.evolution_log.best_fitness   # Best fitness score

Testing

pytest                    # Run all 27 tests
pytest -v                 # Verbose output
pytest --cov=flux_genome  # With coverage

License

MIT

Metadata

Release files for flux-genome 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flux-genome 0.2.0
File Size Uploaded Provenance Actions
flux_genome-0.2.0.tar.gz 14.1 kB Without provenance Details for flux_genome-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flux-genome 0.2.0
File Interpreter ABI Platform Actions
flux_genome-0.2.0-py3-none-any.whl Python 3 none any Details for flux_genome-0.2.0-py3-none-any.whl

Total release size: 27.9 kB

Release files / flux_genome-0.2.0.tar.gz

Download URL flux_genome-0.2.0.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
058fcf08385409053cec88a64607b96544d7bde7398f6c1f3ca88b091b7f1129
BLAKE2b-256 checksum
How to use checksums
cd5e9e60ffee7e0e88001d492fddfad3d80175c22d05170ee01c494e187aa7e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / flux_genome-0.2.0-py3-none-any.whl

Download URL flux_genome-0.2.0-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16309a810ee105eb78a9547cc0f8282dc4e029f899cba1502a4571f9c9e023d3
BLAKE2b-256 checksum
How to use checksums
8516bea662ead3b77064fff3ca87247d97e81f97e627c53d225de00d1489f7bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for flux-genome 0.2.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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