public class TabularBeliefState extends java.lang.Object implements BeliefState, EnumerableBeliefState, DenseBeliefVector, MutableState, HashableState
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.
If using a BeliefMDP solver with a TabularBeliefState
,
it is recommended that you use the ReflectiveHashableStateFactory
, since TabularBeliefState
implements HashableState
and since you probably do not want to do abstraction of the belief state.
EnumerableBeliefState.StateBelief
Modifier and Type | Field and Description |
---|---|
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() |
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 |
---|---|
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.
|
double[] |
beliefVector()
Returns this belief state as a dense (non-sparse) belief vector.
|
State |
copy()
Returns a copy of this state suitable for creating state transitions.
|
boolean |
equals(java.lang.Object obj) |
java.lang.Object |
get(java.lang.Object variableKey)
Returns the value for the given variable key.
|
java.util.Map<java.lang.Integer,java.lang.Double> |
getBeliefValues() |
PODomain |
getDomain() |
StateEnumerator |
getStateEnumerator() |
java.util.List<State> |
getStateSpace()
Returns the set of underlying MDP states this belief vector spans.
|
int |
hashCode() |
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
|
java.util.List<EnumerableBeliefState.StateBelief> |
nonZeroBeliefs()
Returns the states, and their probability mass, that have non-zero probability mass.
|
int |
numStates()
Returns the size of the observed underlying MDP state space.
|
State |
s()
Returns the underlying source state that is hashed.
|
State |
sample()
Samples an MDP state state from this belief distribution.
|
MutableState |
set(java.lang.Object variableKey,
java.lang.Object value)
Sets the value for the given variable key.
|
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 |
setBeliefValues(java.util.Map<java.lang.Integer,java.lang.Double> beliefValues) |
void |
setBeliefVector(double[] b)
Sets this belief state to the provided.
|
void |
setDomain(PODomain domain) |
void |
setStateEnumerator(StateEnumerator stateEnumerator) |
State |
stateForId(int id)
Returns the corresponding MDP state for the provided unique identifier.
|
java.lang.String |
toString() |
java.util.List<java.lang.Object> |
variableKeys()
Returns the list of state variable keys.
|
void |
zeroOutBeliefVector()
Sets this belief state to have zero probability mass for all underlying MDP states.
|
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()
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 StateEnumerator getStateEnumerator()
public void setStateEnumerator(StateEnumerator stateEnumerator)
public java.util.Map<java.lang.Integer,java.lang.Double> getBeliefValues()
public void setBeliefValues(java.util.Map<java.lang.Integer,java.lang.Double> beliefValues)
public PODomain getDomain()
public void setDomain(PODomain domain)
public double belief(State s)
BeliefState
belief
in interface BeliefState
s
- 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 sample()
BeliefState
sample
in interface BeliefState
State
instance.public java.util.List<EnumerableBeliefState.StateBelief> nonZeroBeliefs()
EnumerableBeliefState
nonZeroBeliefs
in interface EnumerableBeliefState
List
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 State
b
- 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.public void setBeliefVector(double[] b)
setBeliefVector
in interface DenseBeliefVector
b
- the belief vector to set this belief state to.public double[] beliefVector()
beliefVector
in interface DenseBeliefVector
public 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 MutableState set(java.lang.Object variableKey, java.lang.Object value)
MutableState
set
in interface MutableState
variableKey
- the key identifier for the variable value to changevalue
- the variable value to which the variable should be set.public java.util.List<java.lang.Object> variableKeys()
State
variableKeys
in interface State
public java.lang.Object get(java.lang.Object variableKey)
State
public State copy()
State
DeepCopyState
or ShallowCopyState
annotations. If it is a shallow copy, you should not *directly*
modify any fields of a copied state without copying the fields first, or it could contaminate the state from
which the copy was made. Alternatively, use the MutableState.set(Object, Object)
method to modify
ShallowCopyState
copied states,
which for ShallowCopyState
instances should perform a safe copy-on-write operation.public State s()
HashableState
s
in interface HashableState
State
that this object hashes and evaluates.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object