MultiAgentDecisionProcess  Release 0.2.1
GeneralizedMAAStarPlanner Class Reference

GeneralizedMAAStarPlanner is a class that represents the Generalized MAA* planner class. More...

#include <GeneralizedMAAStarPlanner.h>

+ Inheritance diagram for GeneralizedMAAStarPlanner:
+ Collaboration diagram for GeneralizedMAAStarPlanner:

Public Member Functions

 GeneralizedMAAStarPlanner (int verbose_level=0, double slack=0.0)
 (default) Constructor
double GetExpectedReward () const
JointPolicyGetJointPolicy ()
JointPolicyDiscreteGetJointPolicyDiscrete ()
JointPolicyDiscretePureGetJointPolicyDiscretePure ()
LIndex GetMaxJPolPoolSize () const
LIndex GetNrEvaluatedJPolBGs () const
GeneralizedMAAStarPlanneroperator= (const GeneralizedMAAStarPlanner &o)
 Copy assignment operator.
void Plan ()
void SetIntermediateResultFile (std::ofstream &of)
void SetIntermediateTimingFilename (std::string filename)
void SetSaveAllBGs (std::string filename)
void SetVerbose (int verbose)
 ~GeneralizedMAAStarPlanner ()
 Destructor.
- Public Member Functions inherited from TimedAlgorithm
void AddTimedEvent (const std::string &id, clock_t duration)
 Adds event of certain duration, e.g., an external program call.
std::vector< double > GetTimedEventDurations (const std::string &id)
 Returns all stored durations (in s) for a particular event.
void LoadTimers (const std::string &filename)
 Load timing info from file filename.
void PrintTimers () const
 Print stored timing info.
void PrintTimersSummary () const
 Sums data and prints out a summary.
void SaveTimers (const std::string &filename) const
 Save collected timing info to file filename.
void SaveTimers (std::ofstream &of) const
 Save collected timing info to ofstream of.
void StartTimer (const std::string &id) const
 Start to time an event identified by id.
void StopTimer (const std::string &id) const
 Stop to time an event identified by id.
 TimedAlgorithm ()
 (default) Constructor
virtual ~TimedAlgorithm ()
 Destructor.

Protected Member Functions

virtual bool ConstructAndValuateNextPolicies (PartialPolicyPoolItemInterface *ppi, PartialPolicyPoolInterface *poolOfNextPolicies)=0
 The 'NEXT' function as described in refGMAA.
virtual
PartialJointPolicyDiscretePure
ConstructExtendedJointPolicy (const PartialJointPolicyDiscretePure &jpolPrevTs, const JointPolicyDiscretePure &jpolBG, const std::vector< size_t > &nrOHts, const std::vector< Index > &firstOHtsI)=0
 Extends a previous policy jpolPrevTs to the next stage.
virtual
Interface_ProblemToPolicyDiscretePure
GetThisFromMostDerivedPU ()=0
 every derived class must implement this function as follows:
virtual
PartialJointPolicyDiscretePure
NewJPol () const =0
 return a new policy.
virtual
PartialPolicyPoolInterface
NewPP () const =0
 return a new policy pool.
virtual
PartialPolicyPoolItemInterface
NewPPI (PartialJointPolicyDiscretePure *p, double v) const =0
 return a new policy pool item.
void Prune (PartialPolicyPoolInterface &JPVs, size_t k)
void SelectKBestPoliciesToProcessFurther (PartialPolicyPoolInterface *poolOfNextPolicies, bool are_LBs, double bestLB, size_t k)
 Returns the k best-ranked (partial) joint policies.
virtual void SelectPoliciesToProcessFurther (PartialPolicyPoolInterface *poolOfNextPolicies, bool are_LBs, double bestLB)=0
 Limits the policies to be further examined.

Protected Attributes

std::string _m_bgBaseFilename
size_t _m_bgCounter
double _m_expectedRewardFoundPolicy
 the expected reward of the best found policy
JointPolicyDiscretePure_m_foundPolicy
 the best found policy
std::ofstream * _m_intermediateResultFile
 Pointer to an file stream to store the intermediate (timing) results.
std::string _m_intermediateTimingFilename
LIndex _m_maxJPolPoolSize
 a counter that maintains the maximum size of the policy pool during the planning process.
LIndex _m_nrJPolBGsEvaluated
size_t _m_nrPoliciesToProcess
bool _m_saveIntermediateTiming
double _m_slack
 when the heuristic is not admissible, or the past reward is an approximation, we may add some slack such that good policies are not pruned
bool _m_useSparseBeliefs
int _m_verboseness
 the level of verboseness, default=0, >0 verbose, <0 silent

Detailed Description

GeneralizedMAAStarPlanner is a class that represents the Generalized MAA* planner class.

This implements GMAA pretty much as described in refGMAA (see DOC-References.h). The 'NEXT' as described in refGMAA, is called 'ConstructAndValuateNextPolicies'.

Additionally there is a function 'SelectPoliciesToProcessFurther'. (not to be confused with the 'SELECT' function from refGMAA !!!) Given the result of ConstructAndValuateNextPolicies, SelectPoliciesToProcessFurther determines which of these will actually be added to the policy pool. I.e., ConstructAndValuateNextPolicies and SelectPoliciesToProcessFurther together form 'NEXT'.

The 'SELECT' function as described in refGMAA is implemented by the policy pool (see PartialPolicyPoolInterface) itself.

This class also implements a 'NEXT' and 'SELECT' functions that can be used by derived classes.

See Also
GMAA_MAAstar, GMAA, PartialPolicyPoolInterface

Definition at line 90 of file GeneralizedMAAStarPlanner.h.

Constructor & Destructor Documentation

GeneralizedMAAStarPlanner::GeneralizedMAAStarPlanner ( int  verbose_level = 0,
double  slack = 0.0 
)
GeneralizedMAAStarPlanner::~GeneralizedMAAStarPlanner ( )

Destructor.

Definition at line 61 of file GeneralizedMAAStarPlanner.cpp.

References _m_foundPolicy.

Member Function Documentation

virtual bool GeneralizedMAAStarPlanner::ConstructAndValuateNextPolicies ( PartialPolicyPoolItemInterface ppi,
PartialPolicyPoolInterface poolOfNextPolicies 
)
protectedpure virtual

The 'NEXT' function as described in refGMAA.

The function that from a given <jpol,val> pair construct a new (ordered by value->priority_queue) set of joint policies. This function should be overriden in derived classes to get different planning behavior.

Implemented in GMAA_kGMAA, and GMAA_MAAstar.

Referenced by Plan().

virtual PartialJointPolicyDiscretePure* GeneralizedMAAStarPlanner::ConstructExtendedJointPolicy ( const PartialJointPolicyDiscretePure jpolPrevTs,
const JointPolicyDiscretePure jpolBG,
const std::vector< size_t > &  nrOHts,
const std::vector< Index > &  firstOHtsI 
)
protectedpure virtual

Extends a previous policy jpolPrevTs to the next stage.

This function extends a previous policy jpolPrevTs for ts-1 with the behavior specified by the policy of the BayesianGame for time step ts (jpolBG). jpolPrevTs - a joint policy for the DecPOMDP up to time step ts-1 (i.e. with depth=ts-2) jpolBG - a joint policy for the BayesianGame for time step ts. nrOHts - a vector that specifies the number of observation histories for eac agents at time step ts. firstOHtsI - a vector that specifies the index of the first observation history in time step ts for each agent (this functions as the offset in the conversion BG->DecPOMDP index conversion).

returns a new JointPolicyPureVector (so it must be explicitly deleted)

Implemented in GeneralizedMAAStarPlannerForDecPOMDPDiscrete.

double GeneralizedMAAStarPlanner::GetExpectedReward ( void  ) const
inline
JointPolicy * GeneralizedMAAStarPlanner::GetJointPolicy ( void  )

Reimplemented in GeneralizedMAAStarPlannerForDecPOMDPDiscrete.

Definition at line 349 of file GeneralizedMAAStarPlanner.cpp.

References _m_foundPolicy.

JointPolicyDiscrete * GeneralizedMAAStarPlanner::GetJointPolicyDiscrete ( void  )

Definition at line 351 of file GeneralizedMAAStarPlanner.cpp.

References _m_foundPolicy.

JointPolicyDiscretePure * GeneralizedMAAStarPlanner::GetJointPolicyDiscretePure ( )

Definition at line 353 of file GeneralizedMAAStarPlanner.cpp.

References _m_foundPolicy.

LIndex GeneralizedMAAStarPlanner::GetMaxJPolPoolSize ( ) const
inline

Definition at line 294 of file GeneralizedMAAStarPlanner.h.

References _m_maxJPolPoolSize.

LIndex GeneralizedMAAStarPlanner::GetNrEvaluatedJPolBGs ( ) const
inline

Definition at line 296 of file GeneralizedMAAStarPlanner.h.

References _m_nrJPolBGsEvaluated.

virtual Interface_ProblemToPolicyDiscretePure* GeneralizedMAAStarPlanner::GetThisFromMostDerivedPU ( )
protectedpure virtual

every derived class must implement this function as follows:

GetThisFromMostDerivedPU() { return this; } Giving us access to the Interface_ProblemToPolicyDiscretePure in this base class.

Implemented in GeneralizedMAAStarPlannerForDecPOMDPDiscrete.

Referenced by Plan().

virtual PartialJointPolicyDiscretePure* GeneralizedMAAStarPlanner::NewJPol ( ) const
protectedpure virtual

return a new policy.

Different versions of GMAA may make use of different implementations of policies. This function must be implemented by a derived class and return a pointer to a newly created PolicyPoolItem object. This way,the derived class can determine the implementation of the policy.

it returns a pointer to a PartialJointPolicyDiscretePure that is created by 'new' therefore, do not forget to 'delete'!!

Implemented in GMAA_kGMAA, and GeneralizedMAAStarPlannerForDecPOMDPDiscrete.

Referenced by Plan().

virtual PartialPolicyPoolInterface* GeneralizedMAAStarPlanner::NewPP ( ) const
protectedpure virtual

return a new policy pool.

this function must be implemented by a derived class and return a pointer to a PartialPolicyPoolInterface object. This way,the derived class can determine the implementation of the policy pools used and thus the 'SELECT' functions as described in refGMAA.

it returns a pointer to a PartialPolicyPoolInterface that is created by 'new' therefore, do not forget to 'delete'!!

Implemented in GeneralizedMAAStarPlannerForDecPOMDPDiscrete.

Referenced by Plan(), Prune(), and SelectKBestPoliciesToProcessFurther().

virtual PartialPolicyPoolItemInterface* GeneralizedMAAStarPlanner::NewPPI ( PartialJointPolicyDiscretePure p,
double  v 
) const
protectedpure virtual

return a new policy pool item.

This function must be implemented by a derived class and return a pointer to a newly created PolicyPoolItem object. This way,the derived class can determine the implementation of the policy pools used and thus the 'SELECT' functions as described in refGMAA.

it returns a pointer to a PartialPolicyPoolInterface that is created by 'new' therefore, do not forget to 'delete'!!Overloaded form of NewPP().

Creates a PartialPolicyPoolItemInterface which contains joint policy p, with value v.

Implemented in GeneralizedMAAStarPlannerForDecPOMDPDiscrete.

GeneralizedMAAStarPlanner & GeneralizedMAAStarPlanner::operator= ( const GeneralizedMAAStarPlanner o)

Copy assignment operator.

Definition at line 67 of file GeneralizedMAAStarPlanner.cpp.

void GeneralizedMAAStarPlanner::SelectKBestPoliciesToProcessFurther ( PartialPolicyPoolInterface poolOfNextPolicies,
bool  are_LBs,
double  bestLB,
size_t  k 
)
protected

Returns the k best-ranked (partial) joint policies.

An implementation of the 'SELECT' function, that returns the k (partial) joint policies with the highest heuristic values.

Definition at line 268 of file GeneralizedMAAStarPlanner.cpp.

References PartialPolicyPoolInterface::Empty(), PartialPolicyPoolInterface::GetBestRanked(), PartialPolicyPoolItemInterface::GetValue(), PartialPolicyPoolInterface::Insert(), NewPP(), PartialPolicyPoolInterface::Pop(), PartialPolicyPoolInterface::PopBestRanked(), and PartialPolicyPoolInterface::Size().

Referenced by GMAA_kGMAA::SelectPoliciesToProcessFurther().

virtual void GeneralizedMAAStarPlanner::SelectPoliciesToProcessFurther ( PartialPolicyPoolInterface poolOfNextPolicies,
bool  are_LBs,
double  bestLB 
)
protectedpure virtual

Limits the policies to be further examined.

Of the <jpol,val> pairs found by ConstructAndValuateNextPolicies, we may not want to process all of them further. This function performs a selection. This function should be overriden in derived classes to get different planning behavior.

Implemented in GMAA_kGMAA, and GMAA_MAAstar.

Referenced by Plan().

void GeneralizedMAAStarPlanner::SetIntermediateResultFile ( std::ofstream &  of)
inline

Definition at line 273 of file GeneralizedMAAStarPlanner.h.

References _m_intermediateResultFile.

void GeneralizedMAAStarPlanner::SetIntermediateTimingFilename ( std::string  filename)
void GeneralizedMAAStarPlanner::SetSaveAllBGs ( std::string  filename)
inline

Definition at line 276 of file GeneralizedMAAStarPlanner.h.

References _m_bgBaseFilename.

void GeneralizedMAAStarPlanner::SetVerbose ( int  verbose)

Definition at line 344 of file GeneralizedMAAStarPlanner.cpp.

References _m_verboseness.

Member Data Documentation

std::string GeneralizedMAAStarPlanner::_m_bgBaseFilename
protected
size_t GeneralizedMAAStarPlanner::_m_bgCounter
protected
double GeneralizedMAAStarPlanner::_m_expectedRewardFoundPolicy
protected

the expected reward of the best found policy

Definition at line 99 of file GeneralizedMAAStarPlanner.h.

Referenced by GetExpectedReward(), and Plan().

JointPolicyDiscretePure* GeneralizedMAAStarPlanner::_m_foundPolicy
protected
std::ofstream* GeneralizedMAAStarPlanner::_m_intermediateResultFile
protected

Pointer to an file stream to store the intermediate (timing) results.

Definition at line 111 of file GeneralizedMAAStarPlanner.h.

Referenced by GeneralizedMAAStarPlanner(), Plan(), and SetIntermediateResultFile().

std::string GeneralizedMAAStarPlanner::_m_intermediateTimingFilename
protected

Definition at line 116 of file GeneralizedMAAStarPlanner.h.

Referenced by Plan(), and SetIntermediateTimingFilename().

LIndex GeneralizedMAAStarPlanner::_m_maxJPolPoolSize
protected

a counter that maintains the maximum size of the policy pool during the planning process.

Definition at line 107 of file GeneralizedMAAStarPlanner.h.

Referenced by GetMaxJPolPoolSize(), and Plan().

LIndex GeneralizedMAAStarPlanner::_m_nrJPolBGsEvaluated
protected
size_t GeneralizedMAAStarPlanner::_m_nrPoliciesToProcess
protected
bool GeneralizedMAAStarPlanner::_m_saveIntermediateTiming
protected
double GeneralizedMAAStarPlanner::_m_slack
protected

when the heuristic is not admissible, or the past reward is an approximation, we may add some slack such that good policies are not pruned

Definition at line 129 of file GeneralizedMAAStarPlanner.h.

Referenced by Plan().

bool GeneralizedMAAStarPlanner::_m_useSparseBeliefs
protected
int GeneralizedMAAStarPlanner::_m_verboseness
protected

the level of verboseness, default=0, >0 verbose, <0 silent

Definition at line 103 of file GeneralizedMAAStarPlanner.h.

Referenced by GMAA_MAAstar::ConstructAndValuateNextPolicies(), Plan(), and SetVerbose().


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