AIToolbox
A library that offers tools for AI problem solving.
CPSQueue.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_FACTORED_CPS_QUEUE_HEADER_FILE
2 #define AI_TOOLBOX_FACTORED_CPS_QUEUE_HEADER_FILE
3 
4 #include <random>
8 
9 namespace AIToolbox::Factored {
25  class CPSQueue {
26  public:
36  CPSQueue(const DDNGraph & graph);
37 
53  void update(size_t i, size_t a, size_t s, double p);
54 
77  void reconstruct(State & s, Action & a);
78 
86  double getNodeMaxPriority(size_t i) const;
87 
96  unsigned getNonZeroPriorities() const;
97 
98  private:
99  const DDNGraph & graph_;
100  unsigned nonZeroPriorities_;
101 
102  std::vector<size_t> order_;
103 
104  struct ActionNode {
105  Vector priorities;
106  double maxV;
107  size_t maxS;
108  };
109  struct Node {
110  double maxV;
111  size_t maxA;
112  std::vector<size_t> order;
113  std::vector<ActionNode> nodes;
114  };
115 
116  std::vector<Node> nodes_;
117 
118  mutable std::ranlux24_base rand_; // Fastest engine possible, don't care about quality
119  };
120 }
121 
122 #endif
AIToolbox::Factored::CPSQueue::getNonZeroPriorities
unsigned getNonZeroPriorities() const
This function returns how many non-zero priority parent sets there are.
AIToolbox::Factored::CPSQueue::reconstruct
void reconstruct(State &s, Action &a)
This function sets the input State and Action with the highest priority combination.
AIToolbox::Factored::State
Factors State
Definition: Types.hpp:67
AIToolbox::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
Definition: Types.hpp:16
BayesianNetwork.hpp
Core.hpp
AIToolbox::Factored::CPSQueue::CPSQueue
CPSQueue(const DDNGraph &graph)
Basic constructor.
AIToolbox::Factored::DynamicDecisionNetworkGraph
This class represents the structure of a dynamic decision network.
Definition: BayesianNetwork.hpp:52
AIToolbox::Factored
Definition: GraphUtils.hpp:12
Types.hpp
AIToolbox::Factored::CPSQueue::update
void update(size_t i, size_t a, size_t s, double p)
This function updates the probability of the input parent set.
AIToolbox::Factored::CPSQueue
This class is used as the priority queue for CooperativePrioritizedSweeping.
Definition: CPSQueue.hpp:25
AIToolbox::Factored::Action
Factors Action
Definition: Types.hpp:69
AIToolbox::Factored::CPSQueue::getNodeMaxPriority
double getNodeMaxPriority(size_t i) const
This function returns the priority of the highest parent set of the selected node.