Skip to content

Commit 0d25077

Browse files
committed
review AGENTS.md manually
1 parent e8f11dd commit 0d25077

5 files changed

Lines changed: 22 additions & 13 deletions

File tree

AGENTS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ with `call_repeatedly` for genomes >20 genes.
176176
| Genotype | Compatible Crossovers | Recommended |
177177
|---|---|---|
178178
| `BinaryGenotype` | All | `CrossoverUniform` or `CrossoverSinglePoint` |
179-
| `ListGenotype<T>` | All | `CrossoverUniform` |
180-
| `MultiListGenotype<T>` | All | `CrossoverUniform` |
179+
| `ListGenotype<T>` | All | Any (e.g. `CrossoverUniform`, `CrossoverSinglePoint`) |
180+
| `MultiListGenotype<T>` | All | Any (e.g. `CrossoverUniform`, `CrossoverSinglePoint`) |
181181
| `UniqueGenotype<T>` | `CrossoverClone`, `CrossoverRejuvenate` ONLY (others are compile errors) | `CrossoverClone` |
182182
| `MultiUniqueGenotype<T>` | Point-based + `CrossoverClone`, `CrossoverRejuvenate` (gene-based are compile errors) | `CrossoverSinglePoint` |
183-
| `RangeGenotype<T>` | All | `CrossoverMultiPoint` |
184-
| `MultiRangeGenotype<T>` | All | `CrossoverSingleGene` |
183+
| `RangeGenotype<T>` | All | Any (e.g. `CrossoverUniform`, `CrossoverSinglePoint`) |
184+
| `MultiRangeGenotype<T>` | All | Any (e.g. `CrossoverUniform`, `CrossoverSingleGene`) |
185185

186186
**Compile-time safety**: `UniqueGenotype` does not implement `SupportsGeneCrossover`
187187
or `SupportsPointCrossover`, so incompatible crossovers are **compile errors**.
@@ -249,7 +249,7 @@ For range/float genotypes (>50 genes, see Troubleshooting for tuning):
249249
```rust
250250
// also requires: genotype, fitness, target_population_size, ending condition
251251
.with_select(SelectTournament::new(0.5, 0.02, 4))
252-
.with_crossover(CrossoverMultiPoint::new(0.7, 0.8, 3, false))
252+
.with_crossover(CrossoverUniform::new(0.7, 0.8))
253253
.with_mutate(MutateMultiGene::new(10, 1.0))
254254
```
255255

AGENTS_TEMPLATES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn main() {
150150
.with_fitness(MinimizeDistance { target: 0.5, precision: 1e-5 })
151151
.with_fitness_ordering(FitnessOrdering::Minimize)
152152
.with_select(SelectTournament::new(0.5, 0.02, 4))
153-
.with_crossover(CrossoverMultiPoint::new(0.7, 0.8, 3, false))
153+
.with_crossover(CrossoverUniform::new(0.7, 0.8))
154154
.with_mutate(MutateMultiGene::new(10, 1.0))
155155
.call()
156156
.unwrap();
@@ -349,7 +349,7 @@ fn main() {
349349
.with_max_stale_generations(1000)
350350
.with_fitness(HyperparamFitness { precision: 1e-5 })
351351
.with_select(SelectTournament::new(0.5, 0.02, 4))
352-
.with_crossover(CrossoverSingleGene::new(0.7, 0.8))
352+
.with_crossover(CrossoverUniform::new(0.7, 0.8))
353353
.with_mutate(MutateSingleGene::new(0.2))
354354
.call()
355355
.unwrap();

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ parameter reference, copy-paste templates, and troubleshooting.
5151
Located in `src/genotype/`, defines the representation of solutions:
5252
- `BinaryGenotype`: Boolean alleles (Vec<bool>)
5353
- `ListGenotype<T>`: List of values from a fixed set of alleles
54-
- `UniqueGenotype<T>`: Permutation of unique values
54+
- `UniqueGenotype<T>`: Positional permutation (swap-only mutation, default T = usize)
5555
- `RangeGenotype<T>`: Numeric values within a range (default f32)
5656
- `MultiListGenotype<T>`: Per-gene allele lists
5757
- `MultiUniqueGenotype<T>`: Multiple unique sets

src/genotype/unique.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use std::hash::Hash;
1313

1414
pub type DefaultAllele = usize;
1515

16-
/// Genes are a vector of unique values, taken from the allele_list using clone(), each value occurs
17-
/// exactly once. The genes_size is derived to be the same as allele_list length. On random
18-
/// initialization, the allele_list are shuffled to form the genes. Each pair of genes has an equal
19-
/// probability of mutating. If a pair of genes mutates, the values are switched, ensuring the list
20-
/// of alleles remains unique. Defaults to usize as item.
16+
/// Genes are a vector of values taken from the allele_list using clone(). The values don't need to
17+
/// be unique, they are only treated as positionally unique (never changed, only swapped). The
18+
/// genes_size is derived to be the same as allele_list length. On random initialization, the
19+
/// allele_list is shuffled to form the genes. Each pair of genes has an equal probability of
20+
/// mutating. If a pair of genes mutates, the values are swapped. Defaults to usize as item.
2121
///
2222
/// # Panics
2323
///

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
//! * [Genotype](crate::genotype): Knows how to generate, mutate and crossover chromosomes efficiently
1919
//! * [Fitness](crate::fitness): knows how to determine the fitness of a chromosome
2020
//!
21+
//! **Important**: [FitnessValue](crate::fitness::FitnessValue) is `isize` (not `f64`). This
22+
//! enables equality checks for staleness detection. For float-based fitness, scale manually:
23+
//! `Some((score / precision) as FitnessValue)`, or use the
24+
//! [fitness_value](crate::fitness::fitness_value) helper.
25+
//!
26+
//! AI agents: see
27+
//! [AGENTS.md](https://github.com/basvanwesting/genetic-algorithm/blob/main/AGENTS.md) for
28+
//! decision matrices, constructor parameter reference, copy-paste templates, and gotchas.
29+
//!
2130
//! All multithreading mechanisms are implemented using [rayon::iter] and [std::sync::mpsc].
2231
//!
2332
//! ## Quick Usage

0 commit comments

Comments
 (0)