Class GoalManagerComponent

java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.action.GoalManagerComponent
All Implemented Interfaces:
GuiProvider

public class GoalManagerComponent extends DiarcComponent implements 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.
  • Constructor Details

    • GoalManagerComponent

      public GoalManagerComponent()
      Constructs the GoalManagerComponent.
  • Method Details

    • additionalUsageInfo

      protected List<org.apache.commons.cli.Option> additionalUsageInfo()
      Description copied from class: DiarcComponent
      Override this method to define command line options available in sub-class. This should be paired with a parseArgs implementation.
      Overrides:
      additionalUsageInfo in class DiarcComponent
      Returns:
    • parseArgs

      protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine)
      Description copied from class: DiarcComponent
      Override 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:
      parseArgs in class DiarcComponent
    • 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 class DiarcComponent
    • initializeGM

      protected void initializeGM()
    • loadPDDLFiles

      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 executed
      Parameters:
      domainFile -
      problemFile -
    • getPriorityTierForGoal

      public PriorityTier getPriorityTierForGoal(Predicate g)
      Get the default priority tier that would be assigned upon submission for the supplied goal predicate
    • getPriorityForGoal

      public long getPriorityForGoal(Predicate g)
      Get the default priority value that would be assigned upon submission for the supplied goal predicate
    • submitGoal

      public long submitGoal(Predicate g)
      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

      public long submitGoal(Predicate g, ExecutionType type)
      Submit a goal to be achieved.
      Parameters:
      g - the goal in goal(actor,state) or action(actor,args) form
      type - action execution type
      Returns:
      the goal ID (for checking status)
    • submitGoal

      public long submitGoal(Predicate g, ExecutionType type, PriorityTier priorityTier)
      Submit a goal to be achieved.
      Parameters:
      g - the goal in goal(actor,state) or action(actor,args) form
      type - action execution type
      priorityTier - priority tier for the submitted goal (overrides default value)
      Returns:
      the goal ID (for checking status)
    • submitGoal

      public long submitGoal(Predicate g, ExecutionType type, Symbol priorityTier)
      Submit a goal to be achieved.
      Parameters:
      g - the goal in goal(actor,state) or action(actor,args) form
      type - action execution type
      priorityTier - priority tier for the submitted goal (overrides default value)
      Returns:
      the goal ID (for checking status)
    • submitGoal

      public long submitGoal(Predicate g, ExecutionType type, PriorityTier priorityTier, long priority)
      Submit a goal to be achieved.
      Parameters:
      g - the goal in goal(actor,state) or action(actor,args) form
      type - action execution type
      priorityTier - 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

      public long submitGoalWithMetric(Predicate g, Predicate metric)
      Submit a goal with a metric for planning
      Parameters:
      g - the goal in goal(actor,state) or action(actor,args) form
      metric - 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

      public List<Predicate> getCurrentGoals(Symbol actor)
      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

      public List<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

      public List<Goal> getCurrentGoals(Goal queryGoal)
      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

      public List<Predicate> getPastGoals()
      Get a copied list of previously executed goals.
      Returns:
      list of past Goals
    • getActiveGoals

      public List<Predicate> getActiveGoals()
      Get a copied list of the goals currently undergoing execution.
      Returns:
      list of active Goals
    • getActiveGoals

      public List<Predicate> getActiveGoals(Symbol actor)
      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

      public GoalInfo getGoalInfo(long goalID)
      Get goal metadata.
      Parameters:
      goalID - the goal id
      Returns:
      a GoalInfo object
    • getAllGoals

      public List<GoalInfo> getAllGoals()
      Get GoalInfo for all (active, current, past) goals.
      Returns:
    • getSystemGoalsPredicates

      public List<Predicate> getSystemGoalsPredicates()
      Get a list of predicates of all active goals for all agentTeams
    • getSystemGoalsPredicates

      public List<Predicate> getSystemGoalsPredicates(Symbol actor)
      Get a list of predicates of all active goals for the supplied agentTeam and all members
    • getPendingGoals

      public List<Predicate> getPendingGoals()
      Get a list of predicates of all pending goals
    • getNextGoal

      public Predicate getNextGoal()
      Get the predicate of the pending goal currently with the highest priority
    • getNextGoal

      public Predicate getNextGoal(Symbol agent)
      Get the predicate of the pending goal for a specific agentTeam currently with the highest priority
    • getGoalId

      public Long getGoalId(Predicate goal)
      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

      public List<Long> getGoalIds(Predicate goal)
      Get the goal ID for all goals matching the supplied predicate. Checks current and past goals.
      Parameters:
      goal -
      Returns:
    • getGoal

      public Goal getGoal(long gid)
      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

      public Goal getCurrentGoal(Symbol actorToCheck, int index)
    • getGoalStatus

      public GoalStatus getGoalStatus(long gid)
      Get the GoalStatus of a particular goal.
      Parameters:
      gid - the goal to check on
      Returns:
      the GoalStatus
    • joinOnGoal

      public GoalStatus joinOnGoal(long gid)
      Wait on the goal to have terminal goal status.
      Parameters:
      gid - the goal
      Returns:
      the GoalStatus of the goal
    • joinOnGoal

      public GoalStatus joinOnGoal(long gid, long millis)
      Wait at most millis milliseconds for the goal to have terminal goal status.
      Parameters:
      gid - the goal
      millis - milliseconds to wait
      Returns:
      the GoalStatus of the goal
    • getActionStatus

      public ActionStatus getActionStatus(long gid)
      Get the ActionStatus for the action that is/was executed in pursuit of the specified goal.
      Parameters:
      gid -
      Returns:
    • getGoalFailConditions

      public Justification getGoalFailConditions(long gid)
      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 callback
      type - 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 callback
      type - NotificationType
    • setState

      public void setState(Predicate predicate)
      Utility method mainly used for testing.
      Parameters:
      predicate -
    • 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 class DiarcComponent
    • getAdapterClassNames

      public String[] getAdapterClassNames()
      Description copied from interface: GuiProvider
      Provide the class names of this component's GUI adapter classes.
      Specified by:
      getAdapterClassNames in interface GuiProvider