Class ActionDBEntry

java.lang.Object
edu.tufts.hrilab.action.db.DBEntry
edu.tufts.hrilab.action.db.ActionDBEntry
All Implemented Interfaces:
Serializable

public class ActionDBEntry extends DBEntry
An ActionDBEntry is the general-purpose container for one unit of knowledge; can be factual (e.g., "person") or procedural (e.g., "goHome").
See Also:
  • Constructor Details

  • Method Details

    • isPrimitive

      public boolean isPrimitive()
      Check if action is a primitive action (i.e., has a TRADEServiceInfo).
      Returns:
    • isScript

      public boolean isScript()
      Check if action is an action script (i.e., does not have a TRADEServiceInfo).
      Returns:
    • getServiceInfo

      public ai.thinkingrobots.trade.TRADEServiceInfo getServiceInfo()
      Get the TRADEServiceInfo of the method implementing this action in TRADE. This will be null for non-primitive actions (i.e., action scripts).
      Returns:
      the TRADEServiceInfo
    • getPreConditions

      public List<Condition> getPreConditions()
      Get all the conditions that must be true before the action can begin.
      Returns:
      An unmodifiable list of pre conditions
    • getOverallConditions

      public List<Condition> getOverallConditions()
      Get all the conditions that must be true before and during the action.
      Returns:
      An unmodifiable list of overAllConditions
    • getObligationConditions

      public List<Condition> getObligationConditions()
      Get all the conditions that must be true before and during the action.
      Returns:
      An unmodifiable list of overAllConditions
    • getConditions

      public List<Condition> getConditions()
      Get all the Conditions for this action.
      Returns:
      An unmodifiable copy of the list of conditions. The returned list is unmodifiable to require all manipulations of the list to be done through the containing ActionDBEntry.
    • getPostConditions

      public List<Effect> getPostConditions()
      Get the postconditions for the current action. The postconditions are the intended effects.
      Returns:
      a list of the postconditions
    • isObserver

      public boolean isObserver()
      Check if this action is an observer.
      Returns:
    • getObservations

      public List<Predicate> getObservations()
      Get the observations carried out by the action. TODO: move to new subclass
      Returns:
      a list of the observations in Predicate form
    • isRecoveryPolicy

      public boolean isRecoveryPolicy()
      Check if this action is a recovery policy.
      Returns:
    • getPolicyConstraints

      public List<PolicyConstraints> getPolicyConstraints()
      Get recovery policy constraints (i.e., constraining when a policy can be used). TODO: move to new subclass
      Returns:
      shallow copy of the policy constraints
    • getCost

      public double getCost()
      Get the cost
      Returns:
      the action's (nominal) cost
    • getBenefit

      public double getBenefit()
      Get the benefit
      Returns:
      the action's (nominal) benefit
    • getAffect

      public double getAffect(boolean positive)
      Get affect state
      Parameters:
      positive - boolean indicating whether to add positive affect
      Returns:
      the requested affect state value
    • getAffectEval

      public double getAffectEval()
      Get affective evaluation of action
      Returns:
      the evaluation
    • getMaxUrg

      public double getMaxUrg()
      Get the maxUrg
      Returns:
      the action's maxUrg
    • getMinUrg

      public double getMinUrg()
      Get the minUrg
      Returns:
      the action's minUrg
    • getTimeout

      public long getTimeout()
      Get the timeout
      Returns:
      the action's (nominal) timeout
    • hasTimeout

      public boolean hasTimeout()
    • getResourceLockNames

      public List<String> getResourceLockNames()
      Get the names of all resource locks. Useful mainly for writing to XML.
      Returns:
      list of all resource lock names
    • acquireResourceLocks

      public List<ActionResourceLock> acquireResourceLocks(ActionInterpreter actionInt, boolean greedy) throws ResourceUnavailableException
      Acquire all locks registered for this action
      Parameters:
      actionInt - The AI that needs the lock
      greedy - If true then hold whatever locks can be acquired
      Returns:
      the list of resources acquired
      Throws:
      ResourceUnavailableException
    • getEventSpec

      public EventSpec getEventSpec(String enames, String start, String end, int pos)
      Get the next script event specification from a script that matches.
      Parameters:
      enames - a list of event names to search for (e.g., for else, elseif)
      start - the opening name of a potentially nested statement (e.g., if, while)
      end - the closing name of a potentially nested statement (e.g., endif, endwhile)
      pos - the starting point in the list of events to begin searching
      Returns:
      the spec of the next event, or null if there is none (an event specification includes the name of the action to be executed and its parameters). EventSpec is immutable so returning reference to one is okay.
    • getEventSpec

      public EventSpec getEventSpec(String enames, int pos)
      Get the next script event specification from a script that matches
      Parameters:
      enames - a list of event names to search for (e.g., for else, elseif)
      pos - the starting point in the list of events to begin searching
      Returns:
      the spec of the next event, or null if there is none (an event specification includes the name of the action to be executed and its parameters). EventSpec is immutable so returning reference to one is okay.
    • getEventSpec

      public EventSpec getEventSpec(int pos)
      Get the next script event specification from a script
      Parameters:
      pos - the starting point in the list of events to begin searching
      Returns:
      the spec of the next event, or null if there is none (an event specification includes the name of the action to be executed and its parameters). EventSpec is immutable so returning reference to one is okay.
    • getEventSpecs

      public List<EventSpec> getEventSpecs()
      Get the list of event specifications for the script.
      Returns:
      An unmodifiable copy of the list of events. The returned list is unmodifiable to require all manipulations of the list to be done through the containing ActionDBEntry.
    • getEffects

      public List<Effect> getEffects()
      Get all the effects for this action.
      Returns:
      An unmodifiable copy of the list of effects. The returned list is unmodifiable to require all manipulations of the list to be done through the containing ActionDBEntry.
    • getEffects

      public List<Effect> getEffects(ActionStatus status)
      Called when the action completes and creates a list of the effects based on the status of the action.
      Parameters:
      status - The status of the action determines which additional effects are returned. If ActionStatus.SUCCESS then the successEffects are included. If ActionStatus.FAIL then the failureEffects are included. If ActionStatus.CANCEL then the nonperformanceEffects are included.
      Returns:
      All of the effects of this action based on the provided status of the action.
    • getAgents

      public List<Symbol> getAgents()
      Get the list of agents that can perform this action.
      Returns:
      agents that can perform this action
    • getDBFile

      public String getDBFile()
      Returns the file this script was parsed from.
      Returns:
      file this script was parsed from.
    • conflictsWith

      public boolean conflictsWith(ActionDBEntry other)
      Checks if this ActionDBEntry conflicts with another ActionDBEntry.
      Parameters:
      other -
      Returns:
      true if this ActionDBEntry conflicts with other.
    • toString

      public String toString()
      Overrides:
      toString in class DBEntry
    • getSignature

      public Predicate getSignature(boolean includeActor)
      Get action signature in predicate form, ignoring ?actor arg, optional arguments, and return arguments (if any).
      Returns:
    • getSignatureOptions

      public List<Predicate> getSignatureOptions(boolean includeActor)
      Get all the possible action signatures in predicate form with optional argument permutations, ignoring actor and return args
      Returns:
    • executeAction

      public Justification executeAction(Collection<ActionBinding> args)
      Execute the primitive action.
      Parameters:
      args -
      Returns:
    • hasOnCancelEvent

      public boolean hasOnCancelEvent()
      If action has an onCancel EventSpec defined.
      Returns:
    • hasOnSuspendEvent

      public boolean hasOnSuspendEvent()
      If action has an onSuspend EventSpec defined.
      Returns:
    • hasOnResumeEvent

      public boolean hasOnResumeEvent()
      If action has an onResume EventSpec defined.
      Returns:
    • getOnCancelEvent

      public EventSpec getOnCancelEvent()
    • getOnSuspendEvent

      public EventSpec getOnSuspendEvent()
    • getOnResumeEvent

      public EventSpec getOnResumeEvent()
    • getTranslationInfo

      public TranslationInfo getTranslationInfo()
      TODO: Add docs
      Returns:
    • applySemanticTypes

      public Term applySemanticTypes(Term term)
      Attempts to apply the semantic type information from the roles of this ActionDBEntry to the input term.

      NOTE: it's possible that the returned predicate is still not fully typed if the roles aren't all typed

      Parameters:
      term -
      Returns:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object