MultiAgentDecisionProcess
Release 0.2.1
|
GeneralizedMAAStarPlanner is a class that represents the Generalized MAA* planner class. More...
#include <GeneralizedMAAStarPlanner.h>
Public Member Functions | |
GeneralizedMAAStarPlanner (int verbose_level=0, double slack=0.0) | |
(default) Constructor | |
double | GetExpectedReward () const |
JointPolicy * | GetJointPolicy () |
JointPolicyDiscrete * | GetJointPolicyDiscrete () |
JointPolicyDiscretePure * | GetJointPolicyDiscretePure () |
LIndex | GetMaxJPolPoolSize () const |
LIndex | GetNrEvaluatedJPolBGs () const |
GeneralizedMAAStarPlanner & | operator= (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. | |
![]() | |
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 |
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.
Definition at line 90 of file GeneralizedMAAStarPlanner.h.
GeneralizedMAAStarPlanner::GeneralizedMAAStarPlanner | ( | int | verbose_level = 0 , |
double | slack = 0.0 |
||
) |
(default) Constructor
Definition at line 45 of file GeneralizedMAAStarPlanner.cpp.
References _m_bgBaseFilename, _m_bgCounter, _m_intermediateResultFile, _m_nrJPolBGsEvaluated, _m_nrPoliciesToProcess, and _m_saveIntermediateTiming.
GeneralizedMAAStarPlanner::~GeneralizedMAAStarPlanner | ( | ) |
|
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().
|
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.
|
inline |
Reimplemented in GeneralizedMAAStarPlannerForDecPOMDPDiscrete.
Definition at line 292 of file GeneralizedMAAStarPlanner.h.
References _m_expectedRewardFoundPolicy.
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.
|
inline |
Definition at line 294 of file GeneralizedMAAStarPlanner.h.
References _m_maxJPolPoolSize.
|
inline |
Definition at line 296 of file GeneralizedMAAStarPlanner.h.
References _m_nrJPolBGsEvaluated.
|
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().
|
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().
|
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().
|
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::Plan | ( | ) |
Reimplemented in GeneralizedMAAStarPlannerForDecPOMDPDiscrete.
Definition at line 95 of file GeneralizedMAAStarPlanner.cpp.
References _m_expectedRewardFoundPolicy, _m_foundPolicy, _m_intermediateResultFile, _m_intermediateTimingFilename, _m_maxJPolPoolSize, _m_saveIntermediateTiming, _m_slack, _m_verboseness, ConstructAndValuateNextPolicies(), DEBUG_GMAA4, PartialPolicyPoolInterface::Empty(), JointPolicy::GetDepth(), PartialPolicyPoolItemInterface::GetJPol(), GetThisFromMostDerivedPU(), PartialPolicyPoolItemInterface::GetValue(), PartialPolicyPoolInterface::Init(), NewJPol(), NewPP(), PartialPolicyPoolInterface::Pop(), PartialPolicyPoolInterface::PopBestRanked(), PartialPolicyPoolItemInterface::Print(), JointPolicy::Print(), PartialPolicyPoolInterface::Prune(), TimedAlgorithm::SaveTimers(), PartialPolicyPoolInterface::Select(), SelectPoliciesToProcessFurther(), PartialJointPolicy::SetPastReward(), PartialPolicyPoolInterface::Size(), JointPolicyDiscretePure::SoftPrint(), JointPolicyDiscretePure::SoftPrintBrief(), TimedAlgorithm::StartTimer(), TimedAlgorithm::StopTimer(), JointPolicyDiscretePure::ToJointPolicyPureVector(), and PartialPolicyPoolInterface::Union().
|
protected |
|
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().
|
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().
|
inline |
Definition at line 273 of file GeneralizedMAAStarPlanner.h.
References _m_intermediateResultFile.
void GeneralizedMAAStarPlanner::SetIntermediateTimingFilename | ( | std::string | filename | ) |
Definition at line 338 of file GeneralizedMAAStarPlanner.cpp.
References _m_intermediateTimingFilename, and _m_saveIntermediateTiming.
|
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.
|
protected |
Definition at line 119 of file GeneralizedMAAStarPlanner.h.
Referenced by GMAA_kGMAA::ConstructAndValuateNextPolicies(), GeneralizedMAAStarPlanner(), and SetSaveAllBGs().
|
protected |
Definition at line 118 of file GeneralizedMAAStarPlanner.h.
Referenced by GMAA_kGMAA::ConstructAndValuateNextPolicies(), and GeneralizedMAAStarPlanner().
|
protected |
the expected reward of the best found policy
Definition at line 99 of file GeneralizedMAAStarPlanner.h.
Referenced by GetExpectedReward(), and Plan().
|
protected |
the best found policy
Definition at line 97 of file GeneralizedMAAStarPlanner.h.
Referenced by GetJointPolicy(), GetJointPolicyDiscrete(), GetJointPolicyDiscretePure(), Plan(), and ~GeneralizedMAAStarPlanner().
|
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().
|
protected |
Definition at line 116 of file GeneralizedMAAStarPlanner.h.
Referenced by Plan(), and SetIntermediateTimingFilename().
|
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().
|
protected |
Definition at line 122 of file GeneralizedMAAStarPlanner.h.
Referenced by GMAA_MAAstar::ConstructAndValuateNextPolicies(), GeneralizedMAAStarPlanner(), and GetNrEvaluatedJPolBGs().
|
protected |
Definition at line 124 of file GeneralizedMAAStarPlanner.h.
Referenced by GMAA_kGMAA::ConstructAndValuateNextPolicies(), GeneralizedMAAStarPlanner(), GMAA_kGMAA::GMAA_kGMAA(), and GMAA_kGMAA::SelectPoliciesToProcessFurther().
|
protected |
Definition at line 115 of file GeneralizedMAAStarPlanner.h.
Referenced by GeneralizedMAAStarPlanner(), Plan(), and SetIntermediateTimingFilename().
|
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().
|
protected |
Definition at line 113 of file GeneralizedMAAStarPlanner.h.
Referenced by GeneralizedMAAStarPlannerForDecPOMDPDiscrete::GeneralizedMAAStarPlannerForDecPOMDPDiscrete().
|
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().