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

[Tasks] VMAS MPE (Vectorized) #42

Merged
merged 6 commits into from
Dec 26, 2023
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 .github/unittest/install_vmas.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

python -m pip install vmas
python -m pip install git+https://github.com/proroklab/VectorizedMultiAgentSimulator.git
sudo apt-get update
sudo apt-get install python3-opengl xvfb
7 changes: 7 additions & 0 deletions benchmarl/conf/task/vmas/simple_adversary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defaults:
- _self_
- vmas_simple_adversary_config

max_steps: 100
n_agents: 3
n_adversaries: 1
6 changes: 6 additions & 0 deletions benchmarl/conf/task/vmas/simple_crypto.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
defaults:
- _self_
- vmas_simple_crypto_config

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

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

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

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

max_steps: 100
n_agents: 3
obs_agents: True
17 changes: 17 additions & 0 deletions benchmarl/conf/task/vmas/simple_tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defaults:
- _self_
- vmas_simple_tag_config

max_steps: 100
num_good_agents: 1
num_adversaries: 3
num_landmarks: 2
shape_agent_rew: False
shape_adversary_rew: False
agents_share_rew: False
adversaries_share_rew: True
observe_same_team: True
observe_pos: True
observe_vel: True
bound: 1.0
respawn_at_catch: False
10 changes: 10 additions & 0 deletions benchmarl/conf/task/vmas/simple_world_comm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
defaults:
- _self_
- vmas_simple_world_comm_config

max_steps: 100
num_good_agents: 2
num_adversaries: 4
num_landmarks: 1
num_food: 2
num_forests: 2
18 changes: 18 additions & 0 deletions benchmarl/environments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,19 @@
from .vmas.balance import TaskConfig as BalanceConfig
from .vmas.navigation import TaskConfig as NavigationConfig
from .vmas.sampling import TaskConfig as SamplingConfig

from .vmas.simple_adverasary import TaskConfig as VmasSimpleAdversaryConfig
from .vmas.simple_crypto import TaskConfig as VmasSimpleCryptoConfig
from .vmas.simple_push import TaskConfig as VmasSimplePushConfig
from .vmas.simple_reference import TaskConfig as VmasSimpleReferenceConfig
from .vmas.simple_speaker_listener import TaskConfig as VmasSimpleSpeakerListenerConfig
from .vmas.simple_spread import TaskConfig as VmasSimpleSpreadConfig
from .vmas.simple_tag import TaskConfig as VmasSimpleTagConfig
from .vmas.simple_world_comm import TaskConfig as VmasSimpleWorldComm
from .vmas.transport import TaskConfig as TransportConfig
from .vmas.wheel import TaskConfig as WheelConfig


# This is a registry mapping task config schemas names to their python dataclass
# It is used by hydra to validate loaded configs.
# You will see the "envname_taskname_config" strings in the hydra defaults at the top of yaml files.
Expand All @@ -47,6 +57,14 @@
"vmas_navigation_config": NavigationConfig,
"vmas_transport_config": TransportConfig,
"vmas_wheel_config": WheelConfig,
"vmas_simple_adversary_config": VmasSimpleAdversaryConfig,
"vmas_simple_crypto_config": VmasSimpleCryptoConfig,
"vmas_simple_push_config": VmasSimplePushConfig,
"vmas_simple_reference_config": VmasSimpleReferenceConfig,
"vmas_simple_speaker_listener_config": VmasSimpleSpeakerListenerConfig,
"vmas_simple_spread_config": VmasSimpleSpreadConfig,
"vmas_simple_tag_config": VmasSimpleTagConfig,
"vmas_simple_world_comm_config": VmasSimpleWorldComm,
"pettingzoo_multiwalker_config": MultiwalkerConfig,
"pettingzoo_waterworld_config": WaterworldConfig,
"pettingzoo_simple_adversary_config": SimpleAdversaryConfig,
Expand Down
8 changes: 8 additions & 0 deletions benchmarl/environments/vmas/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ class VmasTask(Task):
NAVIGATION = None
TRANSPORT = None
WHEEL = None
SIMPLE_ADVERSARY = None
SIMPLE_CRYPTO = None
SIMPLE_PUSH = None
SIMPLE_REFERENCE = None
SIMPLE_SPEAKER_LISTENER = None
SIMPLE_SPREAD = None
SIMPLE_TAG = None
SIMPLE_WORLD_COMM = None

def get_env_fun(
self,
Expand Down
14 changes: 14 additions & 0 deletions benchmarl/environments/vmas/simple_adverasary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#

from dataclasses import dataclass, MISSING


@dataclass
class TaskConfig:
max_steps: int = MISSING
n_agents: int = MISSING
n_adversaries: int = MISSING
13 changes: 13 additions & 0 deletions benchmarl/environments/vmas/simple_crypto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#

from dataclasses import dataclass, MISSING


@dataclass
class TaskConfig:
max_steps: int = MISSING
dim_c: int = MISSING
12 changes: 12 additions & 0 deletions benchmarl/environments/vmas/simple_push.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#

from dataclasses import dataclass, MISSING


@dataclass
class TaskConfig:
max_steps: int = MISSING
12 changes: 12 additions & 0 deletions benchmarl/environments/vmas/simple_reference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#

from dataclasses import dataclass, MISSING


@dataclass
class TaskConfig:
max_steps: int = MISSING
12 changes: 12 additions & 0 deletions benchmarl/environments/vmas/simple_speaker_listener.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#

from dataclasses import dataclass, MISSING


@dataclass
class TaskConfig:
max_steps: int = MISSING
14 changes: 14 additions & 0 deletions benchmarl/environments/vmas/simple_spread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#

from dataclasses import dataclass, MISSING


@dataclass
class TaskConfig:
max_steps: int = MISSING
obs_agents: bool = MISSING
n_agents: int = MISSING
24 changes: 24 additions & 0 deletions benchmarl/environments/vmas/simple_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#

from dataclasses import dataclass, MISSING


@dataclass
class TaskConfig:
max_steps: int = MISSING
num_good_agents: int = MISSING
num_adversaries: int = MISSING
num_landmarks: int = MISSING
shape_agent_rew: bool = MISSING
shape_adversary_rew: bool = MISSING
agents_share_rew: bool = MISSING
adversaries_share_rew: bool = MISSING
observe_same_team: bool = MISSING
observe_pos: bool = MISSING
observe_vel: bool = MISSING
bound: float = MISSING
respawn_at_catch: bool = MISSING
17 changes: 17 additions & 0 deletions benchmarl/environments/vmas/simple_world_comm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#

from dataclasses import dataclass, MISSING


@dataclass
class TaskConfig:
max_steps: int = MISSING
num_good_agents: int = MISSING
num_adversaries: int = MISSING
num_landmarks: int = MISSING
num_food: int = MISSING
num_forests: int = MISSING
3 changes: 1 addition & 2 deletions test/test_vmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
IppoConfig,
IsacConfig,
MaddpgConfig,
MappoConfig,
MasacConfig,
QmixConfig,
VdnConfig,
Expand Down Expand Up @@ -57,7 +56,7 @@ def test_all_algos(
)
experiment.run()

@pytest.mark.parametrize("algo_config", [MappoConfig, QmixConfig])
@pytest.mark.parametrize("algo_config", [IppoConfig, MasacConfig])
@pytest.mark.parametrize("task", list(VmasTask))
def test_all_tasks(
self,
Expand Down
Loading