mdp_policy.h
Go to the documentation of this file.
00001 
00025 #ifndef _MDP_POLICY_H_
00026 #define _MDP_POLICY_H_
00027 
00028 #include <boost/random/mersenne_twister.hpp>
00029 #include <boost/random/discrete_distribution.hpp>
00030 
00031 #include <mdm_library/common_defs.h>
00032 
00033 namespace mdm_library
00034 {
00035 class MDPPolicy
00036 {
00037 public:
00040     virtual uint32_t getAction ( uint32_t index ) = 0;
00041 
00042     uint32_t operator[] ( uint32_t index )
00043     {
00044         return getAction ( index );
00045     }
00046 };
00047 
00048 class MDPPolicyVector : public MDPPolicy
00049 {
00050 public:
00051     MDPPolicyVector ( IndexVectorPtr p_ptr ) :
00052         policy_vec_ptr_ ( p_ptr ){}
00053 
00054 protected:
00055     virtual uint32_t getAction ( uint32_t index )
00056     {
00057         return ( *policy_vec_ptr_ ) [index];
00058     }
00059 
00060 private:
00061     IndexVectorPtr policy_vec_ptr_;
00062 };
00063 
00064 class MDPPolicyMatrix : public MDPPolicy
00065 {
00066 public:
00067     MDPPolicyMatrix ( MatrixPtr m_ptr ) :
00068         policy_matrix_ptr_ ( m_ptr ),
00069         gen_ ()
00070     {}
00071 
00072 protected:
00073     virtual uint32_t getAction ( uint32_t index )
00074     {
00075         boost::numeric::ublas::matrix_column<Matrix> mc( *policy_matrix_ptr_, index );
00076         boost::random::discrete_distribution<> dist(mc);
00077         return dist(gen_); 
00078     }
00079 
00080 private:
00081     MatrixPtr policy_matrix_ptr_;
00082     boost::mt19937 gen_;
00083 };
00084 }
00085 
00086 #endif


mdm_library
Author(s): Joao Messias
autogenerated on Wed Aug 26 2015 12:28:41