Package com.tnsai.planning
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
- Extract current state from
@Statefields - Find unsatisfied goals
- For each goal, find actions that can achieve it
- 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 Summary
Modifier and TypeMethodDescriptionapplyEffects(PlanningAction action, Map<String, Object> state) Simulates applying an action's effects to a state.findActionsForGoal(PlanningGoal goal, Map<String, Object> state) Finds actions that can help achieve a goal.findApplicableActions(Map<String, Object> state) Finds actions whose preconditions are satisfied.findSatisfiedGoals(Map<String, Object> state) Finds goals that are currently satisfied.findUnsatisfiedGoals(Map<String, Object> state) Finds goals that are not currently satisfied.default Optional<PlanningAction> Finds an action by name.Returns all registered actions.default Optional<PlanningGoal> Finds a goal by name.getGoals()Returns all registered goals.default booleanisGoalSatisfied(PlanningGoal goal, Map<String, Object> state) Checks if a goal is satisfied.booleanisGoalSatisfied(String goalName, Map<String, Object> state) Checks if a specific goal is satisfied.default booleanisPreconditionSatisfied(PlanningAction action, Map<String, Object> state) Checks if an action's precondition is satisfied.Creates a plan to achieve unsatisfied goals.default List<PlanningAction> Creates a plan with optional chaining.
-
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
Creates a plan with optional chaining.- Parameters:
state- current stateuseChaining- 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
Finds a goal by name.- Parameters:
name- goal name- Returns:
- goal if found
-
getAction
Finds an action by name.- Parameters:
name- action name- Returns:
- action if found
-
findUnsatisfiedGoals
Finds goals that are not currently satisfied.- Parameters:
state- current state- Returns:
- unsatisfied goals, ordered by priority (highest first)
-
findSatisfiedGoals
Finds goals that are currently satisfied.- Parameters:
state- current state- Returns:
- satisfied goals
-
isGoalSatisfied
Checks if a specific goal is satisfied.- Parameters:
goalName- goal namestate- current state- Returns:
- true if goal condition is satisfied
-
isGoalSatisfied
Checks if a goal is satisfied.- Parameters:
goal- goal to checkstate- current state- Returns:
- true if goal condition is satisfied
-
findActionsForGoal
Finds actions that can help achieve a goal.- Parameters:
goal- target goalstate- current state- Returns:
- applicable actions for the goal
-
findApplicableActions
Finds actions whose preconditions are satisfied.- Parameters:
state- current state- Returns:
- applicable actions
-
isPreconditionSatisfied
Checks if an action's precondition is satisfied.- Parameters:
action- action to checkstate- current state- Returns:
- true if precondition is satisfied
-
applyEffects
Simulates applying an action's effects to a state.- Parameters:
action- action to applystate- state to modify (returns new state)- Returns:
- new state after applying effects
-