MultiAgentDecisionProcess  Release 0.2.1
BeliefSparse Class Reference

BeliefSparse represents a probability distribution over the state space. More...

#include <BeliefSparse.h>

+ Inheritance diagram for BeliefSparse:
+ Collaboration diagram for BeliefSparse:

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 BeliefSparseClone () 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.
BeliefSparseoperator= (const BeliefSparse &o)
BeliefInterfaceoperator= (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.
- Public Member Functions inherited from BeliefInterface
 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

Detailed Description

BeliefSparse represents a probability distribution over the state space.

It is stored as a sparse vector.

Definition at line 45 of file BeliefSparse.h.

Member Typedef Documentation

typedef boost::numeric::ublas::compressed_vector<double> BeliefSparse::BS
protected

Definition at line 56 of file BeliefSparse.h.

typedef BS::const_iterator BeliefSparse::BScit
protected

Definition at line 59 of file BeliefSparse.h.

typedef BS::iterator BeliefSparse::BSit
protected

Definition at line 60 of file BeliefSparse.h.

Constructor & Destructor Documentation

BeliefSparse::BeliefSparse ( )

Default Constructor.

Definition at line 38 of file BeliefSparse.cpp.

Referenced by Clone().

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.

Member Function Documentation

void BeliefSparse::Clear ( )
virtual

Clears the belief.

Implements BeliefInterface.

Definition at line 159 of file BeliefSparse.cpp.

virtual BeliefSparse* BeliefSparse::Clone ( ) const
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().

double BeliefSparse::Get ( Index  sI) const
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().

std::vector<double> BeliefSparse::Get ( ) const
inlinevirtual

Gets a vector of probabilities representing the belief.

Implements BeliefInterface.

Definition at line 127 of file BeliefSparse.h.

BeliefIteratorGeneric BeliefSparse::GetIterator ( ) const
virtual

Implements BeliefInterface.

Definition at line 256 of file BeliefSparse.cpp.

double BeliefSparse::InnerProduct ( const std::vector< double > &  values) const
virtual

Computes the inner product of a belief with the vector values.

Implements BeliefInterface.

Definition at line 207 of file BeliefSparse.cpp.

vector< double > BeliefSparse::InnerProduct ( const VectorSet v) const
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.

vector< double > BeliefSparse::InnerProduct ( const VectorSet v,
const std::vector< bool > &  mask 
) const
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.

BeliefInterface & BeliefSparse::operator= ( const BeliefInterface o)
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.

double& BeliefSparse::operator[] ( Index &  i)
inlinevirtual

Gets the probability of the i'th state.

Implements BeliefInterface.

Definition at line 104 of file BeliefSparse.h.

References _m_b.

double& BeliefSparse::operator[] ( int &  i)
inlinevirtual

Gets the probability of the i'th state.

Implements BeliefInterface.

Definition at line 108 of file BeliefSparse.h.

References _m_b.

void BeliefSparse::Print ( ) const
inlinevirtual

Prints the belief.

Implements BeliefInterface.

Definition at line 136 of file BeliefSparse.h.

References SoftPrint().

Referenced by AgentQMDP::Act().

bool BeliefSparse::SanityCheck ( ) const
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().

void BeliefSparse::Set ( const std::vector< double > &  belief)
virtual

Copy the belief into this object.

Implements BeliefInterface.

Definition at line 108 of file BeliefSparse.cpp.

void BeliefSparse::Set ( Index  sI,
double  prob 
)
inlinevirtual

Sets probability of the sI'th state to prob .

Implements BeliefInterface.

Definition at line 118 of file BeliefSparse.h.

References _m_b, and prob.

void BeliefSparse::Set ( const BeliefInterface belief)
virtual

Copy the belief into this object.

Implements BeliefInterface.

Definition at line 143 of file BeliefSparse.cpp.

References BeliefInterface::Get(), and BeliefInterface::Size().

void BeliefSparse::Set ( const StateDistribution belief)
virtual

Copy the belief into this object.

Implements BeliefInterface.

Definition at line 127 of file BeliefSparse.cpp.

unsigned int BeliefSparse::Size ( ) const
inlinevirtual

Returns the size of this belief.

Implements BeliefInterface.

Definition at line 138 of file BeliefSparse.h.

References _m_b.

string BeliefSparse::SoftPrint ( ) const
virtual

Prints the belief.

Implements BeliefInterface.

Definition at line 164 of file BeliefSparse.cpp.

Referenced by Print().

Friends And Related Function Documentation

friend class BeliefIteratorSparse
friend

Definition at line 49 of file BeliefSparse.h.

Member Data Documentation

BS BeliefSparse::_m_b
protected

The documentation for this class was generated from the following files: