| AIToolbox
    A library that offers tools for AI problem solving. | 
 
 
 
Go to the documentation of this file.    1 #ifndef AI_TOOLBOX_FACTORED_MDP_GRAPH_UTILS_HEADER_FILE 
    2 #define AI_TOOLBOX_FACTORED_MDP_GRAPH_UTILS_HEADER_FILE 
   39     template <
typename Maximizer, 
typename Data>
 
   45     template <
typename Maximizer, 
typename Data>
 
   63     template <
typename Maximizer>
 
   65         template <
typename Data, 
typename... Args>
 
   84     template <
typename Maximizer>
 
   86         template <
typename Data, 
typename... Args>
 
   87         void operator()(
typename Maximizer::Graph & graph, 
const Data & d, Args && ...args) {
 
   96     template <
typename Data>
 
   99     template <MDP::QFRuleRange Iterable>
 
  113             graph.
reset(A.size());
 
  115             for (
const auto & basis : qf.
bases) {
 
  116                 const auto Ai = 
static_cast<size_t>(basis.values.cols());
 
  118                 auto & factorNode = graph.
getFactor(basis.actionTag)->getData();
 
  120                 if (factorNode.empty()) {
 
  121                     factorNode.reserve(Ai);
 
  122                     for (
size_t ai = 0; ai < Ai; ++ai)
 
  123                         factorNode.emplace_back(ai, 
VE::Factor{0.0, {}});
 
  127                 for (
size_t ai = 0; ai < Ai; ++ai)
 
  128                     factorNode[ai].second.first += basis.values(si, ai);
 
  137     template <MDP::QFRuleRange Iterable>
 
  145             for (
const auto & basis : qf.
bases) {
 
  146                 auto & factorNode = graph.
getFactor(basis.actionTag)->getData();
 
  148                 if (!factorNode.size())
 
  149                     factorNode.resize(basis.values.cols());
 
  156     template <MDP::QFRuleRange Iterable>
 
  168             for (
auto & f : graph)
 
  169                 f.getData().setZero();
 
  171             for (
const auto & basis : qf.
bases) {
 
  173                 graph.getFactor(basis.actionTag)->getData() += basis.values.row(si);
 
  182     template <> 
struct MakeGraph<Bandit::ReusingIterativeLocalSearch> : 
MakeGraph<Bandit::LocalSearch> {};