public class TabularBeliefState extends java.lang.Object implements BeliefState, EnumerableBeliefState, DenseBeliefVector
StateEnumerator and this class uses a Map
to associated the probability mass with each state. MDP states that have zero mass are not stored in the map.
SADomain that has
one ObjectClass named belief, that has one double array attribute named belief. When
An OO-MDP state representation is request, an MutableObjectInstance belonging to class
belief is created with its belief attribute set to the dense (non-sparse) belief vector that this BeliefState represents.
TabularBeliefState,
it is recommended that you use HashableTabularBeliefStateFactory
which will compute hash codes and perform state equality checks with the sparse Map representation
(rather than the dense OO-MDP representation)EnumerableBeliefState.StateBelief| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BELIEFATTNAME |
static java.lang.String |
BELIEFCLASSNAME |
protected java.util.Map<java.lang.Integer,java.lang.Double> |
beliefValues
The belief vector, stored sparsely with a
Map. |
protected PODomain |
domain
The POMDP domain with which this belief state is associated.
|
protected StateEnumerator |
stateEnumerator
A state enumerator for determining the index of MDP states in the belief vector.
|
| Constructor and Description |
|---|
TabularBeliefState(PODomain domain) |
TabularBeliefState(PODomain domain,
StateEnumerator stateEnumerator)
Constructs a new
TabularBeliefState. |
TabularBeliefState(TabularBeliefState srcBeliefState)
Constructs a new
TabularBeliefState from a source
TabularBeliefState. |
| Modifier and Type | Method and Description |
|---|---|
State |
addAllObjects(java.util.Collection<ObjectInstance> objects)
Adds the collection of objects to the state
|
State |
addObject(ObjectInstance o)
Adds object instance o to this state.
|
double |
belief(int stateId)
Returns the value of the belief vector for the provided index.
|
double |
belief(State s)
Returns the probability density/mass for the input MDP state.
|
State |
copy()
Returns a copy of this state, if mutable the copy should be deep.
|
boolean |
equals(java.lang.Object obj) |
java.util.List<ObjectInstance> |
getAllObjects()
Returns the list of observable and hidden object instances in this state.
|
java.util.List<java.util.List<ObjectInstance>> |
getAllObjectsByClass()
Returns a list of list of object instances, grouped by object class
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getAllUnsetAttributes()
Returns a mapping from object instance names to the list of attributes names that have unset values.
|
double[] |
getBeliefVector()
Returns this belief state as a dense (non-sparse) belief vector.
|
java.lang.String |
getCompleteStateDescription()
Returns a string representation of this state using observable and hidden object instances.
|
java.lang.String |
getCompleteStateDescriptionWithUnsetAttributesAsNull()
Returns a string description of the state with unset attribute values listed as null.
|
ObjectInstance |
getFirstObjectOfClass(java.lang.String oclass)
Returns the first indexed object of the object class named oclass
|
ObjectInstance |
getObject(java.lang.String oname)
Returns the object in this state with the name oname
|
java.util.Set<java.lang.String> |
getObjectClassesPresent()
Returns a set of of the object class names for all object classes that have instantiated objects in this state.
|
java.util.Map<java.lang.String,java.lang.String> |
getObjectMatchingTo(State so,
boolean enforceStateExactness)
This method computes a matching from objects in the receiver to value-identical objects in the parameter state so.
|
java.util.List<ObjectInstance> |
getObjectsOfClass(java.lang.String oclass)
Returns all objects that belong to the object class named oclass
|
java.util.List<java.util.List<java.lang.String>> |
getPossibleBindingsGivenParamOrderGroups(java.lang.String[] paramClasses,
java.lang.String[] paramOrderGroups)
Given an array of parameter object classes and an array of their corresponding parameter order groups,
returns all possible object instance bindings to the parameters, excluding bindings that are equivalent due
to the parameter order grouping.
|
java.util.List<EnumerableBeliefState.StateBelief> |
getStatesAndBeliefsWithNonZeroProbability()
Returns the states, and their probability mass, that have non-zero probability mass.
|
java.util.List<State> |
getStateSpace()
Returns the set of underlying MDP states this belief vector spans.
|
static SADomain |
getTabularBeliefMDPDomain() |
protected double |
getTransitionProb(State s,
GroundedAction ga,
State sp)
Returns the probability that the underlying MDP will transition from state s to sp when taking action a in state s.
|
BeliefState |
getUpdatedBeliefState(State observation,
GroundedAction ga)
Computes a new belief distribution using this BeliefState as the prior and conditioned on the given POMDP observation
and action taken.
|
void |
initializeAllBeliefValuesTo(double initialValue)
Initializes the probability mass of all underlying MDP states to the specified value.
|
void |
initializeBeliefsUniformly()
Initializes this belief state to a uniform distribution
|
int |
numStates()
Returns the size of the observed underlying MDP state space.
|
int |
numTotalObjects()
Returns the number of object instances in this state.
|
State |
removeAllObjects(java.util.Collection<ObjectInstance> objects)
Removes the collection of objects from the state
|
State |
removeObject(ObjectInstance o)
Removes the object instance o from this state.
|
State |
removeObject(java.lang.String oname)
Removes the object instance with the name oname from this state.
|
State |
renameObject(ObjectInstance o,
java.lang.String newName)
Renames the identifier for object instance o in this state to newName.
|
State |
renameObject(java.lang.String originalName,
java.lang.String newName)
Renames the identifier for the object instance currently named originalName with the name newName.
|
State |
sampleStateFromBelief()
Samples an MDP state state from this belief distribution.
|
void |
setBelief(int stateId,
double b)
Sets the probability mass (belief) associated with the underlying MDP state.
|
void |
setBelief(State s,
double b)
Sets the probability mass (belief) associated with the underlying MDP state.
|
void |
setBeliefVector(double[] b)
Sets this belief state to the provided.
|
<T> State |
setObjectsValue(java.lang.String objectName,
java.lang.String attName,
T value) |
State |
stateForId(int id)
Returns the corresponding MDP state for the provided unique identifier.
|
void |
zeroOutBeliefVector()
Sets this belief state to have zero probability mass for all underlying MDP states.
|
public static final java.lang.String BELIEFCLASSNAME
public static final java.lang.String BELIEFATTNAME
protected StateEnumerator stateEnumerator
protected java.util.Map<java.lang.Integer,java.lang.Double> beliefValues
Map.protected PODomain domain
ObservationFunction necessary to perform
belief state updates.public TabularBeliefState(TabularBeliefState srcBeliefState)
TabularBeliefState from a source
TabularBeliefState. Changes to the new state or source
state will not affect the other.srcBeliefState - the source TabularBeliefState to copy.public TabularBeliefState(PODomain domain)
public TabularBeliefState(PODomain domain, StateEnumerator stateEnumerator)
TabularBeliefState.domain - the PODomain domain to which the belief state is associated.stateEnumerator - a StateEnumerator to index the states in the belief vector.public static SADomain getTabularBeliefMDPDomain()
public double belief(State s)
BeliefStatebelief in interface BeliefStates - the the input MDP state defined by a State instance.public double belief(int stateId)
stateId - the index (state identification number) of the belief vector to return.public State sampleStateFromBelief()
BeliefStatesampleStateFromBelief in interface BeliefStateState instance.public BeliefState getUpdatedBeliefState(State observation, GroundedAction ga)
BeliefStategetUpdatedBeliefState in interface BeliefStateobservation - the conditioned POMDP observation defined by a State instance.ga - the conditioned action selection in the previous time step.BeliefState instance.public java.util.List<EnumerableBeliefState.StateBelief> getStatesAndBeliefsWithNonZeroProbability()
EnumerableBeliefStategetStatesAndBeliefsWithNonZeroProbability in interface EnumerableBeliefStateList of EnumerableBeliefState.StateBelief objects specifying the enumerated probability mass function.public int numStates()
public State stateForId(int id)
id - the MDP state identifierState, for the provided unique identifier.public void setBelief(State s, double b)
s - the underlying MDP state defined as a Stateb - the probability mass to assigned to the underlying MDP state.public void setBelief(int stateId,
double b)
stateId - the unique numeric identifier of the underlying MDP state defined.b - the probability mass to assigned to the underlying MDP state.protected double getTransitionProb(State s, GroundedAction ga, State sp)
s - the previous MDP state defined by a Statega - the taken action defined by a GroundedActionsp - The next MDP state observed defined by a State.public void setBeliefVector(double[] b)
setBeliefVector in interface DenseBeliefVectorb - the belief vector to set this belief state to.public double[] getBeliefVector()
getBeliefVector in interface DenseBeliefVectorpublic java.util.List<State> getStateSpace()
public void zeroOutBeliefVector()
public void initializeBeliefsUniformly()
public void initializeAllBeliefValuesTo(double initialValue)
initialValue - the probability mass to assign to each state.public State copy()
Statepublic State addObject(ObjectInstance o)
Statepublic State addAllObjects(java.util.Collection<ObjectInstance> objects)
StateaddAllObjects in interface Statepublic State removeObject(java.lang.String oname)
StateremoveObject in interface Stateoname - the name of the object instance to remove.public State removeObject(ObjectInstance o)
StateremoveObject in interface Stateo - the object instance to remove from this state.public State removeAllObjects(java.util.Collection<ObjectInstance> objects)
StateremoveAllObjects in interface Statepublic State renameObject(java.lang.String originalName, java.lang.String newName)
StaterenameObject in interface StateoriginalName - the original name of the object instance to be renamed in this statenewName - the new name of the object instancepublic State renameObject(ObjectInstance o, java.lang.String newName)
StaterenameObject in interface Stateo - the object instance to rename in this statenewName - the new name of the object instancepublic java.util.Map<java.lang.String,java.lang.String> getObjectMatchingTo(State so, boolean enforceStateExactness)
StategetObjectMatchingTo in interface Stateso - the state to whose objects the receiving state's objects should be matchedenforceStateExactness - whether to require that states are identical to return a matchingpublic int numTotalObjects()
StatenumTotalObjects in interface Statepublic ObjectInstance getObject(java.lang.String oname)
Statepublic java.util.List<ObjectInstance> getAllObjects()
StategetAllObjects in interface Statepublic java.util.List<ObjectInstance> getObjectsOfClass(java.lang.String oclass)
StategetObjectsOfClass in interface Stateoclass - the name of the object class for which objects should be returnedpublic ObjectInstance getFirstObjectOfClass(java.lang.String oclass)
StategetFirstObjectOfClass in interface Stateoclass - the name of the object class for which the first indexed object should be returned.public java.util.Set<java.lang.String> getObjectClassesPresent()
StategetObjectClassesPresent in interface Statepublic java.util.List<java.util.List<ObjectInstance>> getAllObjectsByClass()
StategetAllObjectsByClass in interface Statepublic java.lang.String getCompleteStateDescription()
StategetCompleteStateDescription in interface Statepublic java.util.Map<java.lang.String,java.util.List<java.lang.String>> getAllUnsetAttributes()
StategetAllUnsetAttributes in interface Statepublic java.lang.String getCompleteStateDescriptionWithUnsetAttributesAsNull()
StategetCompleteStateDescriptionWithUnsetAttributesAsNull in interface Statepublic java.util.List<java.util.List<java.lang.String>> getPossibleBindingsGivenParamOrderGroups(java.lang.String[] paramClasses,
java.lang.String[] paramOrderGroups)
StategetPossibleBindingsGivenParamOrderGroups in interface StateparamClasses - the name of object classes to which the bound object instances must belongparamOrderGroups - the parameter order group names.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic <T> State setObjectsValue(java.lang.String objectName, java.lang.String attName, T value)
setObjectsValue in interface State