5"""Search four related quadratic tasks with a separate repertoire per task."""
10TASKS = (0.20, 0.35, 0.50, 0.65)
14 """Build a reporting grid with eight cells for each task."""
16 task: Grid(shape=8, fitness_domain=((0, 1),), features_domain=((0, 1),))
21def evaluate(task, genome):
22 """Return a task-specific cost and a shifted descriptor."""
24 cost = (x - task) ** 2 + 0.02 * (y - 0.5) ** 2
25 return (cost,), ((y + task) % 1.0,)
28if __name__ ==
"__main__":
29 result = mtmb_search(make_archives(), evaluate, dimension=2, budget=64, seed=42)
30 print(f
"Attempts: {sum(result.attempts_by_task.values())}")
31 for task, archive
in result.archives.items():
32 print(f
"Task {task:.2f}: {result.attempts_by_task[task]} attempts, "
33 f
"{archive.filled_bins}/8 cells, QD score {archive.qd_score():.3f}")