Package edu.tufts.hrilab.action.db
Class ActionDBEntry
java.lang.Object
edu.tufts.hrilab.action.db.DBEntry
edu.tufts.hrilab.action.db.ActionDBEntry
- All Implemented Interfaces:
Serializable
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:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class edu.tufts.hrilab.action.db.DBEntry
description, isVarArgs, roles, type
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacquireResourceLocks
(ActionInterpreter actionInt, boolean greedy) Acquire all locks registered for this actionapplySemanticTypes
(Term term) Attempts to apply the semantic type information from the roles of this ActionDBEntry to the input term.boolean
conflictsWith
(ActionDBEntry other) Checks if this ActionDBEntry conflicts with another ActionDBEntry.boolean
executeAction
(Collection<ActionBinding> args) Execute the primitive action.double
getAffect
(boolean positive) Get affect statedouble
Get affective evaluation of actionGet the list of agents that can perform this action.double
Get the benefitGet all the Conditions for this action.double
getCost()
Get the costReturns the file this script was parsed from.Get all the effects for this action.getEffects
(ActionStatus status) Called when the action completes and creates a list of the effects based on the status of the action.getEventSpec
(int pos) Get the next script event specification from a scriptgetEventSpec
(String enames, int pos) Get the next script event specification from a script that matchesgetEventSpec
(String enames, String start, String end, int pos) Get the next script event specification from a script that matches.Get the list of event specifications for the script.double
Get the maxUrgdouble
Get the minUrgGet all the conditions that must be true before and during the action.Get the observations carried out by the action.Get all the conditions that must be true before and during the action.Get recovery policy constraints (i.e., constraining when a policy can be used).Get the postconditions for the current action.Get all the conditions that must be true before the action can begin.Get the names of all resource locks.ai.thinkingrobots.trade.TRADEServiceInfo
Get the TRADEServiceInfo of the method implementing this action in TRADE.getSignature
(boolean includeActor) Get action signature in predicate form, ignoring ?actor arg, optional arguments, and return arguments (if any).getSignatureOptions
(boolean includeActor) Get all the possible action signatures in predicate form with optional argument permutations, ignoring actor and return argslong
Get the timeoutTODO: Add docsint
hashCode()
boolean
If action has an onCancel EventSpec defined.boolean
If action has an onResume EventSpec defined.boolean
If action has an onSuspend EventSpec defined.boolean
boolean
Check if this action is an observer.boolean
Check if action is a primitive action (i.e., has a TRADEServiceInfo).boolean
Check if this action is a recovery policy.boolean
isScript()
Check if action is an action script (i.e., does not have a TRADEServiceInfo).toString()
Methods inherited from class edu.tufts.hrilab.action.db.DBEntry
conflictsWith, getDescription, getInputRoles, getInputRolesTypes, getLocalRoles, getName, getNumRoles, getOptionalInputRoles, getOptionalInputRolesTypes, getRequiredInputRoles, getRequiredInputRolesTypes, getReturnRoles, getReturnRolesTypes, getRole, getRoleDefault, getRoleIsVarArg, getRoleJavaType, getRoleLocal, getRoleName, getRoleReturn, getRoles, getRoleSemanticType, getType, isVarArgs
-
Constructor Details
-
ActionDBEntry
-
-
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
Get all the conditions that must be true before the action can begin.- Returns:
- An unmodifiable list of pre conditions
-
getOverallConditions
Get all the conditions that must be true before and during the action.- Returns:
- An unmodifiable list of overAllConditions
-
getObligationConditions
Get all the conditions that must be true before and during the action.- Returns:
- An unmodifiable list of overAllConditions
-
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
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
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
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
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 lockgreedy
- If true then hold whatever locks can be acquired- Returns:
- the list of resources acquired
- Throws:
ResourceUnavailableException
-
getEventSpec
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
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
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
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
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
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. IfActionStatus.SUCCESS
then the successEffects are included. IfActionStatus.FAIL
then the failureEffects are included. IfActionStatus.CANCEL
then the nonperformanceEffects are included.- Returns:
- All of the effects of this action based on the provided status of the action.
-
getAgents
Get the list of agents that can perform this action.- Returns:
- agents that can perform this action
-
getDBFile
Returns the file this script was parsed from.- Returns:
- file this script was parsed from.
-
conflictsWith
Checks if this ActionDBEntry conflicts with another ActionDBEntry.- Parameters:
other
-- Returns:
- true if this ActionDBEntry conflicts with other.
-
toString
-
getSignature
Get action signature in predicate form, ignoring ?actor arg, optional arguments, and return arguments (if any).- Returns:
-
getSignatureOptions
Get all the possible action signatures in predicate form with optional argument permutations, ignoring actor and return args- Returns:
-
executeAction
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
-
getOnSuspendEvent
-
getOnResumeEvent
-
getTranslationInfo
TODO: Add docs- Returns:
-
applySemanticTypes
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
-
hashCode
public int hashCode()
-