本文最后更新于 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
|
def update_agent_belief_actions_in_world(self): last_agent = self.history[-1]['agent'] for agent in self.agents: if last_agent == agent.name: continue 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_last_jp_world = util.get_epistemic_world(reversed(agent_observation_worlds)) hash_set_agent_last_jp_world = util.HashSetFunctions(agent_last_jp_world) 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
| 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): current_agent = node.model.agents[node.current_index] 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) successors = list(start_agent.action_under_jp_worlds[hash_set_jp_world][current_agent.name]) if len(successors) == 0: successors = node.model.get_agent_successors(current_agent.name) successors = [succ for succ in successors if util.is_valid_action(node.model, succ, current_agent.name)]
|
因此,在a选择stay之后,b的规划概念将会更新。b有7中不同的goal set。剩下的流程在图片里。
该方法可以进行拓展,比如:
- 让行动的代理在观测到与以前相同环境时,不再执行以前执行过的行为
- 当由于行为限制导致没有任何行为可用时,用正常的方法模拟行为,或者随机选取一个行为。(这种情况发生的概率极低)