langgoap.AnytimePlanningStrategy

langgoap.AnytimePlanningStrategy#

class AnytimePlanningStrategy(time_budget_ms, *, inner=None)[source]#

Return the best plan found within a wall-clock time budget.

With the default inner strategy (A*) the deadline is enforced natively: langgoap.planner.astar.plan() runs weighted A* with a tightening weight schedule, so a complete plan exists early and is improved while the budget lasts, and the best complete plan found so far is returned on expiry (see langgoap.planner.astar.ANYTIME_WEIGHTS).

Any other inner strategy is a black box: it runs in a worker thread and, when it exceeds the budget, this strategy returns None immediately with a RuntimeWarning. Python cannot interrupt a running thread, so the inner strategy keeps running in the background until it finishes on its own; prefer strategies that accept a budget themselves (AStarStrategy(time_budget_ms=...), MCTSStrategy iteration limits) when the planning problem is large.

Parameters:
  • time_budget_ms (float) – Wall-clock budget in milliseconds.

  • inner (PlanningStrategy | None) – Strategy to wrap. None (default) or an AStarStrategy uses the native anytime A* path.

__init__(time_budget_ms, *, inner=None)[source]#
Parameters:
Return type:

None

Methods

__init__(time_budget_ms, *[, inner])

plan(start, goal, actions, *[, ...])