MultiAgentDecisionProcess
BeliefSparse Class Reference

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

#include <BeliefSparse.h>

Inheritance diagram for BeliefSparse:
[legend]

Public Member Functions

 BeliefSparse ()
 Default Constructor. More...
 
 BeliefSparse (size_t size)
 Constructor which sets the size of the joint belief. More...
 
 BeliefSparse (const std::vector< double > &belief)
 Constructor which copies belief in this joint belief. More...
 
 BeliefSparse (const BeliefInterface &belief)
 Constructor which copies belief in this joint belief. More...
 
 BeliefSparse (const StateDistribution &belief)
 
void Clear ()
 Clears the belief. More...
 
virtual BeliefSparseClone () const
 Returns a pointer to a copy of this class. More...
 
double Get (Index sI) const
 Gets the probability of the sI'th state. More...
 
std::vector< double > Get () const
 Gets a vector of probabilities representing the belief. More...
 
BeliefIteratorGeneric GetIterator () const
 
double InnerProduct (const std::vector< double > &values) const
 Computes the inner product of a belief with the vector values. More...
 
std::vector< double > InnerProduct (const VectorSet &v) const
 Computes the inner product of a belief with the VectorSet v. More...
 
std::vector< double > InnerProduct (const VectorSet &v, const std::vector< bool > &mask) const
 Computes the inner product of a belief with the VectorSet v. More...
 
unsigned int NumberNonZeros () const
 
BeliefSparseoperator= (const BeliefSparse &o)
 
BeliefInterfaceoperator= (const BeliefInterface &o)
 Copy assignment operator. More...
 
double & operator[] (Index &i)
 Gets the probability of the i'th state. More...
 
double & operator[] (int &i)
 Gets the probability of the i'th state. More...
 
void Print () const
 Prints the belief. More...
 
bool SanityCheck () const
 Checks whether the belief is a valid probability distribution. More...
 
void Set (const BS &belief)
 
void Set (const std::vector< double > &belief)
 Copy the belief into this object. More...
 
void Set (Index sI, double prob)
 Sets probability of the sI'th state to prob . More...
 
void Set (const BeliefInterface &belief)
 Copy the belief into this object. More...
 
virtual void Set (const StateDistribution &belief)
 Copy the belief into this object. More...
 
unsigned int Size () const
 Returns the size of this belief. More...
 
std::string SoftPrint () const
 Prints the belief. More...
 
 ~BeliefSparse ()
 Destructor. More...
 
- Public Member Functions inherited from BeliefInterface
 BeliefInterface ()
 (default) Constructor More...
 
virtual ~BeliefInterface ()
 Destructor. More...
 

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. More...
 

Friends

class BeliefIteratorSparse
 

Detailed Description

BeliefSparse represents a probability distribution over the state space.

It is stored as a sparse vector.

Member Typedef Documentation

typedef boost::numeric::ublas::compressed_vector<double> BeliefSparse::BS
protected
typedef BS::const_iterator BeliefSparse::BScit
protected
typedef BS::iterator BeliefSparse::BSit
protected

Constructor & Destructor Documentation

BeliefSparse::BeliefSparse ( )

Default Constructor.

Referenced by Clone().

BeliefSparse::BeliefSparse ( size_t  size)

Constructor which sets the size of the joint belief.

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

Constructor which copies belief in this joint belief.

BeliefSparse::BeliefSparse ( const BeliefInterface belief)

Constructor which copies belief in this joint belief.

BeliefSparse::BeliefSparse ( const StateDistribution belief)
BeliefSparse::~BeliefSparse ( )

Destructor.

Member Function Documentation

void BeliefSparse::Clear ( )
virtual

Clears the belief.

Implements BeliefInterface.

virtual BeliefSparse* BeliefSparse::Clone ( ) const
inlinevirtual

Returns a pointer to a copy of this class.

Implements BeliefInterface.

Reimplemented in JointBeliefSparse.

References BeliefSparse().

double BeliefSparse::Get ( Index  sI) const
inlinevirtual

Gets the probability of the sI'th state.

Implements BeliefInterface.

Referenced by AgentQMDP::Act().

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

Gets a vector of probabilities representing the belief.

Implements BeliefInterface.

BeliefIteratorGeneric BeliefSparse::GetIterator ( ) const
virtual

Implements BeliefInterface.

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

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

Implements BeliefInterface.

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.

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.

unsigned int BeliefSparse::NumberNonZeros ( ) const
inline
BeliefSparse & BeliefSparse::operator= ( const BeliefSparse o)

References _m_b.

Referenced by JointBeliefSparse::operator=().

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.

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

Gets the probability of the i'th state.

Implements BeliefInterface.

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

Gets the probability of the i'th state.

Implements BeliefInterface.

void BeliefSparse::Print ( ) const
inlinevirtual

Prints the belief.

Implements BeliefInterface.

References SoftPrint().

Referenced by AgentQMDP::Act().

bool BeliefSparse::SanityCheck ( ) const
virtual

Checks whether the belief is a valid probability distribution.

Implements BeliefInterface.

References Globals::PROB_PRECISION.

Referenced by JointBeliefSparse::Update(), and JointBeliefSparse::UpdateSlow().

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

Copy the belief into this object.

Implements BeliefInterface.

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

Sets probability of the sI'th state to prob .

Implements BeliefInterface.

void BeliefSparse::Set ( const BeliefInterface belief)
virtual

Copy the belief into this object.

Implements BeliefInterface.

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

void BeliefSparse::Set ( const StateDistribution belief)
virtual

Copy the belief into this object.

Implements BeliefInterface.

References StateDistribution::GetNrStates(), and StateDistribution::GetProbability().

unsigned int BeliefSparse::Size ( ) const
inlinevirtual

Returns the size of this belief.

Implements BeliefInterface.

Referenced by BeliefIteratorSparse::BeliefIteratorSparse().

string BeliefSparse::SoftPrint ( ) const
virtual

Prints the belief.

Implements BeliefInterface.

Referenced by Print().

Friends And Related Function Documentation

friend class BeliefIteratorSparse
friend

Member Data Documentation

BS BeliefSparse::_m_b
protected