AIToolbox
A library that offers tools for AI problem solving.
TypeTraits.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_MDP_TYPE_TRAITS_HEADER_FILE
2 #define AI_TOOLBOX_MDP_TYPE_TRAITS_HEADER_FILE
3 
6 
7 namespace AIToolbox::MDP {
26  template <typename M>
27  concept IsGenerativeModel = AIToolbox::IsGenerativeModel<M> &&
28  HasIntegralStateSpace<M> &&
29  HasIntegralActionSpace<M> &&
30  HasFixedActionSpace<M>;
31 
46  template <typename M>
47  concept IsModel = IsGenerativeModel<M> && requires (const M m, size_t s, size_t a) {
48  { m.getTransitionProbability(s, a, s) } -> std::convertible_to<double>;
49  { m.getExpectedReward(s, a, s) } -> std::convertible_to<double>;
50  };
51 
68  template <typename M>
69  concept IsModelEigen = IsModel<M> && requires (const M m, size_t a) {
70  m.getTransitionFunction(a);
71  requires IsDerivedFromEigen<std::remove_cvref_t<decltype((m.getTransitionFunction(a)))>>;
72 
73  m.getRewardFunction();
74  requires IsDerivedFromEigen<std::remove_cvref_t<decltype((m.getRewardFunction()))>>;
75  };
76 
91  template <typename E>
92  concept IsExperience = requires (const E e, size_t s, size_t a) {
93  { e.getVisits(s, a, s) } -> std::convertible_to<long unsigned>;
94  { e.getVisitsSum(s, a) } -> std::convertible_to<long unsigned>;
95  { e.getReward(s, a) } -> std::convertible_to<double>;
96  { e.getM2(s, a) } -> std::convertible_to<double>;
97  };
98 
117  template <typename E>
118  concept IsExperienceEigen = IsExperience<E> && requires (const E e, size_t a) {
119  e.getVisitsSumTable();
120  requires IsDerivedFromEigen<std::remove_cvref_t<decltype((e.getVisitsSumTable()))>>;
121 
122  e.getVisitsTable(a);
123  requires IsDerivedFromEigen<std::remove_cvref_t<decltype((e.getVisitsTable(a)))>>;
124 
125  e.getRewardMatrix();
126  requires IsDerivedFromEigen<std::remove_cvref_t<decltype((e.getRewardMatrix()))>>;
127 
128  e.getM2Matrix();
129  requires IsDerivedFromEigen<std::remove_cvref_t<decltype((e.getM2Matrix()))>>;
130  };
131 }
132 
133 #endif
AIToolbox::MDP::IsGenerativeModel
concept IsGenerativeModel
This concept represents the required interface for a generative MDP.
Definition: TypeTraits.hpp:27
AIToolbox::MDP::IsModel
concept IsModel
This concept represents the required interface for a full MDP model.
Definition: TypeTraits.hpp:47
AIToolbox::MDP::IsExperienceEigen
concept IsExperienceEigen
This concept represents the required Experience interface that allows leverage Eigen.
Definition: TypeTraits.hpp:118
AIToolbox::MDP
Definition: DoubleQLearning.hpp:10
TypeTraits.hpp
AIToolbox::IsDerivedFromEigen
concept IsDerivedFromEigen
This concept simplifies checking for non-void.
Definition: TypeTraits.hpp:66
AIToolbox::MDP::IsExperience
concept IsExperience
This concept represents the required interface for an experience recorder.
Definition: TypeTraits.hpp:92
Types.hpp
AIToolbox::MDP::IsModelEigen
concept IsModelEigen
This concept represents the required interface that allows MDP algorithms to leverage Eigen.
Definition: TypeTraits.hpp:69