Class AStarSearchStrategy

java.lang.Object
com.google.adk.planner.goap.AStarSearchStrategy
All Implemented Interfaces:
SearchStrategy

public final class AStarSearchStrategy extends Object implements SearchStrategy
这是一种“向前搜索”策略(A* forward search strategy),它从初始条件(preconditions)开始逐步探索,直至达到目标状态;在此过程中,所有相关代理(agents)的输入条件都会被满足(即这些代理的所有输入值都符合要求)。

使用一个按照 f 分数(g + h)排序的优先队列;其中:

  • `g` = 到目前为止激活的代理数量(每个代理的成本相同)
  • h = 可接受的启发式方法(heuristic method);用于计算从目标状态(goal state)出发、无法被满足的依赖关系(unsatisfied dependencies)的数量;这些依赖关系需要通过反向遍历(reachable backward)来发现。

在找到目标后,会重新构建代理的路径,并将后续任务委托给其他组件或流程进行处理。 DependencyGraphSearch.assignParallelLevels(ImmutableList, List, Collection, GoalOrientedSearchGraph) 用于实现数据的并行分组(parallel grouping)。

  • 构造函数详细信息

    • AStarSearchStrategy

      public AStarSearchStrategy()
  • 方法详细信息(Method Details)

    • searchGrouped

      public com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableList<String>> searchGrouped(GoalOrientedSearchGraph graph, List<AgentMetadata> metadata, Collection<String> preconditions, String goal)
      描述内容复制自接口文档: SearchStrategy
      搜索能够实现目标的代理执行组(agent execution groups)。
      Specified by:
      searchGrouped in interface SearchStrategy
      Parameters:
      graph - the dependency graph
      metadata - agent metadata
      preconditions - state keys already available
      goal - the target output key
      Returns:
      ordered list of agent groups for parallel execution