MultiAgentDecisionProcess
Release 0.2.1
|
PolicyPureVector is a class that represents a pure (=deterministic) policy. More...
#include <PolicyPureVector.h>
Public Member Functions | |
virtual PolicyPureVector * | Clone () const |
Returns a pointer to a copy of this class. | |
Index | GetActionIndex (Index oh) const |
Returns the action (index) this policy specifies for a particular domain index. | |
LIndex | GetIndex () const |
Get the index of this policy. | |
bool | Increment () |
Increments the policy, used to iterate over policies. | |
bool | operator++ () |
Performs increment. See Increment(). | |
virtual PolicyPureVector & | operator= (const PolicyPureVector &o) |
PolicyPureVector (const Interface_ProblemToPolicyDiscretePure &pu, Index agentI, PolicyGlobals::IndexDomainCategory idc, size_t depth=MAXHORIZON) | |
Alternate constructor. | |
PolicyPureVector (const PolicyPureVector &a) | |
Copy constructor. | |
void | RandomInitialization () |
Randomly initialize the policy. | |
void | RandomInitialization (Index agentI) |
Randomly initialize the policy for agent agentI. | |
void | SetAction (Index ohI, Index aI) |
Sets the policy to map ohI->aI. | |
void | SetDepth (size_t d) |
Sets the number of time steps for which this policy is valid. | |
void | SetIndex (LIndex i) |
Sets the index of this policy. Updates the policy represented. | |
std::string | SoftPrint () const |
Prints a description of this PolicyPureVector to a string. | |
void | ZeroInitialization () |
Initialize the policy to the first policy. | |
virtual | ~PolicyPureVector () |
Destructor. | |
![]() | |
double | GetActionProb (Index i, Index aI) const |
Returns the probability that the policy specifies action aI for domain index i. | |
const Interface_ProblemToPolicyDiscretePure * | GetInterfacePTPDiscretePure () const |
Return pointer to the Interface_ProblemToPolicyDiscretePure. | |
PolicyDiscretePure (const Interface_ProblemToPolicyDiscretePure &pu, PolicyGlobals::IndexDomainCategory idc, Index agentI) | |
(default) Constructor | |
PolicyDiscretePure (const PolicyDiscretePure &a) | |
Copy constructor. | |
virtual | ~PolicyDiscretePure () |
Destructor. | |
![]() | |
IndexDomainCategory | GetIndexDomainCategory () const |
Returns the Category of the domain over which the indices of this policy are specified. | |
const Interface_ProblemToPolicyDiscrete * | GetInterfacePTPDiscrete () const |
return a pointer to the referred Interface_ProblemToPolicyDiscrete. | |
PolicyDiscrete (const Interface_ProblemToPolicyDiscrete &iptpd, PolicyGlobals::IndexDomainCategory idc, Index agentI) | |
(default) Constructor | |
PolicyDiscrete (const PolicyDiscrete &a) | |
Copy constructor. | |
Index | SampleAction (Index i) const |
samples an action for domain index i. | |
void | SetIndexDomainCategory (IndexDomainCategory idc) |
Sets the category of the domain over which the indices of this policy are specified. | |
virtual | ~PolicyDiscrete () |
Destructor. | |
![]() | |
size_t | GetDepth () const |
Returns the depth of the policy. | |
Policy (Index agentI) | |
Constructor, initializes the depth to the maximum horizon. | |
virtual void | Print () const |
Prints a description of a policy to cout. | |
virtual | ~Policy () |
Destructor. |
Protected Attributes | |
Index | _m_agentI |
The index of the agent to which this policy belongs. | |
std::vector< Index > | _m_domainToActionIndices |
The vector that stores the action indices for each observation history. |
PolicyPureVector is a class that represents a pure (=deterministic) policy.
The implementation of this particular class is based on a vector of length nrObservation-histories, that specifies an action index for each observation history index. Also a policy PolicyPureVector is a Referrer to an object that implements the functions defined by the Interface_ProblemToPolicyDiscretePure (for example a planning unit or Bayesian game).
TODO: the class was not designed with partial policies in mind.
Definition at line 52 of file PolicyPureVector.h.
PolicyPureVector::PolicyPureVector | ( | const Interface_ProblemToPolicyDiscretePure & | pu, |
Index | agentI, | ||
PolicyGlobals::IndexDomainCategory | idc, | ||
size_t | depth = MAXHORIZON |
||
) |
Alternate constructor.
Associates a problem and agent with the policy . Information regarding the problem is used to construct a policy of the proper shape.
Definition at line 38 of file PolicyPureVector.cpp.
References _m_agentI, _m_domainToActionIndices, DEBUG_PPV, PolicyDiscrete::GetIndexDomainCategory(), and PolicyDiscretePure::GetInterfacePTPDiscretePure().
Referenced by Clone().
PolicyPureVector::PolicyPureVector | ( | const PolicyPureVector & | a | ) |
Copy constructor.
Definition at line 58 of file PolicyPureVector.cpp.
References _m_agentI, _m_domainToActionIndices, and DEBUG_PPV.
|
virtual |
Destructor.
Definition at line 67 of file PolicyPureVector.cpp.
References _m_domainToActionIndices.
|
inlinevirtual |
Returns a pointer to a copy of this class.
Implements PolicyDiscretePure.
Definition at line 127 of file PolicyPureVector.h.
References PolicyPureVector().
|
inlinevirtual |
Returns the action (index) this policy specifies for a particular domain index.
Implements PolicyDiscretePure.
Definition at line 123 of file PolicyPureVector.h.
References _m_domainToActionIndices.
LIndex PolicyPureVector::GetIndex | ( | ) | const |
Get the index of this policy.
Definition at line 140 of file PolicyPureVector.cpp.
References _m_agentI, _m_domainToActionIndices, Policy::GetDepth(), PolicyDiscrete::GetIndexDomainCategory(), PolicyDiscretePure::GetInterfacePTPDiscretePure(), Interface_ProblemToPolicyDiscrete::GetNrActions(), and IndexTools::IndividualToJointIndices().
bool PolicyPureVector::Increment | ( | ) |
Increments the policy, used to iterate over policies.
Policies are enumerable. This function changes a policy to the one with the next IndexValue. Returns true when increment changes to policy number from nrPolicies-1 to 0 (carry over signal).
Definition at line 116 of file PolicyPureVector.cpp.
References _m_agentI, _m_domainToActionIndices, Policy::GetDepth(), PolicyDiscrete::GetIndexDomainCategory(), PolicyDiscretePure::GetInterfacePTPDiscretePure(), and Interface_ProblemToPolicyDiscrete::GetNrActions().
Referenced by operator++().
|
inline |
Performs increment. See Increment().
Definition at line 82 of file PolicyPureVector.h.
References Increment().
|
virtual |
Definition at line 72 of file PolicyPureVector.cpp.
References _m_agentI, and _m_domainToActionIndices.
void PolicyPureVector::RandomInitialization | ( | ) |
Randomly initialize the policy.
Definition at line 96 of file PolicyPureVector.cpp.
References _m_agentI, _m_domainToActionIndices, DEBUG_PPV, PolicyDiscretePure::GetInterfacePTPDiscretePure(), and Interface_ProblemToPolicyDiscrete::GetNrActions().
Referenced by RandomInitialization(), and JPolComponent_VectorImplementation::RandomInitialization().
|
inlinevirtual |
Randomly initialize the policy for agent agentI.
Implements PolicyDiscretePure.
Definition at line 98 of file PolicyPureVector.h.
References _m_agentI, and RandomInitialization().
|
inline |
Sets the policy to map ohI->aI.
Definition at line 116 of file PolicyPureVector.h.
References _m_domainToActionIndices.
Referenced by DICEPSPlanner::SampleIndividualPolicy(), and SetIndex().
|
virtual |
Sets the number of time steps for which this policy is valid.
Reimplemented from Policy.
Definition at line 187 of file PolicyPureVector.cpp.
References _m_agentI, _m_domainToActionIndices, PolicyDiscrete::GetIndexDomainCategory(), and PolicyDiscretePure::GetInterfacePTPDiscretePure().
void PolicyPureVector::SetIndex | ( | LIndex | i | ) |
Sets the index of this policy. Updates the policy represented.
Definition at line 165 of file PolicyPureVector.cpp.
References _m_agentI, Policy::GetDepth(), PolicyDiscrete::GetIndexDomainCategory(), PolicyDiscretePure::GetInterfacePTPDiscretePure(), Interface_ProblemToPolicyDiscrete::GetNrActions(), IndexTools::JointToIndividualIndices(), and SetAction().
|
virtual |
Prints a description of this PolicyPureVector to a string.
Implements Policy.
Definition at line 197 of file PolicyPureVector.cpp.
References _m_agentI, _m_domainToActionIndices, PolicyDiscrete::GetIndexDomainCategory(), PolicyDiscretePure::GetInterfacePTPDiscretePure(), Interface_ProblemToPolicyDiscrete::SoftPrintAction(), and Interface_ProblemToPolicyDiscrete::SoftPrintPolicyDomainElement().
void PolicyPureVector::ZeroInitialization | ( | ) |
Initialize the policy to the first policy.
This is the policy that specifies action 0 –the first action– for all observation histories.
Definition at line 82 of file PolicyPureVector.cpp.
References _m_agentI, _m_domainToActionIndices, and DEBUG_PPV.
Referenced by JPolComponent_VectorImplementation::ZeroInitialization().
|
protected |
The index of the agent to which this policy belongs.
Definition at line 58 of file PolicyPureVector.h.
Referenced by GetIndex(), Increment(), operator=(), PolicyPureVector(), RandomInitialization(), SetDepth(), SetIndex(), SoftPrint(), and ZeroInitialization().
|
protected |
The vector that stores the action indices for each observation history.
Definition at line 61 of file PolicyPureVector.h.
Referenced by GetActionIndex(), GetIndex(), Increment(), operator=(), PolicyPureVector(), RandomInitialization(), SetAction(), SetDepth(), SoftPrint(), ZeroInitialization(), and ~PolicyPureVector().