Package edu.tufts.hrilab.action
Class GoalManagerImpl
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.action.GoalManagerImpl
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>
Command line options available in sub-class.void
cancelGoal
(long gid) generateUndoGoalState
(Collection<Predicate> startState, Collection<Predicate> endState) getActionStatus
(long gid) Get the ActionStatus for the action that is/was executed in pursuit of the specified goal.getActiveGoals
(Symbol actor) Get the goals that are currently being pursued by the Basic Goal Manager for a particular actor.int
int
getCurrentGoal
(Symbol actorToCheck, int index) 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.getGoalStatus
(long gid) Get the GoalStatus of a particular goal.protected void
init()
Perform any component initialization.protected void
joinOnGoal
(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 void
loadPDDLFiles
(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 void
parseArgs
(org.apache.commons.cli.CommandLine cmdLine) Called directly after construction to pass runtime values that will override default values.void
Register to be notified of ActionInterpreter and inner StepExecution events (start/completion)void
registerNotification
(ai.thinkingrobots.trade.TRADEServiceInfo callback) Register to be notified of all new actions and removed actions.void
resumeGoal
(long gid) void
void
Any component that needs particular shutdown logic needs to override this method andlong
Submit a goal to be achieved.long
submitGoal
(Predicate g, ExecutionType type) long
submitGoal
(Predicate g, ExecutionType type, long priority) long
submitGoal
(Predicate g, ExecutionType type, long priority, PriorityTier priorityTier) long
submitGoalWithMetric
(Predicate g, Predicate metric) Submit a goal to be achieved.void
suspendGoal
(long gid) void
translate
(int contextID) void
translate
(int contextID, TranslationGenerator generator) void
unregisterNotification
(ai.thinkingrobots.trade.TRADEServiceInfo callback) Unregister to be notified of all new actions and removed actions.Methods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
createInstance, createInstance, createInstance, createInstance, executionLoop, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, main, shutdown
-
Constructor Details
-
GoalManagerImpl
public GoalManagerImpl()Constructs the GoalManagerImpl.
-
-
Method Details
-
init
protected void init()Description copied from class:DiarcComponent
Perform 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:
init
in 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
-
-
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)
-
submitGoalWithMetric
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
-
submitGoal
-
submitGoal
-
cancelGoal
public void cancelGoal(long gid) -
suspendGoal
public void suspendGoal(long gid) -
resumeGoal
public void resumeGoal(long gid) -
getCurrentGoals
Get the goals that are currently being pursued by the Execution Manager for a particular actor. This includes both goals which are actively being pursued by the BGM (have a corresponding Action Interpreter) and goals which are being considered by the Execution Manager but may not have been passed on to the BGM yet- Returns:
- a list of predicates representing the goal
-
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
-
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.- 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
-
additionalUsageInfo
Description copied from class:DiarcComponent
Command line options available in sub-class. This should be paired with a parseArgs implementation.- Overrides:
additionalUsageInfo
in classDiarcComponent
- Returns:
-
parseArgs
protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine) Description copied from class:DiarcComponent
Called directly after construction to pass runtime values that will override default values. This should parse all the options that additionalUsageInfo provides.zs- Overrides:
parseArgs
in classDiarcComponent
-
registerAIListener
Register to be notified of ActionInterpreter and inner StepExecution events (start/completion)- Parameters:
al
-
-
registerNotification
public void registerNotification(ai.thinkingrobots.trade.TRADEServiceInfo callback) Register to be notified of all new actions and removed actions.- Parameters:
callback
-
-
unregisterNotification
public void unregisterNotification(ai.thinkingrobots.trade.TRADEServiceInfo callback) Unregister to be notified of all new actions and removed actions.- Parameters:
callback
-
-
getCurrentContextCount
public int getCurrentContextCount() -
getPreconditionsOfGoal
-
generateUndoGoalState
public Predicate generateUndoGoalState(Collection<Predicate> startState, Collection<Predicate> endState) -
setState
-
getStateMachine
-
translate
public void translate(int contextID) -
translate
-
getContextForGoal
-
shutdownComponent
public void shutdownComponent()Description copied from class:DiarcComponent
Any component that needs particular shutdown logic needs to override this method and- Overrides:
shutdownComponent
in classDiarcComponent
-