Class Goal

java.lang.Object
edu.tufts.hrilab.action.goal.Goal

public class Goal extends Object
Goal encapsulates a goal Predicate, the ActionInterpreter in charge of executing it and some additional information.
  • Constructor Details

    • Goal

      public Goal(Predicate goalState)
      Construct goal that defines the actor to achieve the goal, and the desired goal/action. This is the main method used when using the GoalManager submitGoal method.
      Parameters:
      goalState -
    • Goal

      public Goal(Symbol actor, Symbol goalState)
      Construct goal with explicit actor. This is primarily used for creating goal instance from ASL
      Parameters:
      actor -
      goalState -
    • Goal

      public Goal(Symbol actor, Symbol goalState, Observable observable)
      Goal constructor used to explicitly mark goal as an observation. It's possible to have an observation goal without the OBS(actor, state) predicate form. This is almost always the case for observations from conditions and effects checks.
      Parameters:
      actor - the actor doing the observing (can be null, if it can be inferred from predicate)
      goalState - the goal predicate
      observable - enum specifying if goal is observable, and if so what type (true/false/default)
  • Method Details

    • getPredicate

      public Predicate getPredicate()
      Get the goal predicate. This can contain free variables, and it can also become bound depending on where in the goal execution process this method is called.
      Returns:
    • bindPredicate

      public boolean bindPredicate(Context context)
      Binds goal predicate to values in context.
      Parameters:
      context - context providing bindings
      Returns:
      true if predicate was bound using variables in context
    • getId

      public long getId()
    • isAction

      public boolean isAction()
    • setIsAction

      public void setIsAction(boolean value)
    • isObservation

      public boolean isObservation()
    • getObservableEnum

      public Observable getObservableEnum()
    • isPersistent

      public boolean isPersistent()
    • getActor

      public Symbol getActor()
    • getFailConditions

      public Justification getFailConditions()
    • getStatus

      public GoalStatus getStatus()
    • getStartTime

      public long getStartTime()
    • getEndTime

      public long getEndTime()
    • setRootContext

      public void setRootContext(Context context)
      Set the root context of this goal (not the root of the entire tree).
      Parameters:
      context -
    • setCurrentContext

      public void setCurrentContext(Context context)
      Set the current context being executed by an ActionInterpreter.
      Parameters:
      context -
    • getRootContext

      public Context getRootContext()
      Get the root context of this goal (not the root of the entire tree).
      Returns:
    • getCurrentContext

      public Context getCurrentContext()
      Get the current context being executed by an ActionInterpreter.
      Returns:
    • getContextDescription

      public ContextDescription getContextDescription(Predicate location)
    • setAsStarted

      public boolean setAsStarted()
      Set goal status to ACTIVE and set start time. This method does not actually start goal execution.
      Returns:
    • setStatus

      public void setStatus(GoalStatus status)
      Set the status of this goal. Does not directly change the actual execution of this goal.
      Parameters:
      status -
    • setFailureStatus

      public void setFailureStatus(GoalStatus status, Justification failureJustification)
      Alternate method to setStatus, to set failure condition before sending goal status notifications.
      Parameters:
      status -
      failureJustification -
    • setPriority

      public void setPriority(long priority)
    • getPriority

      public long getPriority()
    • setPriorityTier

      public void setPriorityTier(PriorityTier priorityTier)
    • getPriorityTier

      public PriorityTier getPriorityTier()
    • getRequiredResources

      public Set<Resource> getRequiredResources()
      Get the set of resources necessary to be available in order to execute this goal. Note: This set is specific to the subclass of ExecutionManager being used in the system and requires setRequiredResources to be called first (by the ExecutionManager). Will return null if the set of resources has not yet been computed by an ExecutionManager.
    • setRequiredResources

      public void setRequiredResources(Set<Resource> requiredResources)
      Set the set of resources which must be available for this goal during execution. This method should only be called by the Execution Manager on submission.
    • getHeldResources

      public Set<Resource> getHeldResources()
      Get the set of resources that will be held by this goal during execution. Note: This set is specific to the subclass of ExecutionManager being used in the system and requires setRequiredResources to be called first (by the ExecutionManager). Will return null if the set of resources has not yet been computed by an ExecutionManager.
    • setHeldResources

      public void setHeldResources(Set<Resource> heldResources)
      Set the set of resources which will be held by this goal during execution. This method should only be called by the Execution Manager on submission.
    • setIsLearningGoal

      public void setIsLearningGoal(boolean isLearningGoal)
      Set indication whether this goal is being used as a part of action learning. This is important for reasoning in the ExecutionManager about whether the goal conflicts with active learning.
    • isLearningGoal

      public boolean isLearningGoal()
      Returns true if this goal was submitted as part of an action learning process
    • cancel

      public void cancel()
      Cancels goal execution (if currently being executed). If being executed, calls cancel on the ActionInterpreter which will set the status of this goal once execution has terminated.
    • suspend

      public void suspend()
      Suspends goal execution (if currently being executed). If being executed, calls suspend on the ActionInterpreter which will set the status of this goal once execution has fully suspended.
    • resume

      public void resume()
      Resumes goal execution (if currently suspended). Calls suspend on the ActionInterpreter which will set the status of this goal once execution has resumed.
    • getActionInterpreter

      public ActionInterpreter getActionInterpreter()
    • setActionInterpreter

      public boolean setActionInterpreter(ActionInterpreter interpreter)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setMetric

      public void setMetric(Predicate metric)
    • getMetric

      public Predicate getMetric()
    • getInfo

      public GoalInfo getInfo()
      Get copy of GoalInfo.
      Returns:
    • addListener

      public void addListener(GoalListener listener)
    • removeListener

      public void removeListener(GoalListener listener)