强化学习 | Multi Agents | Trust Region | HATRPO | HAPPO

学习情况:

🌱 主要看了论文 MATRPO (HATRPO),这篇博客是笔记。其它地,最近简单看了下 GAE 和 Variance of MAPG 两篇,没做笔记

🌱 MATRPO 逻辑很清晰,理论推导做得很扎实,附录的公式推导近10页。其code

🌱 作者写了 论文解析blog,核心点解释得蛮清晰,不涉及复杂的数学推导。认真读下其blog就能懂个大概,再重读论文便轻松了

🌱 全文共7k字,纯手敲。含大量手写笔记,含大量个人主观理解。较于前两篇学习blog,这篇中的原文引用和英文笔记偏多些。如有错误,欢迎指正

🌱 前序文章1:强化学习入门笔记 | UCL silver RL | UC Berkely cs285 DRL

🌱 前序文章2:强化学习 | 策略梯度 | Natural PG | TRPO | PPO

🌱 此篇文章3:强化学习 | Multi Agents | Trust Region | HATRPO | HAPPO

🌱 后序文章4:强化学习 | Mirror Learning


目录:

🌻 论文概述

🌻 符号定义

🌴 MARL基本符号

🌴 Q-value Function

🌴 Advantage Funciton

🌻 Decomposition Lemma

🌻 Trust Region Learning

🌴 表示差异

🌴 Trust Region in Single Agent

🌴  Trust Region in Multi Agents

🌻 HATRPO

🌴 原理

🌴 伪代码

🌻 HAPPO

🌴 原理

🌴 伪代码

🌻 实验情况

🌴 SMAC

🌵 任务

🌵 结果

🌵 分析

🌴 Multi-Agent MuJoCo

🌵 任务

🌵 结果

🌵 分析


🌻 论文概述

​​​​​​​2022 - Kuba - Multi-Agent Constrained Policy Optimisation

该论文将 trust region learning 推广至了MARL (multi-agent reinforcement learning):

其提出并证明了multi-agent advantage decomposition lemma,并基于此提出了多智能体的 sequential policy update scheme (update the policy of agent one by one)

而后,基于单智能体上的TRPO和PPO算法,基于新颖的多智能体策略更新方案,作者构建了针对多智能体的trust region算法:HATRPO (Heterogenous-Agent Trust Region Policy Optimisation) 和 HAPPO (Heterogeneous-Agent Proximal Policy Optimisation)

作者证明了该算法的单调改进性 (monotonic improvement)。且该算法 no parameters sharing,也 no any restrictive assumptions on decomposibility of the joint value function.

关于homogenous (同质的) 和heterogenous (异质的):

  • Homogenous, sharing the same action space and policy parameters, which largely limits their applicability and harm the performance 
  • heterogenous, not need agents to share parameters, having their own action space

对比这两个词,再理解下HATRPO (H -> heterogenous) 的含义。将借由顺次更新各个智能体的策略实现这一设想

那么 homogenous,参数共享有什么缺点吗?

其实将 trust region learning 从 single-agent 推广到 MARL 已经有了一些先例,比如 MAPPO。但是它的推广方式十分简单,"equip all agents with one shared set of parameters and use agents' aggregated trajectories to conduct policy optimisation at every iteration"。它学习一个基于global state的centralized value function和一个 sharing policy(各个agent通过局部观测和共享策略做动作),而且并不能从理论上保证单调递增

那么MARL中参数共享 (共享策略空间)可能导致什么问题呢?

看一个例子,

 证明如下(通过举反例证明还蛮有意思的;这个证明过程比较好懂):

则在这个例子中,parameter sharing can lead to a suboptimal outcome that is exponentially-worse with the increasing number of agents.

该算法在 SMAC task 和 MuJoCo task 上为SOTA


还是那个学习顺序,建议先读透Natural PG,再看TRPO。有了TRPO的基础看PPO会很容易。然后再看这篇HATRPO、HAPPO。

这个推进关系上,每个算法都做了改进和变动,如果略过中间一环或者略过一环的某个推导过程,接下来的算法可能真的吃不透。例如,TRPO中并没有那么细致地讲NPG的推导过程;PPO虽延续了TRPO的思想,但是不再复述TRPO中步步推导的目标函数,而是直接讲其改进了。初学者学习trust region PG时,最好从地基起。


🌻 符号定义

🌴 MARL基本符号


作者新引入两个定义:Multi-agent Q-value Function 和 Multi-agent Advantage Function

🌴 Q-value Function

The multi-agent state-action value function Q for an arbitrary ordered agent subset \begin{equation} i_{1: m}=\left\{i_{1}, \ldots, i_{m}\right\} \end{equation}  is defined as \begin{equation} Q_{\boldsymbol{\pi}}^{i_{1: m}}\left(s, \boldsymbol{a}^{i_{1: m}}\right) \triangleq \mathbb{E}_{\mathbf{a}^{-i_{1: m}}\sim \boldsymbol{\pi}^{-i_{1: m}}}\left[Q_{\boldsymbol{\pi}}\left(s, \boldsymbol{a}^{i_{1: m}}, \mathbf{a}^{-i_{1: m}}\right)\right] \end{equation}

where \begin{equation} -i_{1: m} \end{equation} refers to its complement and \begin{equation} i_{k} \end{equation} refers to the \begin{equation} k^{t h} \end{equation} agent in the ordered subset.

complement应该翻译成补集吧,\begin{equation} -i_{1: m} \end{equation}应该是指除了这1:m个agents外的agents,即\begin{equation} i_{m+1: n} \end{equation}

直观理解下,\begin{equation} Q_{\pi}^{i_{1: m}}\left(s, \boldsymbol{a}^{i_{1: m}}\right) \end{equation} represents the average return if agents \begin{equation} i_{1: m} \end{equation} take a joint action \begin{equation} \boldsymbol{a}^{i_{1: m}} \end{equation} at state s. 

按照我的理解,再白话一点 (部分用词不准确,大概是那个意思qaq),agents \begin{equation} i_{1: m} \end{equation} 的动作是固定的:\begin{equation} \boldsymbol{a}^{i_{1: m}} \end{equation},Q是在该状态s、该动作组\begin{equation} \boldsymbol{a}^{i_{1: m}} \end{equation}条件下的average return。\begin{equation} \mathbf{a}^{-i_{1: m}} \end{equation}是变量,不确定\begin{equation} -i_{1: m} \end{equation}采取什么动作,所以针对它求Q的期望

结合上面两段话,理解Q


🌴 Advantage Funciton

The multi-agent advantage function A of subsets \begin{equation} i_{1: m} \end{equation} is defined as

\begin{equation} A_{\boldsymbol{\pi}}^{i_{1: m}}\left(s, \boldsymbol{a}^{j_{1: k}}, \boldsymbol{a}^{i_{1: m}}\right) \triangleq Q_{\boldsymbol{\pi}}^{j_{1: k}, i_{1: m}}\left(s, \boldsymbol{a}^{j_{1: k}}, \boldsymbol{a}^{i_{1: m}}\right)-Q_{\boldsymbol{\pi}}^{j_{1: k}}\left(s, \boldsymbol{a}^{j_{1: k}}\right) \end{equation}

where \begin{equation} i_{1: m} \end{equation} and \begin{equation} j_{1: k} \end{equation} are disjoint subsets.

Advantage Function指 "relative advantage",要减去 baseline.

在single agent时,\begin{equation} A_{\pi}(s, \boldsymbol{a}) \triangleq Q_{\pi}(s, \boldsymbol{a})-V_{\pi}(s) \end{equation},减掉的baseline是状态s的状态函数

在multi agent时,对\begin{equation} A_{\boldsymbol{\pi}}^{i_{1: m}}\left(s, \boldsymbol{a}^{j_{1: k}}, \boldsymbol{a}^{i_{1: m}}\right) \triangleq Q_{\boldsymbol{\pi}}^{j_{1: k}, i_{1: m}}\left(s, \boldsymbol{a}^{j_{1: k}}, \boldsymbol{a}^{i_{1: m}}\right)-Q_{\boldsymbol{\pi}}^{j_{1: k}}\left(s, \boldsymbol{a}^{j_{1: k}}\right) \end{equation}这么理解: 

写好后截屏时候Prodrafts滑了下没截上,留下了这道斜线。 却发现Prodrafts居然没有橡皮擦(大离谱!),破坏了画面的线消不去了。幸亏我没有强迫症,唉

而且这个米色纸配这个灰色底色好丑啊显得qaq 后面还是白色吧


🌻 Decomposition Lemma

Multi-Agent Advantage Decomposition Lemma (pivotal)

In any cooperative Markov games, given a joint policy Π, for any state s, and any agent subset \begin{equation} i_{1: m} \end{equation}, the below equations holds. 

\begin{equation} A_{\pi}^{i_{1: m}}\left(s, \boldsymbol{a}^{i_{1: m}}\right)=\sum_{j=1}^{m} A_{\pi}^{i_{j}}\left(s, \boldsymbol{a}^{i_{1: j-1}}, a^{i_{j}}\right) \end{equation}

The lemma shows that the joint advantage function can be decomposed into a summation of each agent's local advantages in the process of sequential update


解释一下,


Multi-Agent Advantage Decomposition Lemma证明如下:

ps:从直观上理解从第一行到第二行的意思


🌻 Trust Region Learning

将首先写下 trust region learning 应用于 single agent 和 multi agent 时的差异的符号表示和推导顺序,并回顾下 single agent 上的 objective 推导过程,而后顺畅推广至 multi agents中

这里名词执意写 single agent 和 multi agents 而不写 TRPO 和 HATRPO 的原因是 trust region in single agent (描述于 那篇著名论文) / multi agents (描述于本篇论文) 是一种思想,一种scheme,而 TRPO 和 PPO 是前者思想的实现方式,HATRPO 和 HAPPO 是后者思想的实现方式


🌴 表示差异

ps:notion definition不同,一方面是本文作者下了multi agents时的 Q-value Function 和 Advantage Function 的新定义(已写于上一part),另一方面不同论文表示意思相同时可能用了不同符号(部分总结于这儿)。为了下面对比两篇论文数学公式时候顺畅一点,才写了这一部分。其实没什么影响,只是很正常地不同论文中表示不同


🌴 Trust Region in Single Agent


🌴  Trust Region in Multi Agents




推导过程中一些严格的数学证明:

关于 J(Π) 单调递增的严格证明:


证明中用到的 Lemma8 及其证明:


然后作者又研究了一下该算法的收敛:

This definition characterises the equilibrium point at convergence for cooperative MARL tasks. Based on this, we have the following result that describes the asymptotic convergent behaviour towards NE.

Nash equilibrium (纳什平衡):平衡了,任何人都利益最大化,认为遵循协议行事强于违背协议。参考链接1参考链接2 , 参考链接3

Proposition2中涉及到的Corollary 1又涉及到蛮多推导和定义:



使用归纳法证明,好长,不放了


最后的证明结果是,\begin{equation} \left\|Q_{\pi}-Q_{\hat{\pi}}\right\| \leq \frac{\gamma Q_{\max } \cdot|\mathcal{A}| \cdot\|\pi-\hat{\pi}\|}{1-\gamma} \end{equation}


终于得到了Corollary1: 


作者甚至证明了,

在TRPO中都没有看到类似证明,真的好严谨啊


还有一个连续性相关的推论一起放在这里:


感觉涉及到好多凸优化的概念,看上面这些推导的时候,查了NE、凸优化convexity、compact set、close set、Bolzano-weierstrass theorem、lipschitz-continuity、variance decomposition、affine function 好多,实在懒得整理了,有空再说吧。可能会跟课程完整过一遍之后


则 Sequential Policy Update Scheme的伪代码:


🌻 HATRPO

🌴 原理


🌴 伪代码


🌻 HAPPO

🌴 原理

To further alleviate the computation burden from Hessian Matrix in HATRPO,one can follow the idea of PPO by considering only using first order derivatives. This is achieved by making agent \begin{equation} i_{m} \end{equation} choose a policy parameter \begin{equation} \theta_{k+1}^{i_{m}} \end{equation} which maimises the clipping objecvite of

\begin{equation} \mathbb{E}_{\mathrm{s} \sim \rho_{\pi_{\theta_{k}}}, \mathbf{a}^{\sim} \boldsymbol{\pi}_{\theta_{k}}}\left[\min \left(\frac{\pi_{\theta^{i_{m}}}^{i_{m}}\left(\mathrm{a}^{i} \mid \mathrm{s}\right)}{\pi_{\theta_{k}^{i_{m}}}^{i_{m}}\left(\mathrm{a}^{i} \mid \mathrm{s}\right)} M^{i_{1: m}}(s, \mathbf{a}), \operatorname{clip}\left(\frac{\pi_{\theta^{i_{m}}}^{i_{m}}\left(\mathrm{a}^{i} \mid \mathrm{s}\right)}{\pi_{\theta_{k}^{i_{m}}}\left(\mathrm{a}^{i} \mid \mathrm{s}\right)}, 1 \pm \epsilon\right) M^{i_{1: m}}(s, \mathbf{a})\right]\right. \end{equation}

The optimisation process can be performed by stochastic gradient methods such as Adam.


🌴 伪代码


🌻 实验情况

🌴 SMAC

🌵 任务

SMAC (StarCraftll Multi-Agent Challenge) contains a set of StarCraft maps in which a team of ally units aims to defeat the opponent team.


🌵 结果

在该任务上,IPPO、MAPPO 这类 parameter sharing 算法,和 HATRPO、HAPPO 这类 non-parameter sharing 算法都达到了100%


🌵 分析

SMAC任务较简单,non-parameter sharing is not necessarily required,sharing policies is sufficient to solve SMAC tasks.


🌴 Multi-Agent MuJoCo

🌵 任务

A continuous control task. MuJoCo tasks challenge a robot to learn an optimal way of motion; Multi-Agent MuJoCo models each part of a robot as an independent agent, for example, a leg for a spider or an arm for a swimmer.


🌵 结果

HATRPO and HAPPO enjoy superior performance over those of parameter-sharing methods:IPPPO and MAPPO, and the gap enlarges with the number of agents increases.

HATRPO and HAPPO also outperform non-parameter sharing MADDPG with both in terms of reward values and variance.


🌵 分析

该任务较复杂,能较好与其它算法拉开差距,体现HATRPO和其背后原理的优越性

HATRPO比 参数共享方法 (MAPPO等) 性能好得多。而且随着智能体数目增加,两类算法差距越拉越大,这说明了modelling heterogeneous policies的必要性

HATRPO性能表现优于HAPPO,认为是 hard KL constraint 相较于 clipping  更接近原理描述

  • 20
    点赞
  • 31
    收藏
  • 打赏
    打赏
  • 19
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:技术黑板 设计师:CSDN官方博客 返回首页
评论 19

打赏作者

111辄

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值