Package edu.tufts.hrilab.action.state
Class StateMachine
java.lang.Object
edu.tufts.hrilab.action.state.StateMachine
-
Constructor Summary
ConstructorsConstructorDescriptionStateMachine
(State state) Creates a new state machine from an initial stateStateMachine
(StateMachine original) Create a new state machine by branching off of an existing state machine.StateMachine
(StateMachine originalSM, boolean useBelief) Create a new state machine by branching off of an existing state machine.StateMachine
(String[] beliefArgs) Create a new state machine. -
Method Summary
Modifier and TypeMethodDescriptionvoid
assertBelief
(Predicate fact) Deprecated.void
assertBelief
(Predicate fact, MemoryLevel memoryLevel) Deprecated.void
assertBelief
(Predicate fact, MemoryLevel memoryLevel, Predicate source) void
assertBeliefs
(Collection<Predicate> facts) void
assertRule
(Term head, List<Term> body) static StateMachine
createTestStateMachine
(Set<Predicate> initFacts) USE FOR TESTS ONLY.disjunctionHolds
(List<Predicate> predicates) Checks that the disjunction of the listed predicates holdsdisjunctionHolds
(List<Predicate> predicates, List<Predicate> assumption) Checks that the disjunction of the listed predicates holds for a specific assumption.findResultingState
(Context context) findStartingState
(Context context) findStartingState
(Context context, boolean isTerminated) Get all facts from belief.getAllFactsFromBelief
(MemoryLevel memoryLevel) Get all facts from belief from specified memory level.Get current state from StateMachine.Gets a rule from belief whose head matches, without argumentsgetRules()
Get all rules from beliefGets the simulated SM, a standalone instancegetStateChange
(Context context) get how the state changes from the initial state of an action to the completion of an actiongetStateChange
(Context startStep, Context endStep) Checks that the predicate holdsvoid
Pulls all the facts from this instance's belief into its current statevoid
prune
(long historyLength) Prune old states from the state machine.void
retractBelief
(Predicate fact) void
retractBelief
(Predicate fact, MemoryLevel memoryLevel) void
retractRule
(Term head) void
retractRule
(Term head, List<Term> body) void
Updates the simulation state to the given statevoid
Sets the simulated SM to the instance of the SM passed invoid
shutdown()
Update the state based on action effects.Sets the simulated SM's current state to this instance's currrent statevoid
updateState
(Map<Predicate, Boolean> facts)
-
Constructor Details
-
StateMachine
Create a new state machine. This also creates a BeliefComponent and registers it with TRADE. -
StateMachine
Create a new state machine by branching off of an existing state machine. The new StateMachine creates a new BeliefComponent initialled with the state of other's BeliefComponent. The new BeliefComponent is NOT registered with TRADE.- Parameters:
original
- StateMachine to branch off.
-
StateMachine
Create a new state machine by branching off of an existing state machine. If the belief component is not used but the original does, copy all the original's facts to the new state.- Parameters:
originalSM
- State machine to be copied fromuseBelief
- If belief should be used
-
StateMachine
Creates a new state machine from an initial state- Parameters:
state
-
-
-
Method Details
-
createTestStateMachine
USE FOR TESTS ONLY. Create a new state machine with an initial set of facts for unit tests.- Parameters:
initFacts
- initial set of facts
-
mergeBelief
public void mergeBelief()Pulls all the facts from this instance's belief into its current state -
simulatedStateMachine
-
setSimulationState
Updates the simulation state to the given state- Parameters:
s
- State to update the simulated SM to
-
setSimulationStateMachine
Sets the simulated SM to the instance of the SM passed in- Parameters:
simSM
-
-
getSimulationStateMachine
Gets the simulated SM, a standalone instance- Returns:
- Simulated SM
-
updateSimStateMachine
Sets the simulated SM's current state to this instance's currrent state- Returns:
-
update
Update the state based on action effects.- Parameters:
context
- Context for which the update is done- Returns:
- Next/updated state
-
getRules
Get all rules from belief- Returns:
- List of pairs of rule heads and rule bodies
-
getAllFacts
Get all facts from belief.- Returns:
-
getAllFactsFromBelief
Get all facts from belief from specified memory level.- Returns:
-
getCurrentState
Get current state from StateMachine. This does not consult belief.- Returns:
-
holds
Checks that the predicate holds- Parameters:
predicate
- predicate- Returns:
- True if the predicate holds.
-
disjunctionHolds
Checks that the disjunction of the listed predicates holds- Parameters:
predicates
- List of predicates- Returns:
- True if at least one predicate holds (disjunction).
-
disjunctionHolds
Checks that the disjunction of the listed predicates holds for a specific assumption.- Parameters:
predicates
- List of predicates, the disjunction of which has to holdassumption
- List of predicates that are assumed to hold- Returns:
- True if at least one predicate holds (disjunction).
-
assertBeliefs
-
assertBelief
Deprecated. -
assertBelief
Deprecated. -
assertBelief
-
retractBelief
-
retractBelief
-
assertRule
-
retractRule
-
retractRule
-
getRule
Gets a rule from belief whose head matches, without arguments- Parameters:
name
- Head, without arguments- Returns:
-
prune
public void prune(long historyLength) Prune old states from the state machine.- Parameters:
historyLength
- ms of history to keep
-
shutdown
public void shutdown() -
updateState
-
getStateChange
-
getStateChange
get how the state changes from the initial state of an action to the completion of an action- Parameters:
context
- action to get state change- Returns:
- set of predicates representing the resulting state the initial state
-
findStartingState
-
findStartingState
-
findResultingState
-