Class ActionContext

Direct Known Subclasses:
NormCheckingActionContext

public class ActionContext extends DatabaseEntryContext<ActionDBEntry>
  • Constructor Details

  • Method Details

    • acquireLocks

      public boolean acquireLocks(ActionInterpreter actionInt, boolean greedy)
      Acquire all locks registered for this action
      Overrides:
      acquireLocks in class Context
      Parameters:
      actionInt - The AI that needs the lock
      greedy - if not greedy, then release the locks if all can't be acquired
      Returns:
      true is all locks acquired, false otherwise
    • releaseLocks

      public void releaseLocks(ActionInterpreter actionInt)
      Release all locks registered for this action
      Overrides:
      releaseLocks in class Context
      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

      public List<Predicate> 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 class Context
      Returns:
    • getEffects

      public List<Effect> getEffects(ActionStatus status)
      Get the list of effects (filtered by ActionStatus) from the ActionDBEntry, bind variables, and return it all.
      Parameters:
      status -
      Returns:
    • getEffects

      public List<Effect> getEffects()
      Get the list of effects from the ActionDBEntry, bind variables, and return it all.
      Returns:
    • getPreConditions

      public List<Condition> 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

      public List<Condition> 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

      public List<Condition> 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

      public Justification isApproved()
      Overrides:
      isApproved in class Context
    • startOverAllMonitor

      protected void startOverAllMonitor()
      Continuously checks that the overall conditions are met. Calls the Context exit() method on failure.
      Overrides:
      startOverAllMonitor in class Context
    • 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 class Context
    • setTimeout

      protected void setTimeout()
      Overrides:
      setTimeout in class Context
    • isAction

      public boolean isAction()
      Overrides:
      isAction in class Context
    • getContextDescription

      public ContextDescription getContextDescription(Predicate location)
      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 class Context
      Returns:
    • getContextDescription

      public ContextDescription 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 class Context
      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.
      Overrides:
      doStep in class Context
    • 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 class Context
    • verifyEffects

      protected Justification verifyEffects()
      Applies the effects of this context according to the execution state. Observes them if necessary.
      Overrides:
      verifyEffects in class Context
      Returns:
      returns justification for verified effects. always true if no effects are observed.
    • updatePerformanceModels

      protected void updatePerformanceModels()
      Overrides:
      updatePerformanceModels in class Context
    • verifyReturnValue

      public Justification verifyReturnValue()
      Description copied from class: Context
      Verify that the return value (if any) of a context is valid.
      Overrides:
      verifyReturnValue in class Context
      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 class Context
    • getConditionObserver

      public ObservationContext getConditionObserver(Condition condition, Predicate predicate)
      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

      public ObservationContext getEffectObserver(Effect effect)
      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 update
      positive - 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

      public ActionContext copy(Context newParent)
      Description copied from class: Context
      deep copy of the context, its status, and its children
      Specified by:
      copy in class Context
      Parameters:
      newParent - parent to attach the copied context too
      Returns:
      the copied context
    • setStartTime

      protected void setStartTime()
      Overrides:
      setStartTime in class Context
    • handleInterrupt

      public void handleInterrupt(ActionStatus eStatus)
    • setStatus

      public void setStatus(ActionStatus eStatus, Justification justification)
      This is overridden to handle interpretable actions.
      Overrides:
      setStatus in class Context
      Parameters:
      eStatus -
      justification -
    • getTranslation

      public TranslationInfo getTranslation()