The repository is for the paper: Multi-Agent Constrained Policy Optimisation, in which we investigate the problem of safe MARL. The problem of safe multi-agent learning with safety constraints has not been rigorously studied; very few solutions have been proposed, nor a sharable testing environment or benchmarks. To fill these gaps, in this work, we formulate the safe multi-agent reinforcement learning problem as a constrained Markov game and solve it with trust region methods. Our solutions---Multi-Agent Constrained Policy Optimisation (MACPO) and MAPPO-Lagrangian---leverage on the theory of Constrained Policy Optimisation (CPO) and multi-agent trust region learning, and critically, they enjoy theoretical guarantees of both monotonic improvement in reward and satisfaction of safety constraints at every iteration. Experimental results reveal that MACPO/MAPPO-Lagrangian significantly outperform baselines in terms of balancing the performance and constraint satisfaction, e.g. MAPPO, IPPO, HAPPO.
# create conda environment
conda create -n macpo python==3.7
conda activate macpo
pip install -r requirements.txt
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c nvidia
cd MACPO/macpo (for the macpo algorithm) or cd MAPPO-Lagrangian/mappo_lagrangian (for the mappo_lagrangian algorithm)
pip install -e .
- Install mujoco accoring to mujoco-py and MuJoCo website.
- clone Safety Multi-Agent Mujoco to the env path (in this repository, have set the path).
LD_LIBRARY_PATH=${HOME}/.mujoco/mujoco200/bin;
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so
cd MACPO/macpo/scripts or cd MAPPO-Lagrangian/mappo_lagrangian/scripts
chmod +x ./train_mujoco.sh
./train_mujoco.sh
Ant Task: the width of the corridor set by two walls is 10 m. The environment emits the cost of 1 for an agent, if the distance between the robot and the wall is less than 1.8 m, or when the robot topples over.
A demo denotes unsafe performance using HAPPO on Ant-2x4 task. | A demo denotes safe performance using MAPPO-Lagrangian on Ant-2x4 task. |
HalfCheetah Task: In the task, the agents move inside a corridor (which constraints their movement, but does not induce costs). Together with them, there are bombs moving inside the corridor. If an agent finds itself too close to the bomb, the distance between an agent and the bomb is less than 9m, a cost of 1 will be emitted, at the same time, the bomb will turn blood red.
A demo denotes unsafe performance using HAPPO on HalfCheetah-2x3 task. | A demo denotes safe performance using MAPPO-Lagrangian on HalfCheetah-2x3 task. |
ManyAgent Ant Task One: In the ManyAgent Ant task, the width of the corridor set by two walls is 9m. The environment emits the cost of 1 for an agent, if the distance between the robot and the wall is less than 1.8 m, or when the robot topples over.
A demo denotes unsafe performance using HAPPO on ManyAgent Ant-2x3 task. | A demo denotes safe performance using MAPPO-Lagrangian on ManyAgent Ant-2x3 task. |
ManyAgent Ant Task Two: In the ManyAgent Ant task, the width of the corridor is 12 m; its walls fold at the angle of 30 degrees. The environment emits the cost of 1 for an agent, if the distance between the robot and the wall is less than 1.8 m, or when the robot topples over.
A demo denotes unsafe performance using HAPPO on ManyAgent Ant-2x3 task. | A demo denotes unsafe performance using MAPPO-Lagrangian on ManyAgent Ant-2x3 task. | A demo denotes safe performance using MACPO on ManyAgent Ant-2x3 task. |
If you find the repository useful, please cite the paper:
@article{gu2021multi,
title={Multi-Agent Constrained Policy Optimisation},
author={Gu, Shangding and Kuba, Jakub Grudzien and Wen, Munning and Chen, Ruiqing and Wang, Ziyan and Tian, Zheng and Wang, Jun and Knoll, Alois and Yang, Yaodong},
journal={arXiv preprint arXiv:2110.02793},
year={2021}
}
We thank the list of contributors from the following open source repositories: MAPPO, HAPPO, safety-starter-agents, CMBPO.