Skip to content

SimpleBandit-bsuite

SimpleBandit

SimpleBandit(num_actions: int = 11)

Bases: Environment[EnvState, EnvParams]

Pull the arm with the highest reward in a deterministic multi-armed bandit.

JAX port of the bsuite bandit environment. Each reset assigns num_actions evenly spaced rewards from 0 to 1 to the actions in a random order. Every step is a complete episode, so step redraws the assignment after each action.

  • Observation: Box of shape (1, 1) that always contains 1.
  • Actions: Discrete(num_actions). The index of the arm to pull.
  • Reward: the reward assigned to the chosen action, a value from 0 to 1.
  • Termination: after every step.
  • Truncation: after params.max_steps_in_episode steps (100 by default). Not reached with the default, since every episode terminates after one step.

Parameters:

  • num_actions (int, default: 11 ) –

    Number of arms.

References

Parameters and state

EnvParams

Bases: EnvParams

Parameters of the SimpleBandit environment.

Attributes:

  • optimal_return (float) –

    Reward of the best action, used to compute the regret.

  • max_steps_in_episode (int) –

    Number of steps after which the episode is truncated.

EnvState

Bases: EnvState

State of the SimpleBandit environment.

Attributes:

  • rewards (float) –

    Reward of each action, shape (num_actions,). A random permutation of num_actions evenly spaced values from 0 to 1.

  • total_regret (float) –

    Sum of params.optimal_return - reward over the steps of the current episode.

  • time (float) –

    Number of steps taken in the current episode.