ConditionalProbability.cpp
Go to the documentation of this file.
1 
19 
21 
23 { }
24 
26 { }
27 
28 void ConditionalProbability::setProbability(std::string pParentId, double pProbability)
29 {
30  if (mWasRead) throw std::runtime_error("In ConditionalProbability::setProbability(" + pParentId + ", "
31  + std::to_string(pProbability) + "): trying to add to a probability that has already been read.");
32  mParentProbabilities[pParentId] = pProbability; // overwrites older probabilities.
33 }
34 
36 {
37  mWasRead = true;
38 
39  // to increase speed: if there is only one parent anyways, return its probability immediately.
40  if (mParentProbabilities.size() == 1)
41  return mParentProbabilities.begin()->second;
42 
43  if (mParentProbabilities.empty())
44  throw std::runtime_error("In MinimumConditionalProbability::getProbability(): trying to access probability that has not been set.");
45 
46  return calculateProbability();
47 }
48 
50 {
51  std::string result;
52  for (std::pair<std::string, double> parentProbability: mParentProbabilities)
53  result += "(" + parentProbability.first + ", " + std::to_string(parentProbability.second) + ")";
54  return result;
55 }
56 
57 }
58 
void setProbability(std::string pParentId, double pProbability)


asr_psm
Author(s): Braun Kai, Gehrung Joachim, Heizmann Heinrich, Meißner Pascal
autogenerated on Fri Nov 15 2019 03:57:54