MultiAgentDecisionProcess
Release 0.2.1
|
Perseus contains basic functionality for the Perseus planner. More...
#include <Perseus.h>
Public Member Functions | |
bool | CheckConvergence (const std::vector< double > &VB, const std::vector< double > &VBnew, int iter) const |
virtual void | ExportValueFunction (const std::string &filename) const =0 |
Exports the computed value function in a simple text format used by Tony Cassandra for .alpha files. | |
std::string | GetIdentification () const |
virtual double | GetQ (const JointBeliefInterface &b, Index jaI) const =0 |
virtual double | GetQ (const JointBeliefInterface &b, Index jaI, int &betaMaxI) const =0 |
virtual double | GetQ (const JointBeliefInterface &b, Index t, Index jaI) const =0 |
virtual double | GetQ (const JointBeliefInterface &b, Index t, Index jaI, int &betaMaxI) const =0 |
int | GetVerbose () const |
void | Initialize () |
Perseus (const PlanningUnitDecPOMDPDiscrete &pu) | |
(default) Constructor | |
virtual void | Plan ()=0 |
int | SampleNotImprovedBeliefIndex (std::vector< bool > stillNeedToBeImproved, int nrNotImproved) const |
Sample an index of a belief in the set which has not been improved. | |
void | SetComputeVectorForEachBelief (bool compute) |
void | SetDryrun (bool dryrun) |
void | SetIdentification (std::string identification) |
void | SetInitializeWithImmediateReward (bool initReward) |
void | SetInitializeWithZero (bool initZero) |
void | SetMaximumNumberOfIterations (int nr) |
void | SetMinimumNumberOfIterations (int nr) |
void | SetResultsFilename (std::string filename) |
void | SetSaveIntermediateValueFunctions (bool save) |
void | SetSaveTimings (bool save) |
virtual void | SetValueFunction (const std::string &filename)=0 |
void | SetVerbose (int verbose) |
virtual | ~Perseus () |
Destructor. | |
![]() | |
AlphaVectorPlanning (const PlanningUnitDecPOMDPDiscrete &pu) | |
(default) Constructor | |
GaoVectorSet | BackProject (const ValueFunctionPOMDPDiscrete &v) const |
Back projects a value function. | |
GaoVectorSet | BackProject (const VectorSet &v) const |
Back projects a value function, represented as a VectorSet. | |
GaoVectorSet | BackProjectMonahan (const QFunctionsDiscrete &Qs) const |
GaoVectorSet | BackProjectMonahan (const ValueFunctionPOMDPDiscrete &V) const |
VectorSet | CrossSum (const VectorSet &A, const VectorSet &B) const |
Compute the cross-sum of two vector sets. | |
void | ExportPOMDPFile (const std::string &filename) const |
Exports the POMDP to file named filename. | |
ValueFunctionPOMDPDiscrete | GetImmediateRewardValueFunction () const |
Returns the value function induced by the reward model. | |
const PlanningUnitDecPOMDPDiscrete * | GetPU () const |
Returns a ref to the PlanningUnit. | |
void | MonahanCrossSum (const GaoVectorSet &G, ValueFunctionPOMDPDiscrete &V, Index a, bool doIncPrune) const |
ValueFunctionPOMDPDiscrete | Prune (const ValueFunctionPOMDPDiscrete &V) const |
Prune a valuefunction. | |
VectorSet | Prune (const VectorSet &V) const |
Prune a VectorSet. | |
BeliefSet | SampleBeliefs (ArgumentHandlers::Arguments args) const |
Sample a belief set according to the arguments. | |
QFunctionsDiscrete | ValueFunctionToQ (const ValueFunctionPOMDPDiscrete &V) const |
virtual | ~AlphaVectorPlanning () |
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. |
Static Public Member Functions | |
static std::string | BackupTypeToString (const QAVParameters ¶ms) |
static QAVParameters | ProcessArguments (const ArgumentHandlers::Arguments &args) |
![]() | |
static void | ExportBeliefSet (const BeliefSet &B, const std::string &filename) |
Exports a belief set to a file. | |
static void | ExportPOMDPFile (const std::string &filename, const PlanningUnitDecPOMDPDiscrete *pu) |
Exports the POMDP represented by pu to file named filename. | |
static void | ExportValueFunction (const std::string &filename, const ValueFunctionPOMDPDiscrete &V) |
Exports a value function V to file named filename. | |
static void | ExportValueFunction (const std::string &filename, const QFunctionsDiscrete &Q) |
Exports a Q functions Q to file named filename. | |
static void | ExportValueFunction (const std::string &filename, const QFunctionsDiscreteNonStationary &Q) |
Exports a Q functions Q to file named filename. | |
static std::vector< int > | GetDuplicateIndices (const VectorSet &V) |
Returns a vector<int> which for each vector k in V specifies whether it is unique, in which case vector<int>[k] is set to -1, or whether it is a duplicate of another vector l in V, in which case vector<int>[k] is set to the index of l, where 0 <= l < V.size()). | |
static ValueFunctionPOMDPDiscrete | GetImmediateRewardValueFunction (const PlanningUnitDecPOMDPDiscrete *pu) |
Returns the value function induced by the reward model of pu. | |
static ValueFunctionPOMDPDiscrete | ImportValueFunction (const std::string &filename) |
Imports a value function from a file named filename. | |
static QFunctionsDiscreteNonStationary | ImportValueFunction (const std::string &filename, size_t nr, size_t nrA, size_t nrS) |
static ValueFunctionPOMDPDiscrete | QFunctionsToValueFunction (const QFunctionsDiscrete &Q) |
static QFunctionsDiscrete | ValueFunctionToQ (const ValueFunctionPOMDPDiscrete &V, size_t nrA, size_t nrS) |
static bool | VectorIsInValueFunction (const AlphaVector &alpha, const ValueFunctionPOMDPDiscrete &V) |
Protected Attributes | |
bool | _m_beliefsInitialized |
Whether or not the belief set has been set. | |
double | _m_bestValue |
bool | _m_computeVectorForEachBelief |
bool | _m_dryrun |
std::string | _m_identification |
std::string | _m_resultsFilename |
bool | _m_storeIntermediateValueFunctions |
bool | _m_storeTimings |
std::string | _m_valueFunctionFilename |
Private Member Functions | |
size_t | GetSize (const ValueFunctionPOMDPDiscrete &V) const |
size_t | GetSize (const QFunctionsDiscrete &Q) const |
size_t | GetSize (const QFunctionsDiscreteNonStationary &Q) const |
Private Attributes | |
bool | _m_initializeWithImmediateReward |
bool | _m_initializeWithZero |
int | _m_maximumNumberOfIterations |
int | _m_minimumNumberOfIterations |
const PlanningUnitDecPOMDPDiscrete * | _m_pu |
int | _m_verbose |
Perseus::Perseus | ( | const PlanningUnitDecPOMDPDiscrete & | pu | ) |
(default) Constructor
Definition at line 37 of file Perseus.cpp.
References SetMaximumNumberOfIterations(), SetMinimumNumberOfIterations(), and UpdateValueFunctionName().
|
virtual |
Destructor.
Definition at line 57 of file Perseus.cpp.
|
protected |
Definition at line 300 of file Perseus.cpp.
References AlphaVectorPlanning::BackProject(), GetIdentification(), and TimedAlgorithm::StartTimer().
Referenced by PerseusPOMDPPlanner::BackupStage(), PerseusBGPlanner::BackupStageAll(), PerseusBGPlanner::BackupStageSampling(), and PerseusBGPlanner::BackupStageSamplingAlt().
|
protected |
Definition at line 307 of file Perseus.cpp.
References GetIdentification(), PlanningUnitMADPDiscrete::GetNrJointActions(), PlanningUnitMADPDiscrete::GetNrJointObservations(), AlphaVectorPlanning::GetPU(), and TimedAlgorithm::StopTimer().
Referenced by PerseusPOMDPPlanner::BackupStage(), PerseusBGPlanner::BackupStageAll(), PerseusBGPlanner::BackupStageSampling(), and PerseusBGPlanner::BackupStageSamplingAlt().
|
static |
Definition at line 317 of file Perseus.cpp.
References QAVParameters::backup, BG, QAVParameters::bgBackupType, and POMDP.
bool Perseus::CheckConvergence | ( | const std::vector< double > & | VB, |
const std::vector< double > & | VBnew, | ||
int | iter | ||
) | const |
Definition at line 217 of file Perseus.cpp.
References _m_maximumNumberOfIterations, _m_minimumNumberOfIterations, _m_pu, PlanningUnit::GetHorizon(), GetIdentification(), and GetVerbose().
Referenced by PerseusQFunctionPlanner::Plan(), and PerseusPOMDPPlanner::Plan().
|
pure virtual |
Exports the computed value function in a simple text format used by Tony Cassandra for .alpha files.
Implemented in PerseusStationary.
Referenced by PlanEndOfIteration(), and PlanStartOfIteration().
|
inline |
Definition at line 224 of file Perseus.h.
References _m_identification.
Referenced by BackupStageLeadIn(), BackupStageLeadOut(), CheckConvergence(), PlanEndOfIteration(), PlanLeadIn(), PlanLeadOut(), PlanStartOfIteration(), PrintMaxRewardInBeliefSet(), and UpdateValueFunctionName().
|
protectedpure virtual |
Implemented in PerseusStationary.
Referenced by PrintMaxRewardInBeliefSet().
|
protected |
Definition at line 156 of file Perseus.cpp.
References PlanningUnit::GetHorizon(), GetInitialQFunctions(), and AlphaVectorPlanning::GetPU().
|
protected |
Definition at line 117 of file Perseus.cpp.
References _m_initializeWithImmediateReward, _m_initializeWithZero, _m_pu, GetInitialValueFunction(), PlanningUnitMADPDiscrete::GetNrJointActions(), PlanningUnitMADPDiscrete::GetNrStates(), PlanningUnitDecPOMDPDiscrete::GetReward(), AlphaVector::SetAction(), and AlphaVector::SetValue().
Referenced by GetInitialNonStationaryQFunctions(), and PerseusQFunctionPlanner::Plan().
|
protected |
Definition at line 65 of file Perseus.cpp.
References _m_initializeWithImmediateReward, _m_initializeWithZero, _m_pu, PlanningUnitDecPOMDPDiscrete::GetDiscount(), PlanningUnit::GetHorizon(), PlanningUnitMADPDiscrete::GetNrJointActions(), PlanningUnitMADPDiscrete::GetNrStates(), PlanningUnitDecPOMDPDiscrete::GetReward(), Globals::MAXHORIZON, AlphaVector::SetAction(), and AlphaVector::SetValue().
Referenced by GetInitialQFunctions(), and PerseusPOMDPPlanner::Plan().
|
pure virtual |
Implemented in PerseusStationary.
|
pure virtual |
Implemented in PerseusStationary.
|
pure virtual |
Implemented in PerseusStationary.
|
pure virtual |
Implemented in PerseusStationary.
|
inlineprivate |
Definition at line 62 of file Perseus.h.
Referenced by GetSize(), and PlanStartOfIteration().
|
inlineprivate |
|
inlineprivate |
|
inline |
Definition at line 248 of file Perseus.h.
References _m_verbose.
Referenced by PerseusPOMDPPlanner::BackupStage(), PerseusBGPlanner::BackupStageAll(), PerseusBGPlanner::BackupStageSampling(), PerseusBGPlanner::BackupStageSamplingAlt(), CheckConvergence(), PlanLeadIn(), PlanLeadOut(), PlanStartOfIteration(), PrintMaxRewardInBeliefSet(), and UpdateValueFunctionName().
void Perseus::Initialize | ( | ) |
Reimplemented from AlphaVectorPlanning.
Definition at line 61 of file Perseus.cpp.
|
protectedpure virtual |
Implemented in PerseusStationary.
Referenced by PlanLeadIn().
|
pure virtual |
Implemented in PerseusPOMDPPlanner, and PerseusQFunctionPlanner.
|
inlineprotected |
Definition at line 138 of file Perseus.h.
References _m_bestValue, _m_dryrun, _m_pu, _m_valueFunctionFilename, ExportValueFunction(), PlanningUnitMADPDiscrete::GetNewJointBeliefFromISD(), BeliefValue::GetValue(), PlanEndOfIteration(), and StoreValueFunction().
|
protected |
Definition at line 270 of file Perseus.cpp.
References _m_storeTimings, PlanningUnit::GetHorizon(), GetIdentification(), AlphaVectorPlanning::GetPU(), directories::MADPGetResultsDir(), TimedAlgorithm::PrintTimersSummary(), and TimedAlgorithm::SaveTimers().
Referenced by PerseusQFunctionPlanner::Plan(), PerseusPOMDPPlanner::Plan(), and PlanEndOfIteration().
|
protected |
Definition at line 249 of file Perseus.cpp.
References _m_beliefsInitialized, GetIdentification(), GetVerbose(), InitializeBeliefs(), PrintMaxRewardInBeliefSet(), and TimedAlgorithm::StartTimer().
Referenced by PerseusQFunctionPlanner::Plan(), and PerseusPOMDPPlanner::Plan().
|
protected |
Definition at line 285 of file Perseus.cpp.
References _m_storeTimings, PlanningUnit::GetHorizon(), GetIdentification(), AlphaVectorPlanning::GetPU(), GetVerbose(), directories::MADPGetResultsDir(), TimedAlgorithm::SaveTimers(), and TimedAlgorithm::StopTimer().
Referenced by PerseusQFunctionPlanner::Plan(), and PerseusPOMDPPlanner::Plan().
|
inlineprotected |
Definition at line 103 of file Perseus.h.
References _m_bestValue, _m_dryrun, _m_pu, _m_storeIntermediateValueFunctions, ExportValueFunction(), PlanningUnit::GetHorizon(), GetIdentification(), PlanningUnitMADPDiscrete::GetNewJointBeliefFromISD(), GetSize(), BeliefValue::GetValue(), GetVerbose(), and directories::MADPGetResultsDir().
Referenced by PerseusQFunctionPlanner::Plan(), and PerseusPOMDPPlanner::Plan().
|
protected |
Prints the maximum immediate reward present in the belief set.
Definition at line 165 of file Perseus.cpp.
References _m_beliefsInitialized, GetIdentification(), GetImmediateRewardBeliefSet(), and GetVerbose().
Referenced by PlanLeadIn().
|
static |
Definition at line 335 of file Perseus.cpp.
References QAVParameters::backup, ArgumentHandlers::Arguments::backup, BG, ArgumentHandlers::Arguments::bgBackup, QAVParameters::bgBackupType, BGIP_SOLVER_EXHAUSTIVE, and POMDP.
int Perseus::SampleNotImprovedBeliefIndex | ( | std::vector< bool > | stillNeedToBeImproved, |
int | nrNotImproved | ||
) | const |
Sample an index of a belief in the set which has not been improved.
Definition at line 183 of file Perseus.cpp.
References PrintTools::PrintVectorCout().
Referenced by PerseusPOMDPPlanner::BackupStage(), PerseusBGPlanner::BackupStageSampling(), and PerseusBGPlanner::BackupStageSamplingAlt().
|
inline |
Definition at line 231 of file Perseus.h.
References _m_computeVectorForEachBelief.
|
inline |
void Perseus::SetIdentification | ( | std::string | identification | ) |
Definition at line 353 of file Perseus.cpp.
References _m_identification, and UpdateValueFunctionName().
|
inline |
Definition at line 239 of file Perseus.h.
References _m_initializeWithImmediateReward.
|
inline |
Definition at line 242 of file Perseus.h.
References _m_initializeWithZero.
|
inline |
Definition at line 236 of file Perseus.h.
References _m_maximumNumberOfIterations.
Referenced by Perseus().
|
inline |
Definition at line 234 of file Perseus.h.
References _m_minimumNumberOfIterations.
Referenced by Perseus().
void Perseus::SetResultsFilename | ( | std::string | filename | ) |
Definition at line 359 of file Perseus.cpp.
References _m_resultsFilename, and UpdateValueFunctionName().
|
inline |
Definition at line 214 of file Perseus.h.
References _m_storeIntermediateValueFunctions.
|
inline |
Definition at line 217 of file Perseus.h.
References _m_storeTimings.
|
pure virtual |
Implemented in PerseusStationary.
|
inline |
Definition at line 247 of file Perseus.h.
References _m_verbose.
|
protectedvirtual |
Reimplemented in PerseusStationary.
Definition at line 378 of file Perseus.cpp.
Referenced by PlanEndOfIteration().
|
protectedvirtual |
Reimplemented in PerseusStationary.
Definition at line 383 of file Perseus.cpp.
|
protectedvirtual |
Definition at line 388 of file Perseus.cpp.
|
protected |
Definition at line 365 of file Perseus.cpp.
References _m_pu, _m_resultsFilename, _m_valueFunctionFilename, PlanningUnit::GetHorizon(), GetIdentification(), and GetVerbose().
Referenced by Perseus(), SetIdentification(), and SetResultsFilename().
|
protected |
Whether or not the belief set has been set.
Definition at line 84 of file Perseus.h.
Referenced by PerseusStationary::ExportBeliefSet(), PlanLeadIn(), PrintMaxRewardInBeliefSet(), PerseusStationary::SetBeliefSet(), and PerseusStationary::~PerseusStationary().
|
protected |
Definition at line 81 of file Perseus.h.
Referenced by PlanEndOfIteration(), and PlanStartOfIteration().
|
protected |
Definition at line 98 of file Perseus.h.
Referenced by PerseusBGPlanner::BackupStage(), PerseusPOMDPPlanner::BackupStage(), and SetComputeVectorForEachBelief().
|
protected |
Definition at line 100 of file Perseus.h.
Referenced by PlanEndOfIteration(), PlanStartOfIteration(), and SetDryrun().
|
protected |
Definition at line 86 of file Perseus.h.
Referenced by GetIdentification(), and SetIdentification().
|
private |
Definition at line 59 of file Perseus.h.
Referenced by GetInitialQFunctions(), GetInitialValueFunction(), and SetInitializeWithImmediateReward().
|
private |
Definition at line 60 of file Perseus.h.
Referenced by GetInitialQFunctions(), GetInitialValueFunction(), and SetInitializeWithZero().
|
private |
Definition at line 55 of file Perseus.h.
Referenced by CheckConvergence(), and SetMaximumNumberOfIterations().
|
private |
Definition at line 54 of file Perseus.h.
Referenced by CheckConvergence(), and SetMinimumNumberOfIterations().
|
private |
Definition at line 52 of file Perseus.h.
Referenced by CheckConvergence(), GetInitialQFunctions(), GetInitialValueFunction(), PlanEndOfIteration(), PlanStartOfIteration(), and UpdateValueFunctionName().
|
protected |
Definition at line 86 of file Perseus.h.
Referenced by SetResultsFilename(), and UpdateValueFunctionName().
|
protected |
Definition at line 94 of file Perseus.h.
Referenced by PlanStartOfIteration(), and SetSaveIntermediateValueFunctions().
|
protected |
Definition at line 96 of file Perseus.h.
Referenced by PlanEndOfIteration(), PlanLeadOut(), and SetSaveTimings().
|
protected |
Definition at line 86 of file Perseus.h.
Referenced by PlanEndOfIteration(), and UpdateValueFunctionName().
|
private |
Definition at line 57 of file Perseus.h.
Referenced by GetVerbose(), and SetVerbose().