qgym.generators package

This subpackage contains data generation functionality.

These data generators can be used during training, as well as during evaluation.

class qgym.generators.BasicCircuitGenerator(seed=None)[source]

Bases: CircuitGenerator

BasicCircuitGenerator is a basic random circuit generation implementation.

__init__(seed=None)[source]

Init of the BasicInteractionGenerator.

Parameters:

seed (Generator | SupportsInt | None) – Seed to use.

__next__()[source]

Create a new randomly generated circuit.

The length of the circuit is a random integer in the interval [n_qubits, max_length].

Return type:

list[Gate]

__repr__()[source]

String representation of the BasicCircuitGenerator.

Return type:

str

set_state_attributes(machine_properties=None, max_gates=0, **kwargs)[source]

Set the n_qubits and max_gates attributes.

Parameters:
  • machine_properties (Any) – MachineProperties containing at least the number of qubits of the machine.

  • max_gates (SupportsInt) – Maximum number of gates allowed in the circuit.

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

Return type:

None

class qgym.generators.BasicGraphGenerator(interaction_graph_edge_probability=0.5, seed=None)[source]

Bases: GraphGenerator

BasicGraphGenerator is a simple graph generation implementation.

It uses fast_gnp_random_graph() to generate graphs.

__init__(interaction_graph_edge_probability=0.5, seed=None)[source]

Init of the BasicGraphGenerator.

Parameters:
__next__()[source]

Create a new randomly generated :class:~`networkx.Graph`.

Return type:

Graph

__repr__()[source]

String representation of the BasicGraphGenerator.

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.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.NullCircuitGenerator[source]

Bases: CircuitGenerator

Generator class for generating empty circuits.

Useful for unit testing.

__init__()[source]

Init of the NullCircuitGenerator

__next__()[source]

Create a new empty circuit.

Return type:

list[Gate]

__repr__()[source]

String representation of the NullCircuitGenerator.

Return type:

str

set_state_attributes(**kwargs)[source]

Receive state attributes, but do nothing with it.

Parameters:

kwargs (dict[str, Any]) – Keyword arguments.

Return type:

None

class qgym.generators.NullGraphGenerator[source]

Bases: GraphGenerator

Generator class for generating empty Graphs.

Useful for unit testing.

__init__()[source]

Init of the NullGraphGenerator

__next__()[source]

Create a new null graph.

Return type:

Graph

__repr__()[source]

String representation of the NullGraphGenerator.

Return type:

str

set_state_attributes(**kwargs)[source]

Receive state attributes, but do nothing with it.

Parameters:

kwargs (Any) – Keyword arguments.

Return type:

None

class qgym.generators.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

class qgym.generators.WorkshopCircuitGenerator(seed=None)[source]

Bases: CircuitGenerator

WorkshopCircuitGenerator is a simplified random circuit generation implementation.

__init__(seed=None)[source]

Init of the WorkshopCircuitGenerator.

Parameters:

seed (Generator | SupportsInt | None) – Seed to use.

__next__()[source]

Create a new randomly generated circuit.

The length of the circuit is a random integer in the interval [n_qubits, max_length].

Return type:

list[Gate]

__repr__()[source]

String representation of the WorkshopCircuitGenerator.

Return type:

str

set_state_attributes(**kwargs)[source]

Set the- n_qubits and max_gates attributes.

Parameters:

kwargs (dict[str, Any]) – Keyword arguments. Must have the keys "machine_properties" and "max_gates" with values of type MachineProperties and integerlike (SupportsInt) respectively.

Return type:

None