认知状态-行为集合以限制本地模拟时其他代理的可能动作

本文最后更新于 2025年8月20日 晚上

该方法的目标状态过滤法采用的是对neutral settings下的epistemic problem的规划逻辑的一个尝试2文章中提到的反选过滤法。

基本介绍

该方法实际上十分简单,就是在一个代理行动过后,其他代理如果能够直接看见这个代理,则将该代理当前的行为与自己对当前环境的jp world进行记录。在自己本地进行BFS搜索时,如果遇到了相同的jp world,且行动回合为该代理,则只会将该代理在该jp world下做过的行为当作successor。

举个例子:

graph LR
a(1) <--> b(2)
b <--> c(3)
b <--> d(4)

一开始a在1,b在3。a的目标为去3,b的目标为去1。同房间不能同时有复数个代理存在。

根据我们之前已经推算过的流程,a在一开始会选择stay。此时,由于问题设置中b能够看见a选择了stay,因此b会将自己对当前环境的认知状态也a的行为进行记录,以让当自己进行本地BFS搜索时,在a的轮次遇到相同环境时,让a的行为只有stay一种。实际算法代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 在last_agent执行完自己的行为后,self.history中会添加上一批ontic functions,action agent, action和complete signal信息。

def update_agent_belief_actions_in_world(self):
last_agent = self.history[-1]['agent']
for agent in self.agents:
# 代理不会记录自己的行为,以避免在BFS中限制了自己的行为。
if last_agent == agent.name:
continue
# 只有上一个行动的agent能被当前agent看见,才会记录他的行为
if last_agent not in self.observation_function.get_observable_agents(self, self.history[-1]['functions'], agent.name):
continue
agent_observation_worlds = self.get_history_functions_of_agent(agent.name)
# 获取上一个时间戳下当前agent的jp world
agent_last_jp_world = util.get_epistemic_world(reversed(agent_observation_worlds))
# 将其转为可Hash的function集合(这个不重要)
hash_set_agent_last_jp_world = util.HashSetFunctions(agent_last_jp_world)
# 为agent的action_under_jp_worlds添加jp world,last_agent与他的行为对
# action_under_jp_worlds是一个dict[HashSetFunctions, dict[str, set[Action]]]结构。
agent.action_under_jp_worlds[hash_set_agent_last_jp_world][last_agent].add(self.history[-1]['action'])

在BFS中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# BFS节点
class BFSNode:
def __init__(self, current_index, action, model, priority):
self.current_index: int = current_index
self.actions: list[Action] = action
self.model: Model = model
self.priority: int = priority

def __lt__(self, other):
return self.priority < other.priority

def singleBFS(self, virtual_model, agent_name):
# 此处virtual model为执行规划算法用的虚拟世界, agent_name为实际世界中当前回合下即将行动的agent的名字

# ...其他流程
# 获取virtual model中当前行动回合的agent
current_agent = node.model.agents[node.current_index]
# 检查当前世界状态中,对于agent_name代理来说是否有笃定current_agent会做的行为
# 如果有,则直接将这些行为记为successors,如果没有则正常生成successors

# 获取对于agent_name来说,在当前virtual model下的jp world
jp_world_for_agent_name = util.get_epistemic_world(reversed(node.model.get_history_functions_of_agent(agent_name)))
hash_set_jp_world = util.HashSetFunctions(jp_world_for_agent_name)

# start_agent是model中的agent_name代理
# 获取在start_agent的action_under_jp_worlds中current_agent在当前jp world下执行过的行为
successors = list(start_agent.action_under_jp_worlds[hash_set_jp_world][current_agent.name])
# 如果没有任何行为,则正常生成successors,有则保留
if len(successors) == 0:
successors = node.model.get_agent_successors(current_agent.name)
# 进保留可用的successors
successors = [succ for succ in successors if util.is_valid_action(node.model, succ, current_agent.name)]

# ...其他流程

因此,在a选择stay之后,b的规划概念将会更新。b有7中不同的goal set。剩下的流程在图片里。

该方法可以进行拓展,比如:

  • 让行动的代理在观测到与以前相同环境时,不再执行以前执行过的行为
  • 当由于行为限制导致没有任何行为可用时,用正常的方法模拟行为,或者随机选取一个行为。(这种情况发生的概率极低)

认知状态-行为集合以限制本地模拟时其他代理的可能动作
http://example.com/2025/08/19/Decentralized-Epistemic-Planning/认知状态-行为集合以限制本地模拟时其他代理的可能动作/
作者
Clain Chen
发布于
2025年8月19日
许可协议