Class GoalManagerImpl

java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.action.GoalManagerImpl

public class GoalManagerImpl extends DiarcComponent
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

    • 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 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 -
    • 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)
    • submitGoalWithMetric

      public long submitGoalWithMetric(Predicate g, Predicate metric)
      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)
    • submitGoal

      public long submitGoal(Predicate g, ExecutionType type, long priority)
    • submitGoal

      public long submitGoal(Predicate g, ExecutionType type, long priority, PriorityTier priorityTier)
    • cancelGoal

      public void cancelGoal(long gid)
    • suspendGoal

      public void suspendGoal(long gid)
    • resumeGoal

      public void resumeGoal(long gid)
    • 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 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

      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
    • 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.
      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
    • additionalUsageInfo

      protected List<org.apache.commons.cli.Option> additionalUsageInfo()
      Description copied from class: DiarcComponent
      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
      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 class DiarcComponent
    • registerAIListener

      public void registerAIListener(ActionListener al)
      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

      public List<Symbol> getPreconditionsOfGoal(Goal g)
    • generateUndoGoalState

      public Predicate generateUndoGoalState(Collection<Predicate> startState, Collection<Predicate> endState)
    • setState

      public void setState(Predicate predicate)
    • getStateMachine

      public StateMachine getStateMachine()
    • translate

      public void translate(int contextID)
    • translate

      public void translate(int contextID, TranslationGenerator generator)
    • getContextForGoal

      public int getContextForGoal(Predicate g)
    • 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