Goal
Goal predicates, type aliases, and shared infrastructure for traversals.
CostFunction
module-attribute
CostFunction = Callable[[ConfigurationNode], float]
Computes the accumulated cost of reaching a node. Lower is better.
GoalPredicate
module-attribute
GoalPredicate = Callable[[ConfigurationNode], bool]
Returns True if the node satisfies the search goal.
HeuristicFunction
module-attribute
HeuristicFunction = Callable[[ConfigurationNode], float]
Estimates the cost from a node to the goal. Lower is better.
PriorityEntry
dataclass
PriorityEntry(priority: float, node: ConfigurationNode)
Heap entry for priority-based search.
SearchResult
dataclass
SearchResult(
*,
nodes_expanded: int,
max_depth_reached: int,
goal_nodes: tuple[ConfigurationNode, ...] = (),
goal_node: ConfigurationNode | None = None
)
Result of a search strategy.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/search/traversal/goal.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
goal_node
property
goal_node: ConfigurationNode | None
Best goal node, or None if no goal was found.
goal_nodes
instance-attribute
goal_nodes: tuple[ConfigurationNode, ...] = goal_nodes
Goal nodes found during search, ordered best to worst.
max_depth_reached
instance-attribute
max_depth_reached: int = max_depth_reached
Maximum depth reached during search.
nodes_expanded
instance-attribute
nodes_expanded: int = nodes_expanded
Total number of nodes expanded during search.
partial_placement_goal
partial_placement_goal(
target: dict[int, LocationAddress],
min_placed: int | None = None,
) -> GoalPredicate
Goal: at least some qubits are at their target locations.
If min_placed is None, all qubits in target must be placed
(same as placement_goal). Otherwise, at least min_placed
qubits must be at their target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
dict[int, LocationAddress]
|
Mapping of qubit ID to desired location. |
required |
min_placed
|
int | None
|
Minimum number of qubits that must be at their target. None means all. |
None
|
Returns:
| Type | Description |
|---|---|
GoalPredicate
|
A GoalPredicate. |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/search/traversal/goal.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
placement_goal
placement_goal(
target: dict[int, LocationAddress],
) -> GoalPredicate
Goal: all specified qubits are at their target locations.
Every qubit in target must be at the exact location. Qubits not
in target are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
dict[int, LocationAddress]
|
Mapping of qubit ID to desired location. |
required |
Returns:
| Type | Description |
|---|---|
GoalPredicate
|
A GoalPredicate that returns True when all targets are met. |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/search/traversal/goal.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
zone_goal
zone_goal(
zone_id: int, arch_spec: ArchSpec
) -> GoalPredicate
Goal: all qubits are located in the specified zone.
A qubit is "in the zone" if its location's word_id is in the zone's word list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zone_id
|
int
|
The zone to target. |
required |
arch_spec
|
ArchSpec
|
Architecture specification (for zone → word mapping). |
required |
Returns:
| Type | Description |
|---|---|
GoalPredicate
|
A GoalPredicate that returns True when all qubits are in the zone. |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/search/traversal/goal.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |