Skip to content

Commit 906e7aa

Browse files
authored
Merge pull request #1 from alexnodeland/claude/tdd-prd-implementation-01LMu66uYzAvMSTAM3Jx7dXp
Implement Phase 1 of fugue-evo library (TDD approach)
2 parents 2796518 + 1dbb83c commit 906e7aa

55 files changed

Lines changed: 21525 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
RUSTFLAGS: -Dwarnings
13+
14+
jobs:
15+
check:
16+
name: Check
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install Rust toolchain
22+
uses: dtolnay/rust-toolchain@stable
23+
24+
- name: Cache cargo registry
25+
uses: actions/cache@v4
26+
with:
27+
path: |
28+
~/.cargo/registry
29+
~/.cargo/git
30+
target
31+
key: ${{ runner.os }}-cargo-check-${{ hashFiles('**/Cargo.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-cargo-check-
34+
35+
- name: Run cargo check
36+
run: cargo check --all-targets --all-features
37+
38+
fmt:
39+
name: Format
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Install Rust toolchain
45+
uses: dtolnay/rust-toolchain@stable
46+
with:
47+
components: rustfmt
48+
49+
- name: Check formatting
50+
run: cargo fmt --all -- --check
51+
52+
clippy:
53+
name: Clippy
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Install Rust toolchain
59+
uses: dtolnay/rust-toolchain@stable
60+
with:
61+
components: clippy
62+
63+
- name: Cache cargo registry
64+
uses: actions/cache@v4
65+
with:
66+
path: |
67+
~/.cargo/registry
68+
~/.cargo/git
69+
target
70+
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
71+
restore-keys: |
72+
${{ runner.os }}-cargo-clippy-
73+
74+
- name: Run clippy
75+
run: cargo clippy --all-targets --all-features -- -D warnings
76+
77+
test:
78+
name: Test
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v4
82+
83+
- name: Install Rust toolchain
84+
uses: dtolnay/rust-toolchain@stable
85+
86+
- name: Cache cargo registry
87+
uses: actions/cache@v4
88+
with:
89+
path: |
90+
~/.cargo/registry
91+
~/.cargo/git
92+
target
93+
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
94+
restore-keys: |
95+
${{ runner.os }}-cargo-test-
96+
97+
- name: Run tests
98+
run: cargo test --all-features
99+
100+
doc:
101+
name: Documentation
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@v4
105+
106+
- name: Install Rust toolchain
107+
uses: dtolnay/rust-toolchain@stable
108+
109+
- name: Cache cargo registry
110+
uses: actions/cache@v4
111+
with:
112+
path: |
113+
~/.cargo/registry
114+
~/.cargo/git
115+
target
116+
key: ${{ runner.os }}-cargo-doc-${{ hashFiles('**/Cargo.lock') }}
117+
restore-keys: |
118+
${{ runner.os }}-cargo-doc-
119+
120+
- name: Check documentation
121+
run: cargo doc --no-deps --all-features
122+
env:
123+
RUSTDOCFLAGS: -Dwarnings
124+
125+
# Summary job that depends on all other jobs
126+
ci-success:
127+
name: CI Success
128+
needs: [check, fmt, clippy, test, doc]
129+
runs-on: ubuntu-latest
130+
if: always()
131+
steps:
132+
- name: Check all jobs passed
133+
run: |
134+
if [[ "${{ needs.check.result }}" != "success" ]] || \
135+
[[ "${{ needs.fmt.result }}" != "success" ]] || \
136+
[[ "${{ needs.clippy.result }}" != "success" ]] || \
137+
[[ "${{ needs.test.result }}" != "success" ]] || \
138+
[[ "${{ needs.doc.result }}" != "success" ]]; then
139+
echo "One or more jobs failed"
140+
exit 1
141+
fi
142+
echo "All jobs passed!"

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Generated by Cargo
2+
/target/
3+
4+
# IDE
5+
.idea/
6+
.vscode/
7+
*.swp
8+
*.swo
9+
10+
# OS
11+
.DS_Store
12+
Thumbs.db

CHANGELOG.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2025-12-12
9+
10+
### Added
11+
12+
- **Core Genetic Algorithm Framework**
13+
- `SimpleGA` builder pattern for easy algorithm configuration
14+
- Generational evolution with configurable operators
15+
- Elitism support for preserving best individuals
16+
17+
- **Genome Types**
18+
- `RealVector` for continuous optimization
19+
- `BitString` for binary/combinatorial problems
20+
- `Permutation` for ordering problems (TSP, scheduling)
21+
- `TreeGenome` for genetic programming
22+
- Unified `EvolutionaryGenome` trait abstraction
23+
24+
- **Selection Operators**
25+
- `TournamentSelection` with configurable tournament size
26+
- `RouletteWheelSelection` (fitness-proportionate)
27+
- `TruncationSelection` for steady-state evolution
28+
- `RankSelection` for rank-based selection
29+
- `BoltzmannSelection` with temperature parameter
30+
31+
- **Crossover Operators**
32+
- `SbxCrossover` (Simulated Binary Crossover) for real-valued genomes
33+
- `UniformCrossover` for bit strings
34+
- `SinglePointCrossover` and `TwoPointCrossover`
35+
- `OrderCrossover` (OX) for permutations
36+
- `SubtreeCrossover` for tree genomes
37+
38+
- **Mutation Operators**
39+
- `PolynomialMutation` for real-valued genomes
40+
- `GaussianMutation` with adaptive step sizes
41+
- `BitFlipMutation` for bit strings
42+
- `SwapMutation` and `InsertMutation` for permutations
43+
- `PointMutation` and `SubtreeMutation` for trees
44+
45+
- **Advanced Algorithms**
46+
- `CmaEs` (Covariance Matrix Adaptation Evolution Strategy)
47+
- `NSGA2` for multi-objective optimization with Pareto fronts
48+
- `IslandModel` for parallel evolution with migration
49+
50+
- **Fugue PPL Integration**
51+
- `to_trace()` and `from_trace()` for probabilistic programming interop
52+
- Trace-based evolutionary operators
53+
- Bayesian hyperparameter learning with `BetaPosterior`
54+
55+
- **Production Features**
56+
- Checkpointing with `CheckpointManager` (JSON, Binary, Compressed)
57+
- Convergence detection with configurable criteria
58+
- Evolution statistics tracking
59+
- Termination conditions (max generations, target fitness, stagnation)
60+
61+
- **Benchmark Functions**
62+
- `Sphere`, `Rastrigin`, `Rosenbrock`, `Ackley`, `Griewank`
63+
- `OneMax`, `LeadingOnes` for bit strings
64+
- `SymbolicRegression` for GP benchmarks
65+
66+
- **Examples**
67+
- `sphere_optimization.rs` - Basic continuous optimization
68+
- `rastrigin_benchmark.rs` - Multimodal function optimization
69+
- `cma_es_example.rs` - CMA-ES for Rosenbrock
70+
- `island_model.rs` - Parallel island model
71+
- `checkpointing.rs` - Save/restore evolution state
72+
- `symbolic_regression.rs` - Genetic programming
73+
- `hyperparameter_learning.rs` - Bayesian adaptation
74+
75+
- **Testing**
76+
- Comprehensive unit tests (370+ tests)
77+
- Property-based tests with proptest (21 tests)

0 commit comments

Comments
 (0)