pub struct AtomStateData {
pub locations_to_qubit: HashMap<LocationAddr, u32>,
pub qubit_to_locations: HashMap<u32, LocationAddr>,
pub collision: HashMap<u32, u32>,
pub prev_lanes: HashMap<u32, LaneAddr>,
pub move_count: HashMap<u32, u32>,
}Expand description
Tracks qubit-to-location mappings as atoms move through the architecture.
This is an immutable value type: all mutation methods (add_atoms,
apply_moves) return a new instance rather than modifying in place.
The two primary maps (locations_to_qubit and qubit_to_locations) are
kept in sync as a bidirectional index. When a move causes two atoms to
occupy the same site, both are removed from the location maps and recorded
in collision.
Fields§
§locations_to_qubit: HashMap<LocationAddr, u32>Reverse index: given a physical location, which qubit (if any) is there?
qubit_to_locations: HashMap<u32, LocationAddr>Forward index: given a qubit id, where is it currently located?
collision: HashMap<u32, u32>Cumulative record of qubits that have collided since this state was
created (via constructors or add_atoms). Updated by apply_moves —
new collisions are added to existing entries. Key is the moving qubit,
value is the qubit it displaced. Collided qubits are removed from
both location maps.
prev_lanes: HashMap<u32, LaneAddr>The lane each qubit used in the most recent apply_moves.
Only populated for qubits that moved in the last step.
move_count: HashMap<u32, u32>Cumulative number of moves each qubit has undergone across
all apply_moves calls in the state’s history.
Implementations§
Source§impl AtomStateData
impl AtomStateData
Sourcepub fn from_locations(locations: &[(u32, LocationAddr)]) -> Self
pub fn from_locations(locations: &[(u32, LocationAddr)]) -> Self
Create a state from a list of (qubit_id, location) pairs.
Builds both the forward (qubit → location) and reverse (location → qubit) maps. All other fields (collision, prev_lanes, move_count) are empty.
Sourcepub fn add_atoms(
&self,
locations: &[(u32, LocationAddr)],
) -> Result<Self, &'static str>
pub fn add_atoms( &self, locations: &[(u32, LocationAddr)], ) -> Result<Self, &'static str>
Add atoms at new locations, returning a new state.
Each (qubit_id, location) pair is added to the bidirectional maps.
Returns Err if any qubit id already exists in this state or any
location is already occupied by another qubit.
The returned state inherits no collision, prev_lanes, or move_count data — those fields are reset to empty.
Sourcepub fn apply_moves(
&self,
lanes: &[LaneAddr],
arch_spec: &ArchSpec,
) -> Option<Self>
pub fn apply_moves( &self, lanes: &[LaneAddr], arch_spec: &ArchSpec, ) -> Option<Self>
Apply a sequence of lane moves and return the resulting state.
For each lane, resolves its source and destination locations via
ArchSpec::lane_endpoints. If a qubit exists at the source, it is
moved to the destination. If the destination is already occupied,
both qubits are removed from the location maps and recorded in
collision. Lanes whose source has no qubit are skipped.
Returns None if any lane cannot be resolved to endpoints (invalid
bus, word, or site). The prev_lanes field is reset to contain only
the lanes used in this call; move_count is accumulated.
Sourcepub fn get_qubit(&self, location: &LocationAddr) -> Option<u32>
pub fn get_qubit(&self, location: &LocationAddr) -> Option<u32>
Look up which qubit (if any) occupies the given location.
Sourcepub fn get_qubit_pairing(
&self,
zone: &ZoneAddr,
arch_spec: &ArchSpec,
) -> Option<(Vec<u32>, Vec<u32>, Vec<u32>)>
pub fn get_qubit_pairing( &self, zone: &ZoneAddr, arch_spec: &ArchSpec, ) -> Option<(Vec<u32>, Vec<u32>, Vec<u32>)>
Find CZ gate control/target qubit pairings within a zone.
Iterates over all qubits whose current location is in the given zone
and checks whether the CZ pair site (via ArchSpec::get_blockaded_location)
is also occupied. If both sites are occupied, the qubits form a
control/target pair. If the pair site is empty or doesn’t exist, the
qubit is unpaired.
Returns (controls, targets, unpaired) where controls[i] and
targets[i] are paired for CZ. Results are sorted by qubit id for
deterministic ordering. Returns None if the zone id is invalid.
Trait Implementations§
Source§impl Clone for AtomStateData
impl Clone for AtomStateData
Source§fn clone(&self) -> AtomStateData
fn clone(&self) -> AtomStateData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more