# mqt.ionshuttler.linear.architecture

Hardware layout, timing, and operation rules for a linear qccd architecture.

## Module Contents

### IMPLICIT_PROCESSING_ZONE *= 'all_sites'*

### *class* LinearArchitecture

Describe the sites, processing zones, timing, and supported operations.

The architecture owns the complete meaning of its operations: their
durations, the ions and processing zones they occupy, when they may start,
and how they change the machine state.

`supported_action_types` selects which of the operations implemented by
Linear architectures this device offers, for example to compare schedules
with and without physical swaps. It does not add new operation types.

The architecture stores `processing_zones` as a read-only mapping from
zone name to normalized site tuple, so later changes to the supplied
mapping do not affect it.

#### num_sites *: [int](https://docs.python.org/3/builtins/functions.html#int)*

#### processing_zones *: [Mapping](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[int](https://docs.python.org/3/builtins/functions.html#int)]] | [None](https://docs.python.org/3/builtins/constants.html#None)* *= None*

#### field_profile *: [FieldProfile](../field_profile/index.html.md#mqt.ionshuttler.linear.field_profile.FieldProfile) | [None](https://docs.python.org/3/builtins/constants.html#None)* *= None*

#### gate_timing *: [GateTiming](../../core/gates/index.html.md#mqt.ionshuttler.core.gates.GateTiming)*

#### transport_timing *: [TransportTiming](../actions/index.html.md#mqt.ionshuttler.linear.actions.TransportTiming)*

#### supported_action_types *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[type](https://docs.python.org/3/builtins/functions.html#type)[[Action](../../core/actions/index.html.md#mqt.ionshuttler.core.actions.Action)], ...]*

#### topology *: Literal['chain', 'ring']* *= 'chain'*

#### valid_two_qubit_site_pairs *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)], ...]*

#### \_\_post_init_\_() → [None](https://docs.python.org/3/builtins/constants.html#None)

Check the hardware description and store zone sites in order.

* **Raises:**
  * [**TypeError**](https://docs.python.org/3/builtins/exceptions.html#TypeError) – If the site count, a zone, the field profile, timing, or
    an action type has the wrong type.
  * [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – If the site count, zones, operations, or field profile are invalid.

#### \_\_hash_\_() → [int](https://docs.python.org/3/builtins/functions.html#int)

Hash the site layout so that cached lookups can take the architecture as a key.

Equal architectures have equal site layouts, so the hash agrees with
equality, which still compares every field.

* **Returns:**
  The hash value.

#### \_\_reduce_\_() → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[type](https://docs.python.org/3/builtins/functions.html#type)[[LinearArchitecture](#mqt.ionshuttler.linear.architecture.LinearArchitecture)], [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[object](https://docs.python.org/3/builtins/functions.html#object), ...]]

Rebuild the architecture from its constructor arguments when pickled.

[`pickle`](https://docs.python.org/3/library/pickle.html#module-pickle) cannot store the read-only `processing_zones` mapping,
so the zones pass through a regular dictionary.

* **Returns:**
  The architecture class and its constructor arguments.

#### neighbors(site: [int](https://docs.python.org/3/builtins/functions.html#int)) → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[int](https://docs.python.org/3/builtins/functions.html#int), ...]

Return directly connected sites in stable transport order.

Chain neighbors use lower-site-first order. Ring neighbors use the
preceding site followed by the next site, modulo the site count.

#### are_adjacent(first_site: [int](https://docs.python.org/3/builtins/functions.html#int), second_site: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Return whether two valid sites share a transport edge.

#### distance(first_site: [int](https://docs.python.org/3/builtins/functions.html#int), second_site: [int](https://docs.python.org/3/builtins/functions.html#int)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Return the shortest number of transport edges between two sites.

#### processing_zone_at(site: [int](https://docs.python.org/3/builtins/functions.html#int)) → [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None)

Return the processing zone containing a site, if any.

#### action_processing_zone(action: [Action](../../core/actions/index.html.md#mqt.ionshuttler.core.actions.Action), state: [State](../state/index.html.md#mqt.ionshuttler.linear.state.State)) → [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None)

Return the processing zone an action occupies in a machine state.

* **Parameters:**
  * **action** – Action whose zone is requested.
  * **state** – Machine state that holds the ion positions.
* **Returns:**
  The zone name, or `None` if the action occupies no zone. Global
  gates, virtual single-ion gates, and transport occupy none.

#### field_at(site: [int](https://docs.python.org/3/builtins/functions.html#int)) → [float](https://docs.python.org/3/builtins/functions.html#float)

Return the configured field value at one site.

#### has_nontrivial_field_profile() → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Return whether any site differs from the unit field profile.

#### supports(action_type: [type](https://docs.python.org/3/builtins/functions.html#type)[[Action](../../core/actions/index.html.md#mqt.ionshuttler.core.actions.Action)]) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Return whether the hardware exposes an action type.

#### action_duration(action: [Action](../../core/actions/index.html.md#mqt.ionshuttler.core.actions.Action)) → [int](https://docs.python.org/3/builtins/functions.html#int)

Return the architecture’s duration for one action.

Gates use [`gate_timing`](#mqt.ionshuttler.linear.architecture.LinearArchitecture.gate_timing), and a global gate takes the duration of
its rotation. Transport uses [`transport_timing`](#mqt.ionshuttler.linear.architecture.LinearArchitecture.transport_timing).

* **Returns:**
  The duration in timesteps.
* **Raises:**
  [**TypeError**](https://docs.python.org/3/builtins/exceptions.html#TypeError) – If the architecture defines no duration for the action.

#### is_virtual_gate(gate: [SingleQubitGate](../../core/gates/index.html.md#mqt.ionshuttler.core.gates.SingleQubitGate)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Return whether this architecture implements a single-ion gate virtually.

#### is_action_valid(state: [State](../state/index.html.md#mqt.ionshuttler.linear.state.State), action: [Action](../../core/actions/index.html.md#mqt.ionshuttler.core.actions.Action)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Return whether one action can start in a machine state.

This checks only the action’s own start conditions. Use
[`is_transport_layer_valid()`](../validation/index.html.md#mqt.ionshuttler.linear.validation.is_transport_layer_valid)
when several transports start together.

* **Raises:**
  [**TypeError**](https://docs.python.org/3/builtins/exceptions.html#TypeError) – If the architecture defines no rules for the action.

#### apply_action(state: [State](../state/index.html.md#mqt.ionshuttler.linear.state.State), action: [Action](../../core/actions/index.html.md#mqt.ionshuttler.core.actions.Action)) → [State](../state/index.html.md#mqt.ionshuttler.linear.state.State)

Apply the hardware effect of one valid action.

The effect changes ion positions and resource availability. Circuit
progress stays unchanged; the compiler records it separately.

* **Returns:**
  The updated state.
* **Raises:**
  [**TypeError**](https://docs.python.org/3/builtins/exceptions.html#TypeError) – If the architecture defines no rules for the action.

#### replay_schedule(schedule: [Schedule](../../core/schedule/index.html.md#mqt.ionshuttler.core.schedule.Schedule)) → [LinearMachineState](../schedule/index.html.md#mqt.ionshuttler.linear.schedule.LinearMachineState)

Replay a schedule and return its final Linear machine state.

* **Returns:**
  The final machine state.

#### sites_share_processing_zone(\*sites: [int](https://docs.python.org/3/builtins/functions.html#int)) → [bool](https://docs.python.org/3/builtins/functions.html#bool)

Return whether all supplied sites belong to one processing zone.

#### initial_pzs_busy_until() → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [int](https://docs.python.org/3/builtins/functions.html#int)], ...]

Return every processing zone as available at the start of a schedule.

#### to_dict() → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [object](https://docs.python.org/3/builtins/functions.html#object)]

Return JSON-compatible architecture metadata.

#### to_json() → [str](https://docs.python.org/3/builtins/stdtypes.html#str)

Serialize architecture metadata as JSON.

* **Returns:**
  The serialized architecture object.

#### *classmethod* from_dict(data: [object](https://docs.python.org/3/builtins/functions.html#object)) → [LinearArchitecture](#mqt.ionshuttler.linear.architecture.LinearArchitecture)

Construct an architecture from a JSON-style mapping.

* **Returns:**
  A validated architecture.
* **Raises:**
  * [**TypeError**](https://docs.python.org/3/builtins/exceptions.html#TypeError) – If the architecture or site count has the wrong type.
  * [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – If the mapping has an invalid shape or values.

#### *classmethod* from_json(raw: [str](https://docs.python.org/3/builtins/stdtypes.html#str)) → [LinearArchitecture](#mqt.ionshuttler.linear.architecture.LinearArchitecture)

Deserialize an architecture from JSON.

* **Returns:**
  A validated architecture.

#### *classmethod* load(filename: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [Path](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) → [LinearArchitecture](#mqt.ionshuttler.linear.architecture.LinearArchitecture)

Load an architecture from a UTF-8 JSON file.

* **Returns:**
  A validated architecture.
