MultiAgentDecisionProcess
OptimalValueDatabase Class Reference

OptimalValueDatabase provides values of optimal policies for problems, so to be used for verification purposes. More...

#include <OptimalValueDatabase.h>

Public Member Functions

std::string GetEntryName () const
 Get the name of the current entry. More...
 
double GetOptimalValue () const
 Get the optimal value (if known, otherwise expection is thrown). More...
 
bool IsInDatabase () const
 Check if the particular (problem, discount, horizon) tuple is stored. More...
 
bool IsOptimal (double value) const
 Check if the value is optimal. More...
 
 OptimalValueDatabase (const PlanningUnitDecPOMDPDiscrete *pu)
 (default) Constructor More...
 
 OptimalValueDatabase (const std::string &problemName, double discount, size_t horizon)
 
void SetOptimalValue (double value)
 Add an entry to the database. Saves it to disk. More...
 
std::string SoftPrint () const
 A string representation of the database. More...
 

Private Types

typedef std::pair
< nameDiscountT, size_t > 
nameDiscountHorizonT
 
typedef std::pair< std::string,
double > 
nameDiscountT
 

Private Member Functions

void AddEntry (const std::string &problemName, double discount, size_t horizon, double value)
 Add an entry to the database. More...
 
double GetEntry (const std::string &problemName, double discount, size_t horizon) const
 Get an entry from the database. More...
 
bool IsInDatabase (const std::string &problemName, double discount, size_t horizon) const
 Check if the problem is in the database already. More...
 
bool IsOptimal (const std::string &problemName, double discount, size_t horizon, double value) const
 Check if the value corresponds with a known optimal value. More...
 
void Load ()
 Load the database from disk. More...
 
void Save () const
 Store the database to disk. More...
 

Private Attributes

std::string _filename
 
double _m_discount
 
size_t _m_horizon
 
std::map< nameDiscountHorizonT,
double > 
_m_optimalValues
 The database. More...
 
std::string _m_problemName
 

Detailed Description

OptimalValueDatabase provides values of optimal policies for problems, so to be used for verification purposes.

Member Typedef Documentation

typedef std::pair<nameDiscountT, size_t> OptimalValueDatabase::nameDiscountHorizonT
private
typedef std::pair<std::string,double> OptimalValueDatabase::nameDiscountT
private

Constructor & Destructor Documentation

OptimalValueDatabase::OptimalValueDatabase ( const PlanningUnitDecPOMDPDiscrete pu)

(default) Constructor

References Load().

OptimalValueDatabase::OptimalValueDatabase ( const std::string &  problemName,
double  discount,
size_t  horizon 
)

References Load().

Member Function Documentation

void OptimalValueDatabase::AddEntry ( const std::string &  problemName,
double  discount,
size_t  horizon,
double  value 
)
private

Add an entry to the database.

References _m_optimalValues.

Referenced by Load(), and SetOptimalValue().

double OptimalValueDatabase::GetEntry ( const std::string &  problemName,
double  discount,
size_t  horizon 
) const
private

Get an entry from the database.

References _m_optimalValues.

Referenced by GetOptimalValue(), and IsOptimal().

string OptimalValueDatabase::GetEntryName ( ) const

Get the name of the current entry.

References _m_discount, _m_horizon, and _m_problemName.

double OptimalValueDatabase::GetOptimalValue ( ) const

Get the optimal value (if known, otherwise expection is thrown).

References _m_discount, _m_horizon, _m_problemName, and GetEntry().

bool OptimalValueDatabase::IsInDatabase ( const std::string &  problemName,
double  discount,
size_t  horizon 
) const
private

Check if the problem is in the database already.

References _m_optimalValues.

bool OptimalValueDatabase::IsInDatabase ( ) const

Check if the particular (problem, discount, horizon) tuple is stored.

References _m_discount, _m_horizon, and _m_problemName.

bool OptimalValueDatabase::IsOptimal ( const std::string &  problemName,
double  discount,
size_t  horizon,
double  value 
) const
private

Check if the value corresponds with a known optimal value.

References Globals::EqualReward(), and GetEntry().

Referenced by IsOptimal().

bool OptimalValueDatabase::IsOptimal ( double  value) const

Check if the value is optimal.

References _m_discount, _m_horizon, _m_problemName, and IsOptimal().

void OptimalValueDatabase::Load ( )
private

Load the database from disk.

References _filename, _m_optimalValues, AddEntry(), and directories::MADPGetResultsDir().

Referenced by OptimalValueDatabase().

void OptimalValueDatabase::Save ( ) const
private

Store the database to disk.

References _filename, and SoftPrint().

Referenced by SetOptimalValue().

void OptimalValueDatabase::SetOptimalValue ( double  value)

Add an entry to the database. Saves it to disk.

References _m_discount, _m_horizon, _m_problemName, AddEntry(), and Save().

string OptimalValueDatabase::SoftPrint ( void  ) const

A string representation of the database.

References _m_optimalValues.

Referenced by Save().

Member Data Documentation

std::string OptimalValueDatabase::_filename
private

Referenced by Load(), and Save().

double OptimalValueDatabase::_m_discount
private
size_t OptimalValueDatabase::_m_horizon
private
std::map<nameDiscountHorizonT, double> OptimalValueDatabase::_m_optimalValues
private

The database.

Referenced by AddEntry(), GetEntry(), IsInDatabase(), Load(), and SoftPrint().

std::string OptimalValueDatabase::_m_problemName
private