AIToolbox
A library that offers tools for AI problem solving.
|
Go to the documentation of this file. 1 #ifndef AI_TOOLBOX_POMDP_AMDP_HEADER_FILE
2 #define AI_TOOLBOX_POMDP_AMDP_HEADER_FILE
51 AMDP(
size_t nBeliefs,
size_t entropyBuckets);
107 size_t beliefSize_, buckets_;
112 const size_t S = model.getS(), A = model.getA(), O = model.getO();
113 const size_t S1 = S * buckets_;
116 const auto beliefs = bGen(beliefSize_);
122 const auto discretizer = makeDiscretizer(S);
125 for (
const auto & b : beliefs ) {
126 const size_t s = discretizer(b);
128 for (
size_t a = 0; a < A; ++a ) {
131 for (
size_t o = 0; o < O; ++o ) {
133 const auto p = b1.sum();
136 const size_t s1 = discretizer(b1);
145 for (
size_t a = 0; a < A; ++a )
146 for (
size_t s = 0; s < S1; ++s ) {
147 R(s, a) /= T[a].row(s).sum();
149 const double sum = T[a].row(s).sum();
151 else T[a].row(s) /= sum;
154 return std::make_tuple(
MDP::Model(
NO_CHECK, S1, A, std::move(T), std::move(R), model.getDiscount()), std::move(discretizer));
159 const size_t S = model.getS(), A = model.getA(), O = model.getO();
160 const size_t S1 = S * buckets_;
163 const auto beliefs = bGen(beliefSize_);
168 auto discretizer = makeDiscretizer(S);
171 for (
const auto & b : beliefs ) {
172 const size_t s = discretizer(b);
174 for (
size_t a = 0; a < A; ++a ) {
177 for (
size_t o = 0; o < O; ++o ) {
179 const auto p = b1.sum();
182 const size_t s1 = discretizer(b1);
184 T[a].coeffRef(s, s1) += p;
186 R.coeffRef(s, a) += p * r;
192 for (
size_t a = 0; a < A; ++a ) {
193 for (
size_t s = 0; s < S1; ++s ) {
195 R.coeffRef(s, a) /= T[a].row(s).sum();
197 const double sum = T[a].row(s).sum();
199 else T[a].row(s) /= sum;
201 T[a].makeCompressed();
205 return std::make_tuple(
MDP::SparseModel(
NO_CHECK, S1, A, std::move(T), std::move(R), model.getDiscount()), std::move(discretizer));