AIToolbox
A library that offers tools for AI problem solving.
BayesianNetwork.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_FACTORED_UTILS_BAYESIAN_NETWORK_HEADER_FILE
2 #define AI_TOOLBOX_FACTORED_UTILS_BAYESIAN_NETWORK_HEADER_FILE
3 
7 
8 namespace AIToolbox::Factored {
53  public:
57  struct ParentSet {
59  std::vector<PartialKeys> features;
60  };
61 
76 
89  void push(ParentSet parents);
90 
102  size_t getId(size_t feature, const State & s, const Action & a) const;
103 
115  size_t getId(size_t feature, const PartialState & s, const PartialAction & a) const;
116 
129  size_t getId(size_t feature, size_t parentId, size_t actionId) const;
130 
154  std::pair<size_t, size_t> getIds(size_t feature, const State & s, const Action & a) const;
155 
179  std::pair<size_t, size_t> getIds(size_t feature, const PartialState & s, const PartialAction & a) const;
180 
195  std::pair<size_t, size_t> getIds(size_t feature, size_t j) const;
196 
211  size_t getSize(size_t feature) const;
212 
222  size_t getPartialSize(size_t feature) const;
223 
234  size_t getPartialSize(size_t feature, size_t actionId) const;
235 
241  const State & getS() const;
242 
248  const Action & getA() const;
249 
255  const std::vector<ParentSet> & getParentSets() const;
256 
257  private:
258  State S;
259  Action A;
260  std::vector<ParentSet> parents_;
261  std::vector<std::vector<size_t>> startIds_;
262  };
263 
265 
276  using TransitionMatrix = std::vector<Matrix2D>;
277 
287  double getTransitionProbability(const State & s, const Action & a, const State & s1) const;
288 
302  double getTransitionProbability(const PartialState & s, const PartialAction & a, const PartialState & s1) const;
303 
304  const DDNGraph & graph;
306  };
307 
309 
310  BasisMatrix backProject(const DDN & ddn, const BasisFunction & bf);
311  FactoredMatrix2D backProject(const DDN & ddn, const FactoredVector & fv);
312 }
313 
314 #endif
AIToolbox::Factored::DynamicDecisionNetworkGraph::getIds
std::pair< size_t, size_t > getIds(size_t feature, const State &s, const Action &a) const
This function computes an action and parent ids for the input state, action and feature.
AIToolbox::Factored::PartialKeys
std::vector< size_t > PartialKeys
Definition: Types.hpp:63
AIToolbox::Factored::FactoredVector
This class represents a factored vector.
Definition: FactoredMatrix.hpp:60
AIToolbox::Factored::BasisMatrix
This struct represents a basis matrix.
Definition: FactoredMatrix.hpp:128
AIToolbox::Factored::PartialState
PartialFactors PartialState
Definition: Types.hpp:68
AIToolbox::Factored::DynamicDecisionNetwork::graph
const DDNGraph & graph
Definition: BayesianNetwork.hpp:304
AIToolbox::Factored::DynamicDecisionNetworkGraph::push
void push(ParentSet parents)
This function adds a ParentSet to the graph.
AIToolbox::Factored::State
Factors State
Definition: Types.hpp:67
AIToolbox::Factored::FactoredMatrix2D
This class represents a factored 2D matrix.
Definition: FactoredMatrix.hpp:140
AIToolbox::Factored::DynamicDecisionNetworkGraph::ParentSet
This class contains the parent information for a single next-state feature.
Definition: BayesianNetwork.hpp:57
AIToolbox::Factored::PartialAction
PartialFactors PartialAction
Definition: Types.hpp:70
FactoredMatrix.hpp
AIToolbox::Factored::DynamicDecisionNetwork::transitions
TransitionMatrix transitions
Definition: BayesianNetwork.hpp:305
AIToolbox::Factored::DynamicDecisionNetworkGraph::DynamicDecisionNetworkGraph
DynamicDecisionNetworkGraph(State S, Action A)
Basic constructor.
AIToolbox::Factored::DynamicDecisionNetwork::TransitionMatrix
std::vector< Matrix2D > TransitionMatrix
Definition: BayesianNetwork.hpp:276
Core.hpp
AIToolbox::Factored::DynamicDecisionNetworkGraph::getA
const Action & getA() const
This function returns the action space of the DDNGraph.
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::BasisFunction
This struct represents a basis function.
Definition: FactoredMatrix.hpp:32
AIToolbox::Factored::DynamicDecisionNetwork
This class represents a Dynamic Decision Network with factored actions.
Definition: BayesianNetwork.hpp:275
AIToolbox::Factored::DynamicDecisionNetworkGraph::ParentSet::agents
PartialKeys agents
Definition: BayesianNetwork.hpp:58
AIToolbox::Factored::Action
Factors Action
Definition: Types.hpp:69
AIToolbox::Factored::DynamicDecisionNetwork::getTransitionProbability
double getTransitionProbability(const State &s, const Action &a, const State &s1) const
This function returns the probability of a transition from one state to another with the given action...
AIToolbox::Factored::backProject
BasisMatrix backProject(const DDN &ddn, const BasisFunction &bf)
AIToolbox::Factored::DynamicDecisionNetworkGraph::getId
size_t getId(size_t feature, const State &s, const Action &a) const
This function computes an id for the input state and action, for the specified feature.
AIToolbox::Factored::DynamicDecisionNetworkGraph::getParentSets
const std::vector< ParentSet > & getParentSets() const
This function returns the internal parent sets of the DDNGraph.
AIToolbox::Factored::DynamicDecisionNetworkGraph::getS
const State & getS() const
This function returns the state space of the DDNGraph.
AIToolbox::Factored::DynamicDecisionNetworkGraph::getPartialSize
size_t getPartialSize(size_t feature) const
Thus function returns the number of possible values of the parent agents of the feature.
AIToolbox::Factored::DynamicDecisionNetworkGraph::getSize
size_t getSize(size_t feature) const
This function returns the size required to store one element per value of a parent set.
AIToolbox::Factored::DynamicDecisionNetworkGraph::ParentSet::features
std::vector< PartialKeys > features
Definition: BayesianNetwork.hpp:59