Skip to content

MemoryChain-bsuite

MemoryChain

MemoryChain(num_bits: int = 1)

Bases: Environment[EnvState, EnvParams]

Remember a context bit and report it at the end of the episode.

JAX port of the bsuite MemoryChain environment, a test of memory. Each reset samples num_bits context bits and the index of the bit that is queried, both uniformly at random. The context is only observed at the start of the episode and the query only before the last step, in which the action is the answer.

step_env returns the observation of the state before the transition, so the first step repeats the observation returned by the reset.

  • Observation: Box of shape (num_bits + 2,). Entry 0 is the remaining time 1 - time / params.memory_length. Entry 1 is the query index when time == params.memory_length - 1 and 0 otherwise. The other entries are the context bits encoded as -1 and 1 when time == 0 and 0 otherwise.
  • Actions: Discrete(2). The value of the queried context bit. Actions before the last step are ignored.
  • Reward: on the last step, 1 if the action equals the queried context bit and -1 otherwise. 0 on all other steps.
  • Termination: after params.memory_length + 1 steps (6 by default).
  • Truncation: after params.max_steps_in_episode steps (1000 by default).

Parameters:

  • num_bits (int, default: 1 ) –

    Number of context bits.

References

Parameters and state

EnvParams

Bases: EnvParams

Parameters of the MemoryChain environment.

Attributes:

  • memory_length (int) –

    Number of steps before the step in which the agent answers the query.

  • max_steps_in_episode (int) –

    Number of steps after which the episode is truncated.

EnvState

Bases: EnvState

State of the MemoryChain environment.

Attributes:

  • context (int) –

    Context bits to remember, an array of num_bits values in {0, 1}.

  • query (int) –

    Index of the context bit the agent is asked for.

  • total_perfect (int) –

    Number of correct answers in the current episode.

  • total_regret (float) –

    Regret of the current episode. A wrong answer adds 2.

  • time (int) –

    Number of steps taken in the current episode.