Class ActionContext
java.lang.Object
edu.tufts.hrilab.action.execution.Context
edu.tufts.hrilab.action.execution.ArgumentBasedContext
edu.tufts.hrilab.action.execution.DatabaseEntryContext<ActionDBEntry>
edu.tufts.hrilab.action.execution.ActionContext
- Direct Known Subclasses:
NormCheckingActionContext
-
Field Summary
Fields inherited from class edu.tufts.hrilab.action.execution.ArgumentBasedContext
arguments, variable
Fields inherited from class edu.tufts.hrilab.action.execution.Context
caller, childContexts, cmd, constraints, endTime, log, maxTime, startTime, stateMachine
-
Constructor Summary
ConstructorsConstructorDescriptionActionContext
(Context caller, StateMachine sm, ActionDBEntry action, List<? extends Object> inputArgs, List<? extends Object> returnArgs, Symbol actor) ActionContext
(Context caller, StateMachine sm, ActionDBEntry action, Map<String, Object> bindings, ExecutionType executionType, Symbol actor) -
Method Summary
Modifier and TypeMethodDescriptionboolean
acquireLocks
(ActionInterpreter actionInt, boolean greedy) Acquire all locks registered for this actionprotected double
Get affective evaluation of actiondeep copy of the context, its status, and its childrenvoid
doStep()
Executes the action corresponding to this context.protected double
getAffect
(boolean positive) Get affect statedouble
getConditionObserver
(Condition condition, Predicate predicate) Look up cached ObservationContext or attempt to create a new one for an Condition.Get the ContextDescription for this Context.getContextDescription
(Predicate location) Get the ContextDescription for this context tree based on the location predicate.double
getCost()
getEffectObserver
(Effect effect) Look up cached ObservationContext or attempt to create a new one for an Effect.Get the list of effects from the ActionDBEntry, bind variables, and return it all.getEffects
(ActionStatus status) Get the list of effects (filtered by ActionStatus) from the ActionDBEntry, bind variables, and return it all.double
double
Get the list of obligation conditions from the ActionDBEntry, bind variables and return it all.Get the list of overall conditions from the ActionDBEntry, bind variables and return it all.Get the list of preconditions from the ActionDBEntry, bind variables, and return it all.Get state updates for this context based on the current status (i.e., ActionStatus).void
handleInterrupt
(ActionStatus eStatus) boolean
isAction()
boolean
isScript()
Check if action is script.protected void
A method to perform additional steps during ActionStatus updates (i.e., setStatus).void
releaseLocks
(ActionInterpreter actionInt) Release all locks registered for this actionprotected void
This resets fields specific to concrete sub-classes and should be overridden by inheriting classes if additional resetting needs to happen.protected void
protected void
void
setStatus
(ActionStatus eStatus, Justification justification) This is overridden to handle interpretable actions.protected void
protected void
If Context can have next steps (i.e., children), implement this method to add the next child context that should be executed.protected void
Continuously checks that the overall conditions are met.protected void
updateAffect
(double inc, boolean positive) Update affect stateprotected void
protected Justification
Applies the effects of this context according to the execution state.Verify that the return value (if any) of a context is valid.Methods inherited from class edu.tufts.hrilab.action.execution.DatabaseEntryContext
addArgument, addVarArgArgument, collectArguments, getDBE, getSignatureInPredicateForm, setArgument, setDBE, setupArguments, setupArguments
Methods inherited from class edu.tufts.hrilab.action.execution.ArgumentBasedContext
addArgument, addArgument, bindPredicate, bindText, copyArguments, getArgument, getArguments, getArgumentSilent, getArgumentType, getArgumentValue, getEvaluatedArgument, getLocalArgument, hasArgumentInScope, hasLocalArgument, redistributeArguments, setArgument
Methods inherited from class edu.tufts.hrilab.action.execution.Context
addEvent, addEvent, addEvent, causedFailure, copyInternal, createSimulatedEquivalent, getActor, getActualLogicalValue, getChildContexts, getCommand, getConstraints, getDuration, getElapsedTime, getEndTime, getEquivalentContext, getExecType, getId, getJustification, getLogicalValue, getMaxTime, getNearestTerminatedAncestor, getNextStep, getNextStepForType, getParentContext, getRootContext, getStartTime, getStateMachine, getStatus, hasNormCheckingAncestor, isAsynchronous, isFailure, isSimulation, isSuccess, isTerminated, resetContext, resetCoreContext, setChildContexts, setConstraints, setEndTime, setExecType, setLogicalValue, setStartTime, setStateMachine, setStatus, setupNextStep, toString, waitForTermination, waitForTermination
-
Constructor Details
-
ActionContext
public ActionContext(Context caller, StateMachine sm, ActionDBEntry action, List<? extends Object> inputArgs, List<? extends Object> returnArgs, Symbol actor) - Parameters:
caller
-sm
-action
-inputArgs
-returnArgs
-actor
-
-
ActionContext
public ActionContext(Context caller, StateMachine sm, ActionDBEntry action, Map<String, Object> bindings, ExecutionType executionType, Symbol actor) - Parameters:
caller
-sm
-action
-bindings
-executionType
-actor
-
-
-
Method Details
-
acquireLocks
Acquire all locks registered for this action- Overrides:
acquireLocks
in classContext
- Parameters:
actionInt
- The AI that needs the lockgreedy
- if not greedy, then release the locks if all can't be acquired- Returns:
- true is all locks acquired, false otherwise
-
releaseLocks
Release all locks registered for this action- Overrides:
releaseLocks
in classContext
- Parameters:
actionInt
- The AI that needs the lock
-
getCost
public double getCost() -
getBenefit
public double getBenefit() -
getMinUrgency
public double getMinUrgency() -
getMaxUrgency
public double getMaxUrgency() -
getStateUpdates
Get state updates for this context based on the current status (i.e., ActionStatus). This excludes any effects that were verified via an observation, as observations are actions that automatically update Belief state.- Overrides:
getStateUpdates
in classContext
- Returns:
-
getEffects
Get the list of effects (filtered by ActionStatus) from the ActionDBEntry, bind variables, and return it all.- Parameters:
status
-- Returns:
-
getEffects
Get the list of effects from the ActionDBEntry, bind variables, and return it all.- Returns:
-
getPreConditions
Get the list of preconditions from the ActionDBEntry, bind variables, and return it all.- Returns:
- List of conditions that have been bound using this context
-
getOverAllConditions
Get the list of overall conditions from the ActionDBEntry, bind variables and return it all.- Returns:
- List of conditions that have been bound using this context
-
getObligationConditions
Get the list of obligation conditions from the ActionDBEntry, bind variables and return it all.- Returns:
- List of conditions that have been bound using this context
-
isApproved
- Overrides:
isApproved
in classContext
-
startOverAllMonitor
protected void startOverAllMonitor()Continuously checks that the overall conditions are met. Calls the Context exit() method on failure.- Overrides:
startOverAllMonitor
in classContext
-
performAdditionalStatusUpdates
protected void performAdditionalStatusUpdates()Description copied from class:Context
A method to perform additional steps during ActionStatus updates (i.e., setStatus). If a particular Context sub-class needs this to happen, that class should override this method. NOTE: This method is only called when a select set of ActionStatuses are successfully set.- Overrides:
performAdditionalStatusUpdates
in classContext
-
setTimeout
protected void setTimeout()- Overrides:
setTimeout
in classContext
-
isAction
public boolean isAction() -
getContextDescription
Description copied from class:Context
Get the ContextDescription for this context tree based on the location predicate. This searches down the context tree until some context matches the location predicate and returns a ContextDescription.- Overrides:
getContextDescription
in classContext
- Returns:
-
getContextDescription
Description copied from class:Context
Get the ContextDescription for this Context. TODO: this currently searches down the context tree until some context (e.g., ActionContext) returns a ContextDescription. Eventually, this should probably be abstract, to force every context class to return a ContextDescription.- Overrides:
getContextDescription
in classContext
- Returns:
-
doStep
public void doStep()Executes the action corresponding to this context. If the action is a script, then this step initializes each of the steps in the script. If the action is a primitive, then it executes that action. -
isScript
public boolean isScript()Check if action is script.- Returns:
- true if action is child of script
-
setupNextStep
protected void setupNextStep()Description copied from class:Context
If Context can have next steps (i.e., children), implement this method to add the next child context that should be executed.- Overrides:
setupNextStep
in classContext
-
verifyEffects
Applies the effects of this context according to the execution state. Observes them if necessary.- Overrides:
verifyEffects
in classContext
- Returns:
- returns justification for verified effects. always true if no effects are observed.
-
updatePerformanceModels
protected void updatePerformanceModels()- Overrides:
updatePerformanceModels
in classContext
-
verifyReturnValue
Description copied from class:Context
Verify that the return value (if any) of a context is valid.- Overrides:
verifyReturnValue
in classContext
- Returns:
-
resetConcreteContext
protected void resetConcreteContext()Description copied from class:Context
This resets fields specific to concrete sub-classes and should be overridden by inheriting classes if additional resetting needs to happen.- Overrides:
resetConcreteContext
in classContext
-
getConditionObserver
Look up cached ObservationContext or attempt to create a new one for an Condition. Returns null if an appropriate Observer could not be found in the system.- Parameters:
condition
- Condition (can contain multiple predicates in the case of a disjunction)predicate
- the particular predicate of the Condition- Returns:
-
getEffectObserver
Look up cached ObservationContext or attempt to create a new one for an Effect. Returns null if an appropriate Observer could not be found in the system.- Parameters:
effect
-- Returns:
-
updateAffect
protected void updateAffect(double inc, boolean positive) Update affect state- Parameters:
inc
- the increment value for the updatepositive
- boolean indicating whether to add positive affect
-
getAffect
protected double getAffect(boolean positive) Get affect state- Parameters:
positive
- boolean indicating whether to add positive affect- Returns:
- the requested affect state value
-
affectEval
protected double affectEval()Get affective evaluation of action- Returns:
- the evaluation
-
setExecType
protected void setExecType() -
copy
Description copied from class:Context
deep copy of the context, its status, and its children -
setStartTime
protected void setStartTime()- Overrides:
setStartTime
in classContext
-
handleInterrupt
-
setStatus
This is overridden to handle interpretable actions. -
getTranslation
-