benchmarl.experiment.Experiment

class Experiment(task: Task | TaskClass, algorithm_config: AlgorithmConfig, model_config: ModelConfig, seed: int, config: ExperimentConfig, critic_model_config: ModelConfig | None = None, callbacks: List[Callback] | None = None)[source]

Bases: CallbackNotifier

Main experiment class in BenchMARL.

Parameters:
  • task (TaskClass) – the task

  • algorithm_config (AlgorithmConfig) – the algorithm configuration

  • model_config (ModelConfig) – the policy model configuration

  • seed (int) – the seed for the experiment

  • config (ExperimentConfig) – The experiment config. Note that some of the parameters of this config may go un-consumed based on the provided algorithm or model config. For example, all parameters off-policy algorithm would not be used when running an experiment with an on-policy algorithm.

  • critic_model_config (ModelConfig, optional) – the policy model configuration. If None, it defaults to model_config

  • callbacks (list of Callback, optional) – callbacks for this experiment

property on_policy: bool

Whether the algorithm has to be run on policy.

run()[source]

Run the experiment until completion.

evaluate()[source]

Run just the evaluation loop once.

close()[source]

Close the experiment.

state_dict() OrderedDict[source]

Get the state_dict for the experiment.

load_state_dict(state_dict: Dict) None[source]

Load the state_dict for the experiment.

Parameters:

state_dict (dict) – the state dict

static reload_from_file(restore_file: str) Experiment[source]

Restores the experiment from the checkpoint file.

This method expects the same folder structure created when an experiment is run. The checkpoint file (restore_file) is in the checkpoints directory and a config.pkl file is present a level above at restore_file/../../config.pkl

Parameters:

restore_file (str) – The checkpoint file (.pt) of the experiment reload.

Returns:

The reloaded experiment.