`ClassDependencyGraphSearch`
java.lang.Object
com.google.adk.planner.goap.DependencyGraphSearch
在依赖图上执行拓扑搜索,以找到必须按特定顺序执行的代理程序列表;这些代理程序的执行才能产生预期的输出结果。搜索过程基于一组已知的初始前提条件(即已存在的状态信息)。
搜索过程是从目标状态开始,逆向进行的:对于每一个未满足的依赖关系(即那些仍然需要被解决的依赖关系),系统会找到产生该依赖关系的“代理”(即负责处理该依赖关系的组件或模块),并递归地解决该代理所依赖的其他组件或模块的问题。系统使用递归深度优先搜索(recursive DFS)算法来确保依赖关系的正确拓扑顺序(即各个组件或模块之间的依赖关系按照正确的逻辑顺序被处理)。
-
方法概述
Modifier and TypeMethodDescriptionstatic com.google.common.collect.ImmutableList<String> search(GoalOrientedSearchGraph graph, Collection<String> preconditions, String goal) 该功能用于查找一组按特定顺序排列的代理名称列表;这些代理需要依次执行相应的操作,才能最终实现目标。static com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableList<String>> searchGrouped(GoalOrientedSearchGraph graph, List<AgentMetadata> metadata, Collection<String> preconditions, String goal) 将代理(agents)分组到可以并行执行的层级中。
-
方法详细信息(Method Details)
-
search
public static com.google.common.collect.ImmutableList<String> search(GoalOrientedSearchGraph graph, Collection<String> preconditions, String goal) 该功能用于查找一组按特定顺序排列的代理名称列表;这些代理需要依次执行相应的操作,才能最终实现目标。- Parameters:
graph- the dependency graph built from agent metadatapreconditions- state keys already available (no agent needed to produce them)goal- the target output key to produce- Returns:
- ordered list of agent names, from first to execute to last
- Throws:
IllegalStateException- if a dependency cannot be resolved or a cycle is detected
-
searchGrouped
public static com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableList<String>> searchGrouped(GoalOrientedSearchGraph graph, List<AgentMetadata> metadata, Collection<String> preconditions, String goal) 将代理(agents)分组到可以并行执行的层级中。每个组都包含一些代理(agents);这些代理的依赖关系都得到了前面组中的代理或初始前提条件的满足。同一组内的代理彼此独立,可以并行运行。
- Parameters:
graph- the dependency graphmetadata- agent metadata used to compute dependency levelspreconditions- state keys already availablegoal- the target output key- Returns:
- ordered list of agent groups; agents within each group can run in parallel
- Throws:
IllegalStateException- if a dependency cannot be resolved or a cycle is detected
-