qgym.templates.state module

Generic abstract base class for States of RL environments.

All states should inherit from State.

class qgym.templates.state.State[source]

Bases: Generic[ObservationT, ActionT]

RL State containing the current state of the problem.

abstract create_observation_space()[source]

Create the corresponding observation space.

Return type:

Space[Any]

abstract is_done()[source]

Boolean value stating whether we are in a final state.

Return type:

bool

is_truncated()[source]

Boolean value stating whether the episode is truncated.

Return type:

bool

abstract obtain_info()[source]

Optional debugging info for the current state.

Return type:

dict[Any, Any]

abstract obtain_observation()[source]

Observation based on the current state.

Return type:

TypeVar(ObservationT)

abstract reset(*, seed=None, **_kwargs)[source]

Reset the state.

Return type:

State[TypeVar(ObservationT), TypeVar(ActionT)]

Returns:

Self.

property rng: Generator

Return the random number generator of this environment. If none is set yet, this will generate a new one using numpy.random.default_rng.

Returns:

Random number generator used by this Environment.

seed(seed=None)[source]

Seed the rng of this space, using numpy.random.default_rng.

Parameters:

seed (int | None) – Seed for the rng. Defaults to None

Return type:

list[int | None]

Returns:

The used seeds.

steps_done: int

Number of steps done since the last reset.

abstract update_state(action)[source]

Update the state of this Environment using the given action.

Parameters:

action (TypeVar(ActionT)) – Action to be executed.

Return type:

State[TypeVar(ObservationT), TypeVar(ActionT)]

Returns:

Self.