AIToolbox
A library that offers tools for AI problem solving.
|
Go to the documentation of this file. 1 #ifndef AI_TOOLBOX_POMDP_PERSEUS_HEADER_FILE
2 #define AI_TOOLBOX_POMDP_PERSEUS_HEADER_FILE
47 PERSEUS(
size_t nBeliefs,
unsigned h,
double tolerance);
124 std::tuple<double, ValueFunction>
operator()(
const M & model,
double minReward);
148 template <
typename ProjectionsTable>
149 VList crossSum(
const ProjectionsTable & projs,
const std::vector<Belief> & bl,
const VList & oldV);
151 size_t S, A, O, beliefSize_;
160 if ( model.getDiscount() == 1 )
throw std::invalid_argument(
"The model cannot have a discount of 1 in PERSEUS!");
173 const auto beliefs = bGen(beliefSize_);
178 v[0][0].values.fill(minReward / (1.0 - model.getDiscount()));
180 unsigned timestep = 0;
186 double variation = tolerance_ * 2;
187 while ( timestep < horizon_ && ( !useTolerance || variation > tolerance_ ) ) {
193 const auto projs = projecter(v[timestep-1]);
196 v.emplace_back( crossSum( projs, beliefs, v[timestep-1] ) );
203 return std::make_tuple(useTolerance ? variation : 0.0, v);
206 template <
typename ProjectionsTable>
207 VList PERSEUS::crossSum(
const ProjectionsTable & projs,
const std::vector<Belief> & bl,
const VList & oldV) {
208 VList result, helper;
209 result.reserve(bl.size());
212 double currentValue, oldValue;
214 auto rbegin = std::begin(result);
215 auto rend = std::end (result);
216 const auto obegin = std::begin(oldV);
217 const auto oend = std::end (oldV);
219 for (
const auto & b : bl ) {
224 if ( currentValue >= oldValue )
continue;
229 rbegin = std::begin(result);
230 rend = std::end (result);