From 3990fdc10f363bdb43f8aa6b71bdeffcf42e35cb Mon Sep 17 00:00:00 2001 From: Matteo Bettini Date: Tue, 3 Oct 2023 13:25:56 +0100 Subject: [PATCH] [Examples] Add smac script Signed-off-by: Matteo Bettini --- premade_scripts/smacv2/config.yaml | 18 ++++++++++++++++++ premade_scripts/smacv2/smacv2_run.py | 24 ++++++++++++++++++++++++ premade_scripts/vmas/config.yaml | 8 ++++---- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 premade_scripts/smacv2/config.yaml create mode 100644 premade_scripts/smacv2/smacv2_run.py diff --git a/premade_scripts/smacv2/config.yaml b/premade_scripts/smacv2/config.yaml new file mode 100644 index 00000000..66ec402b --- /dev/null +++ b/premade_scripts/smacv2/config.yaml @@ -0,0 +1,18 @@ +defaults: + - experiment: base_experiment + - algorithm: ??? + - task: ??? + - model: layers/mlp + - model@critic_model: layers/mlp + - _self_ + +hydra: + searchpath: + # Tells hydra to add the default benchmarl configuration to its path + - pkg://benchmarl/conf + +seed: 0 + +experiment: + sampling_device: "cuda" + train_device: "cuda" diff --git a/premade_scripts/smacv2/smacv2_run.py b/premade_scripts/smacv2/smacv2_run.py new file mode 100644 index 00000000..3f0d9c21 --- /dev/null +++ b/premade_scripts/smacv2/smacv2_run.py @@ -0,0 +1,24 @@ +import hydra +from benchmarl.experiment import Experiment + +from benchmarl.hydra_config import load_experiment_from_hydra +from hydra.core.hydra_config import HydraConfig +from omegaconf import DictConfig, OmegaConf + + +@hydra.main(version_base=None, config_path=".", config_name="config") +def hydra_experiment(cfg: DictConfig) -> None: + hydra_choices = HydraConfig.get().runtime.choices + task_name = hydra_choices.task + algorithm_name = hydra_choices.algorithm + + print(f"\nAlgorithm: {algorithm_name}, Task: {task_name}") + print("\nLoaded config:\n") + print(OmegaConf.to_yaml(cfg)) + + experiment: Experiment = load_experiment_from_hydra(cfg, task_name=task_name) + experiment.run() + + +if __name__ == "__main__": + hydra_experiment() diff --git a/premade_scripts/vmas/config.yaml b/premade_scripts/vmas/config.yaml index 9fc22595..5362a2d5 100644 --- a/premade_scripts/vmas/config.yaml +++ b/premade_scripts/vmas/config.yaml @@ -1,18 +1,18 @@ defaults: - experiment: base_experiment - - algorithm: mappo - - task: vmas/balance + - algorithm: ??? + - task: ??? - model: layers/mlp - model@critic_model: layers/mlp - _self_ -seed: 0 - hydra: searchpath: # Tells hydra to add the default benchmarl configuration to its path - pkg://benchmarl/conf +seed: 0 + experiment: sampling_device: "cuda" train_device: "cuda"