Package edu.tufts.hrilab.action.goal
Class Goal
java.lang.Object
edu.tufts.hrilab.action.goal.Goal
- Direct Known Subclasses:
ScheduledGoal
Goal encapsulates a goal Predicate, the ActionInterpreter in charge of
executing it and some additional information.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstruct goal that defines the actor to achieve the goal, and the desired goal/action.protectedConstruct goal with explicit actor.protectedGoal(Symbol actor, Symbol goalState, Observable observable) Goal constructor used to explicitly mark goal as an observation. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(GoalListener listener) booleanbindPredicate(Context context) Binds goal predicate to values in context.booleancancel()Cancels goal execution (if currently being executed).static GoalcreateGoal(Predicate goalState) This is the standard way to construct a new Goal.static GoalcreateGoal(Symbol actor, Symbol goalState) Convenience factory method for constructing goals from the execution of ASL, or when you don't already have a goal predicate of the form "goal(actor, goalState)".static GoalcreateGoal(Symbol actor, Symbol goalState, Observable observable) Convenience factory method for constructing goals that explicitly mark goal as an observation.getActor()getContextDescription(Predicate location) Get the current context being executed by an ActionInterpreter.longGet the full goal predicate.Get the goal state predicate.Get the set of resources that will be held by this goal during execution.longgetId()getInfo()Get copy of GoalInfo.longGet the set of resources necessary to be available in order to execute this goal.Get the root context of this goal (not the root of the entire tree).intlongbooleanisAction()booleanReturns true if this goal was submitted as part of an action learning processbooleanbooleanbooleanbooleanCheck if this goal predicate matches the given goal predicate.voidremoveListener(GoalListener listener) booleanresume()Resumes goal execution (if currently suspended).booleansetActionInterpreter(ActionInterpreter interpreter) booleanSet goal status to ACTIVE and set start time.voidsetCurrentContext(Context context) Set the current context being executed by an ActionInterpreter.voidsetExecutionType(ExecutionType executionType) voidsetFailureStatus(GoalStatus status, Justification failureJustification) Alternate method to setStatus, to set failure condition before sending goal status notifications.voidsetHeldResources(Set<Resource> heldResources) Set the set of resources which will be held by this goal during execution.voidsetIsAction(boolean value) voidsetIsLearningGoal(boolean isLearningGoal) Set indication whether this goal is being used as a part of action learning.voidvoidsetPriority(long priority) voidsetPriorityTier(PriorityTier priorityTier) voidsetRequiredResources(Set<Resource> requiredResources) Set the set of resources which must be available for this goal during execution.voidsetRootContext(Context context) Set the root context of this goal (not the root of the entire tree).voidsetScheduledState(int scheduledState) voidsetStatus(GoalStatus status) Set the status of this goal.voidsetSubmitter(Symbol submitter) booleansuspend()Suspends goal execution (if currently being executed).toString()
-
Field Details
-
info
-
-
Constructor Details
-
Goal
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:
goalPredicate-
-
Goal
Construct goal with explicit actor. This is primarily used for creating goal instance from ASL- Parameters:
actor-goalState-
-
Goal
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 observinggoalState- the goal stateobservable- enum specifying if goal is observable, and if so what type (true/false/default)
-
-
Method Details
-
createGoal
This is the standard way to construct a new Goal. This will automatically create a ScheduledGoal if the goalState is scheduled(...).- Parameters:
goalState-- Returns:
-
createGoal
Convenience factory method for constructing goals from the execution of ASL, or when you don't already have a goal predicate of the form "goal(actor, goalState)".- Parameters:
actor-goalState-- Returns:
-
createGoal
Convenience factory method for constructing goals that 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 predicateobservable- enum specifying if goal is observable, and if so what type (true/false/default)
-
matches
Check if this goal predicate matches the given goal predicate.- Parameters:
goalPredicate-- Returns:
-
getGoalPredicate
Get the full goal predicate. This is the predicate that was used to create this goal. Examples: goal(self,state) --> goal(self,state) action1(self,args) --> action1(self,args) obs(self,state) --> obs(self,state) If the original goal predicate was unbound, this will return the unbound version.- Returns:
-
getGoalStatePredicate
Get the goal state predicate. This is the state to be achieved, or the action to be executed. Examples: goa(self,state) --> state action1(self,args) --> action1(self,args) obs(self,state) --> state 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
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
-
isPersistent
public boolean isPersistent() -
isScheduled
public boolean isScheduled() -
setScheduledState
public void setScheduledState(int scheduledState) -
getScheduledState
public int getScheduledState() -
getActor
-
getFailConditions
-
getStatus
-
getStartTime
public long getStartTime() -
getEndTime
public long getEndTime() -
setRootContext
Set the root context of this goal (not the root of the entire tree).- Parameters:
context-
-
setCurrentContext
Set the current context being executed by an ActionInterpreter.- Parameters:
context-
-
getRootContext
Get the root context of this goal (not the root of the entire tree).- Returns:
-
getCurrentContext
Get the current context being executed by an ActionInterpreter.- Returns:
-
getContextDescription
-
setAsStarted
public boolean setAsStarted()Set goal status to ACTIVE and set start time. This method does not actually start goal execution.- Returns:
-
setStatus
Set the status of this goal. Does not directly change the actual execution of this goal.- Parameters:
status-
-
setFailureStatus
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
-
getPriorityTier
-
setSubmitter
-
getSubmitter
-
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
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
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
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 boolean 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 boolean 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 boolean 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
-
setActionInterpreter
-
toString
-
setMetric
-
getMetric
-
getInfo
Get copy of GoalInfo.- Returns:
-
addListener
-
removeListener
-
getExecutionType
-
setExecutionType
-