qgym.generators.interaction module

This module contains interaction generators for Routing.

class qgym.generators.interaction.BasicInteractionGenerator(max_length=10, seed=None)[source]

Bases: InteractionGenerator

BasicInteractionGenerator is an interaction generation implementation.

Interactions are completely randomly generated using the numpy.random.choice() method.

__init__(max_length=10, seed=None)[source]

Init of the BasicInteractionGenerator.

Parameters:
__next__()[source]

Create a new randomly generated interaction circuit.

Return type:

ndarray[Any, dtype[int32]]

__repr__()[source]

String representation of the BasicInteractionGenerator.

Return type:

str

set_state_attributes(*, connection_graph=None, **kwargs)[source]

Set the n_qubits attribute.

Parameters:
  • connection_graph (Graph | None) – A Graph representation of the connection graph.

  • kwargs (Any) – Additional keyword arguments. These are not used.

Return type:

None

class qgym.generators.interaction.InteractionGenerator[source]

Bases: Iterator[ndarray[Any, dtype[int32]]]

Abstract Base Class for interaction circuit generation.

All interaction circuit generators should inherit from InteractionGenerator to be compatible with the Routing environment.

abstract __next__()[source]

Make a new interaction circuit.

The __next__ method of a InteractionGenerator should generate a ndarray of shape (len_circuit, 2) with dtype int. Each pair represents the indices of two qubits that have an interaction in the circuit.

Return type:

ndarray[Any, dtype[int32]]

finite: bool

Boolean value stating whether the generator is finite.

abstract set_state_attributes(**kwargs)[source]

Set attributes that the state can receive.

This method is called inside the routing environment to receive information about the state. The same keywords as for the the init of the RoutingState are provided.

Return type:

None

class qgym.generators.interaction.NullInteractionGenerator[source]

Bases: InteractionGenerator

Generator class for generating empty interaction circuits.

Useful for unit testing.

__init__()[source]

Init of the NullInteractionGenerator

__next__()[source]

Create a new empty interaction circuit.

Return type:

ndarray[Any, dtype[int32]]

__repr__()[source]

String representation of the NullInteractionGenerator.

Return type:

str

set_state_attributes(**kwargs)[source]

Receive state attributes, but do nothing with it.

Parameters:

kwargs (Any) – Keyword arguments.

Return type:

None