1 #ifndef AI_TOOLBOX_POMDP_INCREMENTAL_PRUNING_HEADER_FILE
2 #define AI_TOOLBOX_POMDP_INCREMENTAL_PRUNING_HEADER_FILE
117 std::tuple<double, ValueFunction>
operator()(
const M & model);
139 VList crossSum(
const VList & l1,
const VList & l2,
size_t a,
bool order);
155 unsigned timestep = 0;
161 double variation = tolerance_ * 2;
162 while ( timestep < horizon_ && ( !useTolerance || variation > tolerance_ ) ) {
169 auto projs = projecter(v[timestep-1]);
171 size_t finalWSize = 0;
174 for (
size_t a = 0; a < A; ++a ) {
177 for (
size_t o = 0; o < O; ++o ) {
178 const auto begin = std::begin(projs[a][o]);
179 const auto end = std::end (projs[a][o]);
180 projs[a][o].erase(prune(begin, end,
unwrap), end);
206 int i, front = 0, back = O - oddOld, stepsize = 2, diff = 1, elements = O;
207 while ( elements > 1 ) {
208 for ( i = front; i != back; i += stepsize ) {
209 projs[a][i] = crossSum(projs[a][i], projs[a][i + diff], a, stepsize > 0);
210 const auto begin = std::begin(projs[a][i]);
211 const auto end = std::end (projs[a][i]);
212 projs[a][i].erase(prune(begin, end,
unwrap), end);
216 const bool oddNew = elements % 2;
218 const int tmp = back;
219 back = front - ( oddNew ? 0 : stepsize );
220 front = tmp - ( oddOld ? 0 : stepsize );
228 projs[a][0] = std::move(projs[a][front]);
229 finalWSize += projs[a][0].size();
232 w.reserve(finalWSize);
235 for (
size_t a = 0; a < A; ++a )
236 w.insert(std::end(w), std::make_move_iterator(std::begin(projs[a][0])), std::make_move_iterator(std::end(projs[a][0])));
240 const auto begin = std::begin(w);
241 const auto end = std::end (w);
242 w.erase(prune(begin, end,
unwrap), end);
244 v.emplace_back(std::move(w));
251 return std::make_tuple(useTolerance ? variation : 0.0, v);