qgym.envs.scheduling.scheduling_state module
This module contains the SchedulingState
class.
This SchedulingState
represents the State
of the
Scheduling
environment.
- class qgym.envs.scheduling.scheduling_state.SchedulingState(*, machine_properties, max_gates, dependency_depth, circuit_generator, rulebook)[source]
Bases:
State
[Dict
[str
,ndarray
[Any
,dtype
[int32
]] |ndarray
[Any
,dtype
[int8
]]],ndarray
[Any
,dtype
[int32
]]]The
SchedulingState
class.- __init__(*, machine_properties, max_gates, dependency_depth, circuit_generator, rulebook)[source]
Init of the
SchedulingState
class.- Parameters:
machine_properties (
MachineProperties
) – AMachineProperties
object.max_gates (
int
) – Maximum number of gates allowed in a circuit.dependency_depth (
int
) – Number of dependencies given in the observation. Determines the shape of the dependencies observation, which has the shape (dependency_depth, max_gates).circuit_generator (
CircuitGenerator
) – Generator class for generating circuits for training.rulebook (
CommutationRulebook
) –CommutationRulebook
describing the commutation rules.
- busy
Amount of cycles that a qubit is still busy (zero if available). Used internally for the hardware limitations.
- circuit_info
CircuitInfo`
dataclass containing the encoded circuit and attributes used to update the state.
- create_observation_space()[source]
Create the corresponding observation space.
- Return type:
- Returns:
Observation space in the form of a
Dict
space containing:MultiBinary
space representing the legal actions. If the value at index \(i\) determines if gate number \(i\) can be scheduled or not.MultiDiscrete
space representing the integer encoded gate names.MultiDiscrete
space representing the interaction of each gate (q1 and q2).MultiDiscrete
space representing the first \(n\) gates that must be scheduled before this gate.
- cycle
Current ‘machine’ cycle.
- is_done()[source]
Determine if the state is done or not.
- Return type:
- Returns:
Boolean value stating whether we are in a final state.
- machine_properties
MachineProperties
class containing machine properties and limitations.
- reset(*, seed=None, circuit=None, **_kwargs)[source]
Reset the state and load a new (random) initial state.
To be used after an episode is finished.
- Parameters:
seed (
int
|None
) – Seed for the random number generator, should only be provided (optionally) on the first reset call, i.e., before any learning is done.circuit (
list
[Gate
] |None
) – Optional list of a circuit for the next episode, each entry in the list should be aGate
. When a circuit is give, no random circuit will be generated._kwargs (
Any
) – Additional options to configure the reset.
- Return type:
- Returns:
Self.
- steps_done: int
Number of steps done since the last reset.
- update_state(action)[source]
Update the state of this environment using the given action.
- utils
SchedulingUtils
dataclass with a random circuit generator, commutation rulebook and a gate encoder.