Package edu.tufts.hrilab.action
Class GoalManagerComponent
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.action.GoalManagerComponent
- All Implemented Interfaces:
GuiProvider
The Goal Manager (also called the Action Manager or simply “Action”)
manages and executes agents' tasks (goals) in DIARC. In addition to simple action
execution, the Goal Manager keeps track of the agents' state (using the Belief
Component) and verifies that all goals and actions are acceptable and that the
conditions for their execution are met. When interfaced with a Planner
the Goal Manager can plan as well as avoid and resolve conflicting actions.
-
Field Summary
Fields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, log, shouldRunExecutionLoop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<org.apache.commons.cli.Option>Override this method to define command line options available in sub-class.voidCancels all active goals (other than the listen goal)voidCancels all pending and active goals (other than the listen goal)voidCancels all pending goalsvoidcancelGoal(long gid) Searches pending and active goals to cancel the goal corresponding to the supplied goalIdbooleancancelPendingGoalByIndex(int index) Cancels the upcoming pending goal at the supplied index (ordered in descending priority)getActionStatus(long gid) Get the ActionStatus for the action that is/was executed in pursuit of the specified goal.Get a copied list of the goals currently undergoing execution.getActiveGoals(Symbol actor) Get the goals that are currently being pursued by the Basic Goal Manager for a particular actor.String[]Provide the class names of this component's GUI adapter classes.Get GoalInfo for all (active, current, past) goals.getCurrentGoal(Symbol actorToCheck, int index) Get a list of all pending and active goals.getCurrentGoals(Goal queryGoal) Get a list of all current pending and/or active goals matching the goalPredicate query.getCurrentGoals(Symbol actor) Get the goals that are currently being pursued by the Execution Manager for a particular actor.getGoal(long gid) Get the Goal for a particular goal ID.getGoalFailConditions(long gid) Get failure condition for a particular goal.Get the goal ID for a goal predicate.getGoalIds(Predicate goal) Get the goal ID for all goals matching the supplied predicate.getGoalInfo(long goalID) Get goal metadata.getGoalStatus(long gid) Get the GoalStatus of a particular goal.Get the predicate of the pending goal currently with the highest prioritygetNextGoal(Symbol agent) Get the predicate of the pending goal for a specific agentTeam currently with the highest priorityGet a copied list of previously executed goals.Get a list of predicates of all pending goalslongGet the default priority value that would be assigned upon submission for the supplied goal predicateGet the default priority tier that would be assigned upon submission for the supplied goal predicateGet a list of predicates of all active goals for all agentTeamsgetSystemGoalsPredicates(Symbol actor) Get a list of predicates of all active goals for the supplied agentTeam and all membersprotected voidinit()Perform any component initialization.protected voidjoinOnGoal(long gid) Wait on the goal to have terminal goal status.joinOnGoal(long gid, long millis) Wait at most millis milliseconds for the goal to have terminal goal status.protected voidloadPDDLFiles(String domainFile, String problemFile) Parse PDDL domain and problem files and add the contents to: 1) actions -> action database 2) facts -> belief (e.g., predicates, functions, types, constants, objects, init, etc) 3) goal -> GM initial goals to be executedprotected voidparseArgs(org.apache.commons.cli.CommandLine cmdLine) Override this method to parse command line args in the sub-class.voidregisterGoalManagerNotification(ai.thinkingrobots.trade.TRADEServiceInfo callback, NotificationType type) Register to be notified of the specified NotificationType.voidresumeGoal(long gid) Searches pending and active goals to resume the goal corresponding to the supplied goalIdvoidUtility method mainly used for testing.voidAny component that needs particular shutdown logic needs to override this method andlongSubmit a goal to be achieved.longsubmitGoal(Predicate g, ExecutionType type) Submit a goal to be achieved.longsubmitGoal(Predicate g, ExecutionType type, PriorityTier priorityTier) Submit a goal to be achieved.longsubmitGoal(Predicate g, ExecutionType type, PriorityTier priorityTier, long priority) Submit a goal to be achieved.longsubmitGoal(Predicate g, ExecutionType type, Symbol priorityTier) Submit a goal to be achieved.longsubmitGoalWithMetric(Predicate g, Predicate metric) Submit a goal with a metric for planningvoidsuspendGoal(long gid) Searches pending and active goals to suspend the goal corresponding to the supplied goalIdvoidunregisterGoalManagerNotification(ai.thinkingrobots.trade.TRADEServiceInfo callback, NotificationType type) Unregister to be notified of the specified NotificationType.Methods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
createInstance, createInstance, createInstance, createInstance, executionLoop, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, main, shutdown
-
Constructor Details
-
GoalManagerComponent
public GoalManagerComponent()Constructs the GoalManagerComponent.
-
-
Method Details
-
additionalUsageInfo
Description copied from class:DiarcComponentOverride this method to define command line options available in sub-class. This should be paired with a parseArgs implementation.- Overrides:
additionalUsageInfoin classDiarcComponent- Returns:
-
parseArgs
protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine) Description copied from class:DiarcComponentOverride this method to parse command line args in the sub-class. Called directly after construction to pass runtime values that will override default values. This should parse all the options that additionalUsageInfo provides.- Overrides:
parseArgsin classDiarcComponent
-
init
protected void init()Description copied from class:DiarcComponentPerform any component initialization. This should not be used for setting local fields to default values as was the case in DIARC. This method is called after the constructor, and after parseArgs. Setting default values should be done in field declaration or in the constructor.- Overrides:
initin classDiarcComponent
-
initializeGM
protected void initializeGM() -
loadPDDLFiles
Parse PDDL domain and problem files and add the contents to: 1) actions -> action database 2) facts -> belief (e.g., predicates, functions, types, constants, objects, init, etc) 3) goal -> GM initial goals to be executed- Parameters:
domainFile-problemFile-
-
getPriorityTierForGoal
Get the default priority tier that would be assigned upon submission for the supplied goal predicate -
getPriorityForGoal
Get the default priority value that would be assigned upon submission for the supplied goal predicate -
submitGoal
Submit a goal to be achieved.- Parameters:
g- the goal in goal(actor,state) or action(actor,args) form- Returns:
- the goal ID (for checking status)
-
submitGoal
Submit a goal to be achieved.- Parameters:
g- the goal in goal(actor,state) or action(actor,args) formtype- action execution type- Returns:
- the goal ID (for checking status)
-
submitGoal
Submit a goal to be achieved.- Parameters:
g- the goal in goal(actor,state) or action(actor,args) formtype- action execution typepriorityTier- priority tier for the submitted goal (overrides default value)- Returns:
- the goal ID (for checking status)
-
submitGoal
Submit a goal to be achieved.- Parameters:
g- the goal in goal(actor,state) or action(actor,args) formtype- action execution typepriorityTier- priority tier for the submitted goal (overrides default value)- Returns:
- the goal ID (for checking status)
-
submitGoal
Submit a goal to be achieved.- Parameters:
g- the goal in goal(actor,state) or action(actor,args) formtype- action execution typepriorityTier- priority tier for the submitted goal (overrides default value)priority- priority value for the submitted goal (overrides default value)- Returns:
- the goal ID (for checking status)
-
submitGoalWithMetric
Submit a goal with a metric for planning- Parameters:
g- the goal in goal(actor,state) or action(actor,args) formmetric- the metric in maximize(...) or minimize(...) form- Returns:
- the goal ID (for checking status)
-
cancelGoal
public void cancelGoal(long gid) Searches pending and active goals to cancel the goal corresponding to the supplied goalId -
cancelAllCurrentGoals
public void cancelAllCurrentGoals()Cancels all pending and active goals (other than the listen goal) -
cancelAllActiveGoals
public void cancelAllActiveGoals()Cancels all active goals (other than the listen goal) -
cancelAllPendingGoals
public void cancelAllPendingGoals()Cancels all pending goals -
cancelPendingGoalByIndex
public boolean cancelPendingGoalByIndex(int index) Cancels the upcoming pending goal at the supplied index (ordered in descending priority) -
suspendGoal
public void suspendGoal(long gid) Searches pending and active goals to suspend the goal corresponding to the supplied goalId -
resumeGoal
public void resumeGoal(long gid) Searches pending and active goals to resume the goal corresponding to the supplied goalId -
getCurrentGoals
Get the goals that are currently being pursued by the Execution Manager for a particular actor. This includes both goals which are actively undergoing execution (have a corresponding Action Interpreter) and goals which are being considered by the Execution Manager but may not have been passed on to execution yet- Returns:
- a list of predicates representing the goal
-
getCurrentGoals
Get a list of all pending and active goals. TODO: remove this method, or at least make it not a trade service -
getCurrentGoals
Get a list of all current pending and/or active goals matching the goalPredicate query. TODO: remove this method, or at least make it not a trade service- Returns:
- goals with matching goalPredicate, or null if no matching goal found
-
getPastGoals
Get a copied list of previously executed goals.- Returns:
- list of past
Goals
-
getActiveGoals
Get a copied list of the goals currently undergoing execution.- Returns:
- list of active
Goals
-
getActiveGoals
Get the goals that are currently being pursued by the Basic Goal Manager for a particular actor.- Returns:
- a list of predicates representing the goal
-
getGoalInfo
Get goal metadata.- Parameters:
goalID- the goal id- Returns:
- a GoalInfo object
-
getAllGoals
Get GoalInfo for all (active, current, past) goals.- Returns:
-
getSystemGoalsPredicates
Get a list of predicates of all active goals for all agentTeams -
getSystemGoalsPredicates
Get a list of predicates of all active goals for the supplied agentTeam and all members -
getPendingGoals
Get a list of predicates of all pending goals -
getNextGoal
Get the predicate of the pending goal currently with the highest priority -
getNextGoal
Get the predicate of the pending goal for a specific agentTeam currently with the highest priority -
getGoalId
Get the goal ID for a goal predicate. Checks current and past goals. If no goal is found, -1 is returned. NOTE: Depending on the ExecutionManager subclass, more than one match may exist and one will be returned at random.- Parameters:
goal-- Returns:
-
getGoalIds
Get the goal ID for all goals matching the supplied predicate. Checks current and past goals.- Parameters:
goal-- Returns:
-
getGoal
Get the Goal for a particular goal ID. This checks current and past goals. Returns null if no matching goal ID is found. TODO: remove this method once PA doesn't use GM- Parameters:
gid- goal id.- Returns:
- the Goal corresponding to the ID.
-
getCurrentGoal
-
getGoalStatus
Get the GoalStatus of a particular goal.- Parameters:
gid- the goal to check on- Returns:
- the GoalStatus
-
joinOnGoal
Wait on the goal to have terminal goal status.- Parameters:
gid- the goal- Returns:
- the GoalStatus of the goal
-
joinOnGoal
Wait at most millis milliseconds for the goal to have terminal goal status.- Parameters:
gid- the goalmillis- milliseconds to wait- Returns:
- the GoalStatus of the goal
-
getActionStatus
Get the ActionStatus for the action that is/was executed in pursuit of the specified goal.- Parameters:
gid-- Returns:
-
getGoalFailConditions
Get failure condition for a particular goal.- Parameters:
gid- the goal to check on- Returns:
- a justification indicating the cause of failure
-
registerGoalManagerNotification
public void registerGoalManagerNotification(ai.thinkingrobots.trade.TRADEServiceInfo callback, NotificationType type) Register to be notified of the specified NotificationType.- Parameters:
callback- TRADE service callbacktype- NotificationType- See Also:
-
unregisterGoalManagerNotification
public void unregisterGoalManagerNotification(ai.thinkingrobots.trade.TRADEServiceInfo callback, NotificationType type) Unregister to be notified of the specified NotificationType.- Parameters:
callback- TRADE service callbacktype- NotificationType
-
setState
Utility method mainly used for testing.- Parameters:
predicate-
-
shutdownComponent
public void shutdownComponent()Description copied from class:DiarcComponentAny component that needs particular shutdown logic needs to override this method and- Overrides:
shutdownComponentin classDiarcComponent
-
getAdapterClassNames
Description copied from interface:GuiProviderProvide the class names of this component's GUI adapter classes.- Specified by:
getAdapterClassNamesin interfaceGuiProvider
-