Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Simplify extending benchmarl and improve extending examples #89

Merged
merged 22 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ They differ based on many aspects, here is a table with the current environments
> BenchMARL uses the [TorchRL MARL API](https://github.com/pytorch/rl/issues/1463) for grouping agents.
> In competitive environments like MPE, for example, teams will be in different groups. Each group has its own loss,
> models, buffers, and so on. Parameter sharing options refer to sharing within the group. See the example on [creating
> a custom algorithm](examples/extending/algorithm/custom_algorithm.py) for more info.
> a custom algorithm](examples/extending/algorithm/algorithms/customalgorithm.py) for more info.

**Models**. Models are neural networks used to process data. They can be used as actors (policies) or,
when requested, as critics. We provide a set of base models (layers) and a SequenceModel to concatenate
Expand Down
2 changes: 1 addition & 1 deletion benchmarl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ def _load_hydra_schemas():
cs.store(name=f"{algo_name}_config", group="algorithm", node=algo_schema)
# Load task schemas
for task_schema_name, task_schema in _task_class_registry.items():
cs.store(name=task_schema_name, group="task", node=task_schema)
cs.store(name=f"{task_schema_name}_config", group="task", node=task_schema)

_load_hydra_schemas()
11 changes: 6 additions & 5 deletions benchmarl/algorithms/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,15 @@ def get_from_yaml(cls, path: Optional[str] = None):

Returns: the loaded AlgorithmConfig
"""

if path is None:
return cls(
**AlgorithmConfig._load_from_yaml(
name=cls.associated_class().__name__,
)
config = AlgorithmConfig._load_from_yaml(
name=cls.associated_class().__name__
)

else:
return cls(**_read_yaml_config(path))
config = _read_yaml_config(path)
return cls(**config)

@staticmethod
@abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion benchmarl/conf/task/pettingzoo/multiwalker.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defaults:
- _self_
- pettingzoo_multiwalker_config
- _self_

task: "multiwalker_v9"
# number of bipedal walker agents in environment
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/pettingzoo/simple_adversary.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- pettingzoo_simple_adversary_config
- _self_


task: "simple_adversary_v3"
N: 2
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/pettingzoo/simple_crypto.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- pettingzoo_simple_crypto_config
- _self_


task: "simple_crypto_v3"
max_cycles: 100
3 changes: 2 additions & 1 deletion benchmarl/conf/task/pettingzoo/simple_push.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- pettingzoo_simple_push_config
- _self_
- pettingzoo_simple_push_config


task: "simple_push_v3"
max_cycles: 100
3 changes: 2 additions & 1 deletion benchmarl/conf/task/pettingzoo/simple_reference.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- pettingzoo_simple_reference_config
- _self_


task: "simple_reference_v3"
max_cycles: 100
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/pettingzoo/simple_speaker_listener.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- pettingzoo_simple_speaker_listener_config
- _self_


task: "simple_speaker_listener_v4"
max_cycles: 100
3 changes: 2 additions & 1 deletion benchmarl/conf/task/pettingzoo/simple_spread.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- pettingzoo_simple_spread_config
- _self_


task: "simple_spread_v3"
max_cycles: 100
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/pettingzoo/simple_tag.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- pettingzoo_simple_tag_config
- _self_


task: "simple_tag_v3"
num_good: 2
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/pettingzoo/simple_world_comm.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- pettingzoo_simple_world_comm_config
- _self_


task: "simple_world_comm_v3"
num_good: 2
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/pettingzoo/waterworld.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- pettingzoo_waterworld_config
- _self_


task: "waterworld_v4"
max_cycles: 500
Expand Down
3 changes: 1 addition & 2 deletions benchmarl/conf/task/vmas/balance.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
defaults:
- _self_
- vmas_balance_config

- _self_

max_steps: 100
n_agents: 4
Expand Down
2 changes: 1 addition & 1 deletion benchmarl/conf/task/vmas/ball_passage.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defaults:
- _self_
- vmas_ball_passage_config
- _self_

max_steps: 500
n_passages: 1
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/ball_trajectory.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_ball_trajectory_config
- _self_


max_steps: 100
joints: True
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/buzz_wire.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_buzz_wire_config
- _self_


max_steps: 100
random_start_angle: True
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/discovery.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_discovery_config
- _self_


max_steps: 100
n_agents: 5
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/dispersion.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_dispersion_config
- _self_



max_steps: 100
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/dropout.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_dropout_config
- _self_



max_steps: 100
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/flocking.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_flocking_config
- _self_


max_steps: 100
n_agents: 4
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/give_way.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_give_way_config
- _self_


max_steps: 100
mirror_passage: False
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/joint_passage.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_joint_passage_config
- _self_


max_steps: 500
n_passages: 1
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/joint_passage_size.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_joint_passage_size_config
- _self_


max_steps: 500
n_passages: 3
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/multi_give_way.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_multi_give_way_config
- _self_


max_steps: 200
agent_collision_penalty: -0.1
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/navigation.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_navigation_config
- _self_



max_steps: 100
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/passage.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_passage_config
- _self_


max_steps: 500
n_passages: 1
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/reverse_transport.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_reverse_transport_config
- _self_


max_steps: 100
n_agents: 4
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/sampling.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_sampling_config
- _self_



max_steps: 100
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/simple_adversary.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_simple_adversary_config
- _self_


max_steps: 100
n_agents: 3
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/simple_crypto.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_simple_crypto_config
- _self_


max_steps: 100
dim_c: 4
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/simple_push.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defaults:
- _self_
- vmas_simple_push_config
- _self_


max_steps: 100
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/simple_reference.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defaults:
- _self_
- vmas_simple_reference_config
- _self_


max_steps: 100
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/simple_speaker_listener.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defaults:
- _self_
- vmas_simple_speaker_listener_config
- _self_


max_steps: 100
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/simple_spread.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_simple_spread_config
- _self_


max_steps: 100
n_agents: 3
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/simple_tag.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_simple_tag_config
- _self_


max_steps: 100
num_good_agents: 1
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/simple_world_comm.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_simple_world_comm_config
- _self_


max_steps: 100
num_good_agents: 2
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/transport.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_transport_config
- _self_



max_steps: 100
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/wheel.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_wheel_config
- _self_


max_steps: 100
n_agents: 4
Expand Down
3 changes: 2 additions & 1 deletion benchmarl/conf/task/vmas/wind_flocking.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defaults:
- _self_
- vmas_wind_flocking_config
- _self_


max_steps: 100
horizon: 100
Expand Down
Loading
Loading