AIToolbox
A library that offers tools for AI problem solving.
|
Go to the documentation of this file. 1 #ifndef AI_TOOLBOX_MDP_SPARSE_EXPERIENCE_HEADER_FILE
2 #define AI_TOOLBOX_MDP_SPARSE_EXPERIENCE_HEADER_FILE
58 template <IsNaive3DTable V>
97 template <IsNaive2DMatrix R>
133 template <IsNaive2DMatrix MM>
163 void record(
size_t s,
size_t a,
size_t s1,
double rew);
184 unsigned long getVisits(
size_t s,
size_t a,
size_t s1)
const;
200 double getReward(
size_t s,
size_t a)
const;
208 double getM2(
size_t s,
size_t a)
const;
270 unsigned long timesteps_;
275 template <IsNaive3DTable V>
277 for (
size_t a = 0; a < A; ++a )
278 visits_[a].setZero();
279 visitsSum_.setZero();
281 for (
size_t s = 0; s < S; ++s )
282 for (
size_t a = 0; a < A; ++a )
283 for (
size_t s1 = 0; s1 < S; ++s1 )
284 if ( v[s][a][s1] > 0 ) {
285 visits_[a].insert(s, s1) = v[s][a][s1];
286 visitsSum_.coeffRef(s, a) += v[s][a][s1];
289 for (
size_t a = 0; a < A; ++a )
290 visits_[a].makeCompressed();
291 visitsSum_.makeCompressed();
294 template <IsNaive2DMatrix R>
298 for (
size_t s = 0; s < S; ++s )
299 for (
size_t a = 0; a < A; ++a )
301 rewards_.insert(s, a) = r[s][a];
303 rewards_.makeCompressed();
306 template <IsNaive2DMatrix MM>
310 for (
size_t s = 0; s < S; ++s )
311 for (
size_t a = 0; a < A; ++a )
313 M2s_.insert(s, a) = mm[s][a];
315 M2s_.makeCompressed();