Graph-path quality diversity¶
Graph-path QD-GA treats each ordered pair of endpoints as a cell. The quality of a route is its edge cost, which the search minimizes. Use this example to study how mutation and crossover discover routes under a finite proposal budget. Dijkstra provides exact answers for ordinary positively weighted shortest-path queries.
from qdpy.algorithms import graph_path_qd
edges = [
("a", "b", 1), ("b", "c", 1),
("a", "c", 10), ("c", "a", 4),
]
result = graph_path_qd(edges, budget=500, seed=11)
route = result.route("a", "c")
print(route.nodes, route.cost)
print(result.attempts, result.evaluations, result.initial_routes)
Every direct edge seeds a cell. Endpoint mutation attempts one plus
a Poisson-distributed number of edge edits. An invalid intermediate
edit ends that proposal. Crossover concatenates two parent routes at
a shared endpoint and rejects cycles. With crossover="feasible",
the second cell comes from the first cell’s target row. An empty
cell or invalid path spends one attempt. Use
crossover_probability=0 for the mutation-only QD-EA variant.
An absent route can mean that the pair is unreachable or that the
search budget ended before discovery. Include isolated nodes in
nodes when they need to appear in the repertoire. The
Local Pareto, team, feedback, graph, and Bayesian QD pilots pilot reports coverage over reachable
pairs and measures discovered routes against exact shortest paths.