AIToolbox
A library that offers tools for AI problem solving.
|
Go to the documentation of this file. 1 #ifndef AI_TOOLBOX_POMDP_PBVI_HEADER_FILE
2 #define AI_TOOLBOX_POMDP_PBVI_HEADER_FILE
56 PBVI(
size_t nBeliefs,
unsigned h,
double tolerance);
160 std::tuple<double, ValueFunction>
operator()(
const M & model,
const std::vector<Belief> & beliefs,
ValueFunction v = {});
182 template <
typename ProjectionsRow>
183 VList crossSum(
const ProjectionsRow & projs,
size_t a,
const std::vector<Belief> & bl);
185 size_t S, A, O, beliefSize_;
201 return operator()(model, bGen(beliefSize_), v);
214 unsigned timestep = 0;
220 double variation = tolerance_ * 2;
221 while ( timestep < horizon_ && ( !useTolerance || variation > tolerance_ ) ) {
228 auto projs = projecter(v.back());
230 size_t finalWSize = 0;
235 for (
size_t a = 0; a < A; ++a ) {
236 projs[a][0] = crossSum( projs[a], a, beliefs );
237 finalWSize += projs[a][0].size();
240 w.reserve(finalWSize);
242 for (
size_t a = 0; a < A; ++a )
243 w.insert(std::end(w), std::make_move_iterator(std::begin(projs[a][0])), std::make_move_iterator(std::end(projs[a][0])));
245 auto begin = std::begin(w);
246 auto end = std::end(w);
248 for (
const auto & belief : beliefs )
251 w.erase(bound, std::end(w));
258 v.emplace_back(std::move(w));
265 return std::make_tuple(useTolerance ? variation : 0.0, v);
268 template <
typename ProjectionsRow>
269 VList PBVI::crossSum(
const ProjectionsRow & projs,
const size_t a,
const std::vector<Belief> & bl) {
271 result.reserve(bl.size());
273 for (
const auto & b : bl )
276 const auto rbegin = std::begin(result);
277 const auto rend = std::end (result);