Skip to content

SafeRL-Lab/Multi-Agent-Constrained-Policy-Optimisation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Agent Constrained Policy Optimisation (MACPO)

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.

Environments Supported:

1. Installation

1.1 Create Environment

# 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 .

1.2 Install Safety Multi-Agent Mujoco

LD_LIBRARY_PATH=${HOME}/.mujoco/mujoco200/bin;
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so

2. Train

cd MACPO/macpo/scripts or cd MAPPO-Lagrangian/mappo_lagrangian/scripts
chmod +x ./train_mujoco.sh
./train_mujoco.sh

3. Results

Performance comparisons on tasks of Safe ManyAgent Ant, Safe Ant, and Safe HalfCheetah in terms of cost (the first row) and reward (the second row). The safety constraint values are: 1 for ManyAgent Ant, 0.2 for Ant, and 5 for HalfCheetah. Our methods consistently achieve almost zero costs, thus satisfying safe constraints, on all tasks. In terms of reward, our methods outperform IPPO and MAPPO on some tasks but underperform HAPPO, which is also an unsafe algorithm.

4. Demos

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.

5. Publication

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}
}

Acknowledgments

We thank the list of contributors from the following open source repositories: MAPPO, HAPPO, safety-starter-agents, CMBPO.

About

Multi-Agent Constrained Policy Optimisation (MACPO; MAPPO-L).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.7%
  • Shell 0.3%