前言
NeurIPS 2020 的论文,POMO: Policy Optimization with Multiple Optima for Reinforcement Learning
KWON Y D, CHOO J, KIM B. POMO: Policy Optimization with Multiple Optima for Reinforcement Learning[C]// Proceedings of the 34th International Conference on Neural Information Processing Systems. Red Hook, NY: Curran Associates Inc., 2020: 21188-21198.
SUN R, ZHENG Z, WANG Z K. Learning Encodings for Constructive Neural Combinatorial Optimization Needs to Regret[C]// Proceedings of the 38th AAAI Conference on Artificial Intelligence (AAAI 2024). Palo Alto, CA: AAAI Press, 2024: 20803-20811.
一、动机
利用一个现象,即选取的第一个节点(非驻点)对是否是最优解没有影响。
由上图可以看到,轨迹
(
v
1
,
v
2
,
v
3
,
v
4
,
v
5
)
(v_1,v_2,v_3,v_4,v_5)
(v1,v2,v3,v4,v5)与轨迹
(
v
2
,
v
3
,
v
4
,
v
5
,
v
1
)
(v_2,v_3,v_4,v_5,v_1)
(v2,v3,v4,v5,v1)都是最优轨迹,根据这个现象作者试图提出一个强化学习策略。
上式是通用的强化策略,由此可知第一个节点对后序轨迹影响极大,此与作者发现的现象相悖。所以作者试图提出一个新的策略。
引自原文的经典概述:
Conceptually, explorations by POMO are analogous to guiding a student to solve the same problem repeatedly from many different angles, exposing her to a variety of problem-solving techniques that would otherwise be unused.
从概念上讲,POMO的探索类似于引导学生从许多不同的角度反复解决同一个问题,让她接触到各种各样的解决问题的技巧,否则这些技巧是不会被使用的。
二、作者的实现
elif state.selected_count == 1: # Second Move, POMO
selected = torch.arange(start=1, end=pomo_size+1)[None, :].expand(batch_size, pomo_size)
prob = torch.ones(size=(batch_size, pomo_size))
作者通过将选择START节点的概率设置为1。
在解决TSP问题时,上图(a)表示单一轨迹的生成,即从第一个节点(START)开始,由策略神经网络选择下一步动作
a
i
a_i
ai。
上图(b)表示将图(a)的操作扩展到有N个不同START节点的情况下,即采用并行运算,每一次运算生成N个动作。
作者的创新
共享基线
采用共享基线,有助于抵抗局部最优解。
算法1:小批量的POMO训练
-
算法1的参数
- 训练集 S S S
- 样本初始节点 N N N个
- 训练步数 T T T
- 批次数 B B B
- 初始化策略网络参数 θ \theta θ
-
执行流程
- 循环:训练步数从1遍历到
T
T
T
- 将实例分为 B B B个批次,每一个批次是一组数据即 s i s_i si
- 选出每一个批次数据中的初始节点共记 B ∗ N B*N B∗N个
- 根据策略 π θ \pi_\theta πθ、初始节点 α i j \alpha_i^j αij和每一批次数据集 s i s_i si生成轨迹 τ i j \tau_i^j τij
- 根据轨迹生成每一个批次的共享基线
- 梯度上升法跟新梯度
- 更新策略网络参数 θ θ θ
- 循环:训练步数从1遍历到
T
T
T
算法2:实例增强
-
算法2的参数如下:
- 输入实例s,是一组数据
- 策略 π θ \pi_\theta πθ
- 初始节点数 N N N
- 数据变换次数 K K K
-
执行流程
- 数据变换次数K次,将数据s拓展为K次
- 每一组数据 s k s_k sk选取N个不同的初始节点 α k j \alpha_k^j αkj
- 通过贪婪策略选取所有轨迹中奖励最大的轨迹,并输出其索引 k max k_{\max} kmax, j max j_{\max} jmax
- 返回奖励最大的轨迹 τ k m a x j m a x τ_{k_max}^{j_max} τkmaxjmax(全局最优路径)
上表所示,通过将坐标进行变换得到 ∗ 8 *8 ∗8的实例。生成8个不同的在 ( 0 , 1 ) ∗ ( 0 , 1 ) (0,1)*(0,1) (0,1)∗(0,1)的方框内的实例
猜想:强化实例仍有许多生成的方法
引用:
For the sake of improving the inference result, however, there is no need to stick to “valid” problem
instances that comply to the setup rule, as long as the (near-) optimal ordering of node sequence can
be generated. Take, for example, rotation by 10 degrees with the center of rotation at (0.5, 0.5). The
new problem instance generated by this transformation may (or may not!) contain nodes that are
outside the unit square, but this is okay. Although the policy network is trained using nodes inside the
unit square only, it is reasonable to assume that it would still perform well with the nodes that are
close from the boundaries. As long as the network can produce alternative result which has nonzero
chance of being better and there is room in the time budget, such non-complying transformations are
still worth trying during the inference stage.
为了改善推理结果,没有必要坚持“有效”的问题实例,符合设置规则,只要(近)最优排序的节点序列可以产生。例如,旋转10度,旋转中心位于(0.5,0.5)。这个转换生成的新问题实例可能(也可能不会!)包含单位正方形外的节点,但这没关系。虽然策略网络仅使用单位正方形内的节点进行训练,但可以合理地假设它仍然可以使用靠近边界的节点进行良好的性能。只要网络可以产生具有非零机会更好的替代结果,并且在时间预算中有空间,这种不符合要求的转换仍然值得在推理阶段尝试。
策略网络结构
The Attention Model. All of our POMO experiments use the policy network named Attention Model (AM), introduced by Kool et al. [10]. The AM is particularly well-suited for POMO, although we emphasize that POMO is a general RL method, not tied to a specific structure of the policy network. The AM consists of two main components, an encoder and a decoder. The majority of computation happens inside the heavy, multi-layered encoder, through which information of each node and its relation with other nodes is embedded as a vector. The decoder then generates a solution sequence autoregressively using these vectors as the keys for its dot-product attention mechanism.
注意力模型我们所有的POMO实验都使用Kool等人[10]引入的名为Attention Model(AM)的策略网络。AM特别适合POMO,尽管我们强调POMO是一种通用的RL方法,不依赖于策略网络的特定结构。AM由两个主要组件组成,编码器和解码器。大部分计算发生在繁重的多层编码器中,通过编码器,每个节点的信息及其与其他节点的关系被嵌入为向量。然后,解码器使用这些向量作为其点积注意力机制的密钥来自回归地生成解序列。
脱胎于Attention Model(AM)的策略网络。
在CVRP中使用POMO
如图所示,最优解只有三个序列表示。所以POMO虽然在处理CVRP问题时是有优势的,但其仍有提升空间。
But, unlike TSP, not all nodes in CVRP can be the first steps for optimal trajectories (see Figure 4) and there is no way of figuring out which of the nodes are good without actually knowing the optimal solution a priori. One way to resolve this issue is to add a secondary network that returns candidates for optimal starting nodes to be used by POMO.
但是,与TSP不同,CVRP中并非所有节点都可以成为最佳轨迹的第一步(见图4),并且在没有实际先验知识的情况下,无法确定哪些节点是好的。解决这个问题的一种方法是添加一个辅助网络,该网络返回POMO使用的最佳起始节点的候选者。
POMO提升收敛速度
注意事项
记住POMO在每个训练时期使用的轨迹是简单REINFORCE的N倍。然而,由于轨迹生成的并行处理,POMO训练时间与REINFORCE相当。例如,TSP100训练对于POMO每个epoch需要大约7分钟,而对于REINFORCE需要6分钟。