One repository is all that is necessary for Multi-agent Reinforcement Learning (MARL)
One repository is all that is necessary for Multi-agent Reinforcement Learning (MARL)
MARLlib: A Multi-agent Reinforcement Learning Library
| :exclamation: News |
|---|
| March 2023 :anchor:We are excited to announce that a major update has just been released. For detailed version information, please refer to the version info. |
| May 2023 Exciting news! MARLlib now supports five more tasks: MATE, GoBigger, Overcooked-AI, MAPDN, and AirCombat. Give them a try! |
| June 2023 OpenAI: Hide and Seek and SISL environments are incorporated into MARLlib. |
| Aug 2023 :tada:MARLlib has been accepted for publication in JMLR. |
| Sept 2023 Latest PettingZoo with Gymnasium are compatiable within MARLlib. |
| Nov 2023 We are currently in the process of creating a hands-on MARL book and aim to release the draft by the end of 2023. |
Multi-agent Reinforcement Learning Library (MARLlib) is a MARL library that utilizes Ray and one of its toolkits RLlib. It offers a comprehensive platform for developing, training, and testing MARL algorithms across various tasks and environments.
Here's an example of how MARLlib can be used:
from marllib import marl
# prepare env
env = marl.make_env(environment_name="mpe", map_name="simple_spread", force_coop=True)
# initialize algorithm with appointed hyper-parameters
mappo = marl.algos.mappo(hyperparam_source='mpe')
# build agent model based on env + algorithms + user preference
model = marl.build_model(env, mappo, {"core_arch": "mlp", "encode_layer": "128-256"})
# start training
mappo.fit(env, model, stop={'timesteps_total': 1000000}, share_policy='group')Here we provide a table for the comparison of MARLlib and existing work.
| Library | Supported Env | Algorithm | Parameter Sharing | Model |
|---|---|---|---|---|
| PyMARL | 1 cooperative | 5 | share | GRU |
| PyMARL2 | 2 cooperative | 11 | share | MLP + GRU |
| MAPPO Benchmark | 4 cooperative | 1 | share + separate | MLP + GRU |
| MAlib | 4 self-play | 10 | share + group + separate | MLP + LSTM |
| EPyMARL | 4 cooperative | 9 | share + separate | GRU |
| HARL | 8 cooperative | 9 | share + separate | MLP + CNN + GRU |
| MARLlib | 17 no task mode restriction | 18 | share + group + separate + customizable | MLP + CNN + GRU + LSTM |
| Library | Github Stars | Documentation | Issues Open | Activity | Last Update |
|---|---|---|---|---|---|
| PyMARL | :x: | ||||
| PyMARL2 | :x: | ||||
| MAPPO Benchmark | :x: | ||||
| MAlib | |||||
| EPyMARL | :x: | ||||
| HARL* | :x: | ||||
| MARLlib |
* HARL is the latest MARL library that has been recently released:fire:. If cutting-edge MARL algorithms with state-of-the-art performance are your target, HARL is definitely worth a look!
:beginner: MARLlib offers several key features that make it stand out:
:rocket: Using MARLlib, you can take advantage of various benefits, such as:
Note: Please note that at this time, MARLlib is only compatible with Linux operating systems.
First, install MARLlib dependencies to guarantee basic usage. following this guide, finally install patches for RLlib.
$ conda create -n marllib python=3.8 # or 3.9
$ conda activate marllib
$ git clone https://github.com/Replicable-MARL/MARLlib.git && cd MARLlib
$ pip install -r requirements.txtPlease follow this guide.
Note: We recommend the gym version around 0.20.0.
pip install "gym==0.20.0"Fix bugs of RLlib using patches by running the following command:
$ cd /Path/To/MARLlib/marllib/patch
$ python add_patch.py -y$ pip install --upgrade pip
$ pip install marllibWe provide a Dockerfile for building the MARLlib docker image in MARLlib/docker/Dockerfile and a devcontainer setup in MARLlib/.devcontainer folder. If you use the devcontainer, one thing to note is that you may need to customise certain arguments in runArgs of devcontainer.json according to your hardware, for example the --shm-size argument.
Prepare the configuration
There are four parts of configurations that take charge of the whole training process.
Before training, ensure all the parameters are set correctly, especially those you don't want to change.
Note: You can also modify all the pre-set parameters via MARLLib API.*
Register the environment
Ensure all the dependencies are installed for the environment you are running with. Otherwise, please refer to MARLlib documentation.
| task mode | api example |
|---|---|
| cooperative | marl.make_env(environment_name="mpe", map_name="simple_spread", force_coop=True) |
| collaborative | marl.make_env(environment_name="mpe", map_name="simple_spread") |
| competitive | marl.make_env(environment_name="mpe", map_name="simple_adversary") |
| mixed | marl.make_env(environment_name="mpe", map_name="simple_crypto") |
Most of the popular environments in MARL research are supported by MARLlib:
| Env Name | Learning Mode | Observability | Action Space | Observations |
|---|---|---|---|---|
| LBF | cooperative + collaborative | Both | Discrete | 1D |
| RWARE | cooperative | Partial | Discrete | 1D |
| MPE | cooperative + collaborative + mixed | Both | Both | 1D |
| SISL | cooperative + collaborative | Full | Both | 1D |
| SMAC | cooperative | Partial | Discrete | 1D |
| MetaDrive | collaborative | Partial | Continuous | 1D |
| MAgent | collaborative + mixed | Partial | Discrete | 2D |
| Pommerman | collaborative + competitive + mixed | Both | Discrete | 2D |
| MAMuJoCo | cooperative | Full | Continuous | 1D |
| GRF | collaborative + mixed | Full | Discrete | 2D |
| Hanabi | cooperative | Partial | Discrete | 1D |
| MATE | cooperative + mixed | Partial | Both | 1D |
| GoBigger | cooperative + mixed | Both | Continuous | 1D |
| Overcooked-AI | cooperative | Full | Discrete | 1D |
| PDN | cooperative | Partial | Continuous | 1D |
| **[AirCombat](ht |
No open issues yet, or sync has not completed.