MultiAgentDecisionProcess
Release 0.2.1
|
BeliefSparse represents a probability distribution over the state space. More...
#include <BeliefSparse.h>
Public Member Functions | |
BeliefSparse () | |
Default Constructor. | |
BeliefSparse (size_t size) | |
Constructor which sets the size of the joint belief. | |
BeliefSparse (const std::vector< double > &belief) | |
Constructor which copies belief in this joint belief. | |
BeliefSparse (const BeliefInterface &belief) | |
Constructor which copies belief in this joint belief. | |
BeliefSparse (const StateDistribution &belief) | |
void | Clear () |
Clears the belief. | |
virtual BeliefSparse * | Clone () const |
Returns a pointer to a copy of this class. | |
double | Get (Index sI) const |
Gets the probability of the sI'th state. | |
std::vector< double > | Get () const |
Gets a vector of probabilities representing the belief. | |
BeliefIteratorGeneric | GetIterator () const |
double | InnerProduct (const std::vector< double > &values) const |
Computes the inner product of a belief with the vector values. | |
std::vector< double > | InnerProduct (const VectorSet &v) const |
Computes the inner product of a belief with the VectorSet v. | |
std::vector< double > | InnerProduct (const VectorSet &v, const std::vector< bool > &mask) const |
Computes the inner product of a belief with the VectorSet v. | |
BeliefSparse & | operator= (const BeliefSparse &o) |
BeliefInterface & | operator= (const BeliefInterface &o) |
Copy assignment operator. | |
double & | operator[] (Index &i) |
Gets the probability of the i'th state. | |
double & | operator[] (int &i) |
Gets the probability of the i'th state. | |
void | Print () const |
Prints the belief. | |
bool | SanityCheck () const |
Checks whether the belief is a valid probability distribution. | |
void | Set (const BS &belief) |
void | Set (const std::vector< double > &belief) |
Copy the belief into this object. | |
void | Set (Index sI, double prob) |
Sets probability of the sI'th state to prob . | |
void | Set (const BeliefInterface &belief) |
Copy the belief into this object. | |
virtual void | Set (const StateDistribution &belief) |
Copy the belief into this object. | |
unsigned int | Size () const |
Returns the size of this belief. | |
std::string | SoftPrint () const |
Prints the belief. | |
~BeliefSparse () | |
Destructor. | |
![]() | |
BeliefInterface () | |
(default) Constructor | |
virtual | ~BeliefInterface () |
Destructor. |
Protected Types | |
typedef boost::numeric::ublas::compressed_vector < double > | BS |
typedef BS::const_iterator | BScit |
typedef BS::iterator | BSit |
Protected Attributes | |
BS | _m_b |
The sparse vector to store the belief. |
Friends | |
class | BeliefIteratorSparse |
BeliefSparse represents a probability distribution over the state space.
It is stored as a sparse vector.
Definition at line 45 of file BeliefSparse.h.
|
protected |
Definition at line 56 of file BeliefSparse.h.
|
protected |
Definition at line 59 of file BeliefSparse.h.
|
protected |
Definition at line 60 of file BeliefSparse.h.
BeliefSparse::BeliefSparse | ( | ) |
BeliefSparse::BeliefSparse | ( | size_t | size | ) |
Constructor which sets the size of the joint belief.
Definition at line 42 of file BeliefSparse.cpp.
BeliefSparse::BeliefSparse | ( | const std::vector< double > & | belief | ) |
Constructor which copies belief in this joint belief.
Definition at line 47 of file BeliefSparse.cpp.
BeliefSparse::BeliefSparse | ( | const BeliefInterface & | belief | ) |
Constructor which copies belief in this joint belief.
Definition at line 66 of file BeliefSparse.cpp.
BeliefSparse::BeliefSparse | ( | const StateDistribution & | belief | ) |
Definition at line 70 of file BeliefSparse.cpp.
BeliefSparse::~BeliefSparse | ( | ) |
Destructor.
Definition at line 77 of file BeliefSparse.cpp.
|
virtual |
|
inlinevirtual |
Returns a pointer to a copy of this class.
Implements BeliefInterface.
Reimplemented in JointBeliefSparse.
Definition at line 152 of file BeliefSparse.h.
References BeliefSparse().
|
inlinevirtual |
Gets the probability of the sI'th state.
Implements BeliefInterface.
Definition at line 126 of file BeliefSparse.h.
References _m_b.
Referenced by AgentQMDP::Act().
|
inlinevirtual |
Gets a vector of probabilities representing the belief.
Implements BeliefInterface.
Definition at line 127 of file BeliefSparse.h.
|
virtual |
Implements BeliefInterface.
Definition at line 256 of file BeliefSparse.cpp.
|
virtual |
Computes the inner product of a belief with the vector values.
Implements BeliefInterface.
Definition at line 207 of file BeliefSparse.cpp.
|
virtual |
Computes the inner product of a belief with the VectorSet v.
Returns the inner product with each vector in v.
Implements BeliefInterface.
Definition at line 220 of file BeliefSparse.cpp.
|
virtual |
Computes the inner product of a belief with the VectorSet v.
Returns the inner product with each vector in v, but only for vectors whose mask is set to true.
Implements BeliefInterface.
Definition at line 236 of file BeliefSparse.cpp.
BeliefSparse & BeliefSparse::operator= | ( | const BeliefSparse & | o | ) |
Definition at line 82 of file BeliefSparse.cpp.
References _m_b.
|
virtual |
Copy assignment operator.
This must be implemented by the derived class (with this prototype). For an example, see PolicyPoolJPolValPair.
For now, this function is purely abstract. Might there be some members added to this (base) class, then an implementation could be made. This should then be called using PolicyPoolInterface::operator=(o) from the copy assignment operator of the derived class. See also http://www.icu-project.org/docs/papers/cpp_report/the_assignment_operator_revisited.html.
Implements BeliefInterface.
Definition at line 91 of file BeliefSparse.cpp.
|
inlinevirtual |
Gets the probability of the i'th state.
Implements BeliefInterface.
Definition at line 104 of file BeliefSparse.h.
References _m_b.
|
inlinevirtual |
Gets the probability of the i'th state.
Implements BeliefInterface.
Definition at line 108 of file BeliefSparse.h.
References _m_b.
|
inlinevirtual |
Prints the belief.
Implements BeliefInterface.
Definition at line 136 of file BeliefSparse.h.
References SoftPrint().
Referenced by AgentQMDP::Act().
|
virtual |
Checks whether the belief is a valid probability distribution.
Implements BeliefInterface.
Definition at line 179 of file BeliefSparse.cpp.
References Globals::PROB_PRECISION.
Referenced by JointBeliefSparse::Update(), and JointBeliefSparse::UpdateSlow().
void BeliefSparse::Set | ( | const BS & | belief | ) |
Definition at line 99 of file BeliefSparse.cpp.
Referenced by AgentQMDP::ResetEpisode(), and AgentBG::ResetEpisode().
|
virtual |
Copy the belief into this object.
Implements BeliefInterface.
Definition at line 108 of file BeliefSparse.cpp.
|
inlinevirtual |
Sets probability of the sI'th state to prob .
Implements BeliefInterface.
Definition at line 118 of file BeliefSparse.h.
|
virtual |
Copy the belief into this object.
Implements BeliefInterface.
Definition at line 143 of file BeliefSparse.cpp.
References BeliefInterface::Get(), and BeliefInterface::Size().
|
virtual |
Copy the belief into this object.
Implements BeliefInterface.
Definition at line 127 of file BeliefSparse.cpp.
|
inlinevirtual |
Returns the size of this belief.
Implements BeliefInterface.
Definition at line 138 of file BeliefSparse.h.
References _m_b.
|
virtual |
Prints the belief.
Implements BeliefInterface.
Definition at line 164 of file BeliefSparse.cpp.
Referenced by Print().
|
friend |
Definition at line 49 of file BeliefSparse.h.
|
protected |
The sparse vector to store the belief.
Definition at line 63 of file BeliefSparse.h.
Referenced by BeliefIteratorSparse::BeliefIteratorSparse(), Get(), BeliefIteratorSparse::Next(), operator=(), operator[](), Set(), Size(), JointBeliefSparse::Update(), and JointBeliefSparse::UpdateSlow().