Interface Planner

All Known Implementing Classes:
BackwardChainingPlanner, UtilityAIPlanner

public interface Planner
Service Provider Interface for planning algorithms.

A Planner creates action plans to achieve goals given the current state. Different planning algorithms can be plugged in via Java ServiceLoader.

Planning Process

  1. Extract current state from @State fields
  2. Find unsatisfied goals
  3. For each goal, find actions that can achieve it
  4. Build a plan (sequence of actions) to reach goal state

Implementation Example


 public class MyPlanner implements Planner {
     @Override
     public List<PlanningAction> plan(Map<String, Object> state) {
         List<PlanningGoal> unsatisfied = findUnsatisfiedGoals(state);
         // ... planning algorithm
     }
 }
 

SPI Registration

Register implementations in META-INF/services/com.tnsai.planning.Planner

Author:
TnsAI Team
See Also:
  • Method Details

    • plan

      Creates a plan to achieve unsatisfied goals.
      Parameters:
      state - current state (belief map)
      Returns:
      ordered list of actions to execute; empty only when every registered goal is already satisfied
      Throws:
      PlanningFailureException - when an unsatisfied goal cannot be reached (implementations that distinguish this case)
    • plan

      default List<PlanningAction> plan(Map<String,Object> state, boolean useChaining)
      Creates a plan with optional chaining.
      Parameters:
      state - current state
      useChaining - true to use backward chaining for multi-step plans
      Returns:
      ordered list of actions
    • getGoals

      List<PlanningGoal> getGoals()
      Returns all registered goals.
      Returns:
      list of goals
    • getActions

      List<PlanningAction> getActions()
      Returns all registered actions.
      Returns:
      list of actions
    • getGoal

      default Optional<PlanningGoal> getGoal(String name)
      Finds a goal by name.
      Parameters:
      name - goal name
      Returns:
      goal if found
    • getAction

      default Optional<PlanningAction> getAction(String name)
      Finds an action by name.
      Parameters:
      name - action name
      Returns:
      action if found
    • findUnsatisfiedGoals

      List<PlanningGoal> findUnsatisfiedGoals(Map<String,Object> state)
      Finds goals that are not currently satisfied.
      Parameters:
      state - current state
      Returns:
      unsatisfied goals, ordered by priority (highest first)
    • findSatisfiedGoals

      List<PlanningGoal> findSatisfiedGoals(Map<String,Object> state)
      Finds goals that are currently satisfied.
      Parameters:
      state - current state
      Returns:
      satisfied goals
    • isGoalSatisfied

      boolean isGoalSatisfied(String goalName, Map<String,Object> state)
      Checks if a specific goal is satisfied.
      Parameters:
      goalName - goal name
      state - current state
      Returns:
      true if goal condition is satisfied
    • isGoalSatisfied

      default boolean isGoalSatisfied(PlanningGoal goal, Map<String,Object> state)
      Checks if a goal is satisfied.
      Parameters:
      goal - goal to check
      state - current state
      Returns:
      true if goal condition is satisfied
    • findActionsForGoal

      List<PlanningAction> findActionsForGoal(PlanningGoal goal, Map<String,Object> state)
      Finds actions that can help achieve a goal.
      Parameters:
      goal - target goal
      state - current state
      Returns:
      applicable actions for the goal
    • findApplicableActions

      List<PlanningAction> findApplicableActions(Map<String,Object> state)
      Finds actions whose preconditions are satisfied.
      Parameters:
      state - current state
      Returns:
      applicable actions
    • isPreconditionSatisfied

      default boolean isPreconditionSatisfied(PlanningAction action, Map<String,Object> state)
      Checks if an action's precondition is satisfied.
      Parameters:
      action - action to check
      state - current state
      Returns:
      true if precondition is satisfied
    • applyEffects

      Map<String,Object> applyEffects(PlanningAction action, Map<String,Object> state)
      Simulates applying an action's effects to a state.
      Parameters:
      action - action to apply
      state - state to modify (returns new state)
      Returns:
      new state after applying effects