public class TabularModel extends java.lang.Object implements KWIKModel
Acknowledgements: Takehiro Oyakawa and Chan Trau for code on which this was based.
KWIKModel.Helper| Modifier and Type | Field and Description |
|---|---|
protected HashableStateFactory |
hashingFactory
The hashing factory to use for indexing states
|
protected int |
nConfident
The number of transitions necessary to be confident in a model's prediction.
|
protected SADomain |
sourceDomain
The source actual domain object for which actions will be modeled.
|
protected java.util.Map<HashableState,burlap.behavior.singleagent.learning.modellearning.models.TabularModel.StateNode> |
stateNodes
A mapping from (hashed) states to state nodes that store transition statistics
|
protected java.util.Set<HashableState> |
terminalStates
The set of states marked as terminal states.
|
| Constructor and Description |
|---|
TabularModel(SADomain sourceDomain,
HashableStateFactory hashingFactory,
int nConfident)
Initializes.
|
| Modifier and Type | Method and Description |
|---|---|
protected burlap.behavior.singleagent.learning.modellearning.models.TabularModel.StateActionNode |
getOrCreateActionNode(HashableState sh,
Action ga)
Returns the
TabularModel.StateActionNode object associated with the given hashed state and action. |
protected burlap.behavior.singleagent.learning.modellearning.models.TabularModel.StateActionNode |
getStateActionNode(HashableState sh,
Action a)
Returns the
TabularModel.StateActionNode object associated with the given hashed state and action. |
void |
resetModel()
Resets the model data so that learning can begin anew.
|
EnvironmentOutcome |
sample(State s,
Action a)
Samples a transition from the transition distribution and returns it.
|
boolean |
terminal(State s)
Indicates whether a state is a terminal state (i.e., no more action occurs and zero reward received from there on out)
|
boolean |
transitionIsModeled(State s,
Action ga)
Indicates whether this model "knows" how the transition dynamics from the given input state and action work.
|
java.util.List<TransitionProb> |
transitions(State s,
Action a)
|
void |
updateModel(EnvironmentOutcome eo)
Updates this model with respect to the observed
EnvironmentOutcome. |
protected SADomain sourceDomain
protected HashableStateFactory hashingFactory
protected java.util.Map<HashableState,burlap.behavior.singleagent.learning.modellearning.models.TabularModel.StateNode> stateNodes
protected java.util.Set<HashableState> terminalStates
protected int nConfident
public TabularModel(SADomain sourceDomain, HashableStateFactory hashingFactory, int nConfident)
sourceDomain - the source domain whose actions will be modeled.hashingFactory - the hashing factory to index statesnConfident - the number of observed transitions to be confident in the model's prediction.public boolean transitionIsModeled(State s, Action ga)
KWIKModeltransitionIsModeled in interface KWIKModels - the state that is checkedga - the action to take in state spublic java.util.List<TransitionProb> transitions(State s, Action a)
FullModelAction is applied in State s. The returned
list only needs to include transitions that have non-zero probability of occurring.transitions in interface FullModels - the source Statea - the Action applied in the source statepublic EnvironmentOutcome sample(State s, Action a)
SampleModelsample in interface SampleModels - the source statea - the action taken in the source stateEnvironmentOutcome describing the sampled transitionpublic boolean terminal(State s)
SampleModelterminal in interface SampleModels - the input state to testpublic void updateModel(EnvironmentOutcome eo)
LearnedModelEnvironmentOutcome.updateModel in interface LearnedModeleo - The EnvironmentOutcome specifying the observed interaction with an Environment.protected burlap.behavior.singleagent.learning.modellearning.models.TabularModel.StateActionNode getStateActionNode(HashableState sh, Action a)
TabularModel.StateActionNode object associated with the given hashed state and action.
If there is not an associated TabularModel.StateActionNode object, then null is returned.sh - the hashed statea - the actionTabularModel.StateActionNode or null if it does not exist.protected burlap.behavior.singleagent.learning.modellearning.models.TabularModel.StateActionNode getOrCreateActionNode(HashableState sh, Action ga)
TabularModel.StateActionNode object associated with the given hashed state and action.
If there is not an associated TabularModel.StateActionNode object, then one will be created.sh - the hashed statega - the grounded actionTabularModel.StateActionNodepublic void resetModel()
LearnedModelresetModel in interface LearnedModel