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, variableFields 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 TypeMethodDescriptionbooleanacquireLocks(ActionInterpreter actionInt, boolean greedy) Acquire all locks registered for this actionprotected doubleGet affective evaluation of actiondeep copy of the context, its status, and its childrenvoiddoStep()Executes the action corresponding to this context.protected doublegetAffect(boolean positive) Get affect statedoublegetConditionObserver(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.doublegetCost()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.doubledoubleGet 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).booleanisAction()booleanisScript()Check if action is script.protected voidA method to perform additional steps during ActionStatus updates (i.e., setStatus).voidreleaseLocks(ActionInterpreter actionInt) Release all locks registered for this actionprotected voidThis resets fields specific to concrete sub-classes and should be overridden by inheriting classes if additional resetting needs to happen.protected voidprotected voidvoidsetStatus(ActionStatus eStatus, Justification justification) This is overridden to handle interpretable actions.protected voidprotected voidIf Context can have next steps (i.e., children), implement this method to add the next child context that should be executed.protected voidContinuously checks that the overall conditions are met.protected voidupdateAffect(double inc, boolean positive) Update affect stateprotected voidprotected JustificationApplies 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, setupArgumentsMethods inherited from class edu.tufts.hrilab.action.execution.ArgumentBasedContext
addArgument, addArgument, bindPredicate, bindText, copyArguments, getArgument, getArguments, getArgumentSilent, getArgumentType, getArgumentValue, getEvaluatedArgument, getLocalArgument, hasArgumentInScope, hasLocalArgument, redistributeArguments, setArgumentMethods 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:
acquireLocksin 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:
releaseLocksin 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:
getStateUpdatesin 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:
isApprovedin classContext
-
startOverAllMonitor
protected void startOverAllMonitor()Continuously checks that the overall conditions are met. Calls the Context exit() method on failure.- Overrides:
startOverAllMonitorin classContext
-
performAdditionalStatusUpdates
protected void performAdditionalStatusUpdates()Description copied from class:ContextA 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:
performAdditionalStatusUpdatesin classContext
-
setTimeout
protected void setTimeout()- Overrides:
setTimeoutin classContext
-
isAction
public boolean isAction() -
getContextDescription
Description copied from class:ContextGet 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:
getContextDescriptionin classContext- Returns:
-
getContextDescription
Description copied from class:ContextGet 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:
getContextDescriptionin 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:ContextIf Context can have next steps (i.e., children), implement this method to add the next child context that should be executed.- Overrides:
setupNextStepin classContext
-
verifyEffects
Applies the effects of this context according to the execution state. Observes them if necessary.- Overrides:
verifyEffectsin classContext- Returns:
- returns justification for verified effects. always true if no effects are observed.
-
updatePerformanceModels
protected void updatePerformanceModels()- Overrides:
updatePerformanceModelsin classContext
-
verifyReturnValue
Description copied from class:ContextVerify that the return value (if any) of a context is valid.- Overrides:
verifyReturnValuein classContext- Returns:
-
resetConcreteContext
protected void resetConcreteContext()Description copied from class:ContextThis resets fields specific to concrete sub-classes and should be overridden by inheriting classes if additional resetting needs to happen.- Overrides:
resetConcreteContextin 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:Contextdeep copy of the context, its status, and its children -
setStartTime
protected void setStartTime()- Overrides:
setStartTimein classContext
-
setStatus
This is overridden to handle interpretable actions.
-