5"""Use a separate Pareto front in each descriptor cell."""
12def evaluate(candidate):
13 """Return two conflicting costs and one descriptor."""
14 x, descriptor = candidate
15 return (x ** 2, (1 - x) ** 2), (descriptor,)
18if __name__ ==
"__main__":
21 shape=4, max_items_per_bin=5, fitness_domain=(unit, unit),
22 features_domain=(unit,), fitness_weights=(-1.0, -1.0),
24 search = MOME(grid, budget=24, dimension=2, batch_size=4)
25 result = run(search, evaluate, seed=42)
27 cell = max(grid.solutions, key=
lambda index: len(grid.front(index)))
28 reference = (1.0, 1.0)
29 tradeoffs = sorted(tuple(round(float(cost), 4)
for cost
in ind.fitness.values)
30 for ind
in grid.front(cell))
31 print(f
"Evaluations: {result.evaluations}")
32 print(f
"Occupied cells: {grid.filled_bins}/{len(grid.solutions)}")
33 print(f
"Raw cost pairs in cell {cell}: {tradeoffs}")
34 print(f
"Cell hypervolume: {grid.cell_hypervolume(cell, reference):.4f}")
35 print(f
"QD hypervolume: {grid.qd_hypervolume(reference):.4f}")
36 print(f
"Global hypervolume: {grid.global_hypervolume(reference):.4f}")