feat(ga): initial population generator with cognitive style coverage
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import random
|
||||
|
||||
from multi_swarm.ga.initial import build_initial_population
|
||||
from multi_swarm.genome.hypothesis import ModelTier
|
||||
|
||||
|
||||
def test_initial_population_size():
|
||||
pop = build_initial_population(k=20, model_tier=ModelTier.C, rng=random.Random(0))
|
||||
assert len(pop) == 20
|
||||
|
||||
|
||||
def test_initial_population_unique_ids():
|
||||
pop = build_initial_population(k=20, model_tier=ModelTier.C, rng=random.Random(0))
|
||||
ids = {g.id for g in pop}
|
||||
assert len(ids) == 20
|
||||
|
||||
|
||||
def test_initial_population_covers_all_styles():
|
||||
pop = build_initial_population(k=12, model_tier=ModelTier.C, rng=random.Random(0))
|
||||
styles = {g.cognitive_style for g in pop}
|
||||
assert len(styles) == 6
|
||||
|
||||
|
||||
def test_initial_population_generation_zero():
|
||||
pop = build_initial_population(k=20, model_tier=ModelTier.C, rng=random.Random(0))
|
||||
assert all(g.generation == 0 for g in pop)
|
||||
assert all(g.parent_ids == [] for g in pop)
|
||||
Reference in New Issue
Block a user