PowerSetForegroundInferenceAlgorithm.cpp
Go to the documentation of this file.
1 
19 
21 
23  : ForegroundInferenceAlgorithm(pSceneObjects)
24  , mProbability(0.0)
25  {
26  }
27 
29  {
30  }
31 
32  void PowerSetForegroundInferenceAlgorithm::doInference(std::vector<ISM::Object> pEvidenceList, std::ofstream& pRuntimeLogger)
33  {
34  // Reset the scene probability. We MARGINALZE here, so we set it to ZERO.
35  mProbability = 0.0;
36 
37  // The number of all hypotheses.
38  unsigned int numberOfHypotheses = 0;
39 
40  ROS_INFO_STREAM("Evaluating primary scene objects.");
41 
42  // Update the scene objects with the new evidence.
43  // This is done before iterating over the probabilities, because it has high costs and must be done only once.
44  for(unsigned int i = 0; i < mSceneObjects->size(); i++)
45  mSceneObjects->at(i)->update(pEvidenceList, pRuntimeLogger);
46 
47  ROS_INFO_STREAM("Iterating over existence hypothesis.");
48 
49  // We iterate over the power set over the scene objects.
50  for(unsigned int i = 1; i < ((unsigned int) 1 << mSceneObjects->size()); ++i)
51  {
52  // String containing the subset for debugging.
53  std::string subset;
54 
55  // The score for this subset. We MULTIPLY the scene object scores, to we initialize it with ONE.
56  double hypothesisProbability = 1.0;
57 
58  // Here we determine and the subset of the power set and build the debug message string.
59  for(unsigned int j = 0; j < mSceneObjects->size(); ++j)
60  {
61  // Is element in subset?
62  if((1 << j) & i)
63  {
64  // Add the current subset number to the debug message string.
65  subset += "(" + mSceneObjects->at(j)->getDescription() + ") ";
66  }
67  }
68 
69  // Here we determine and evaluate the subset of the power set.
70  for(unsigned int j = 0; j < mSceneObjects->size(); ++j)
71  {
72  // Is element in subset?
73  if((1 << j) & i)
74  {
75  // Update score.
76  hypothesisProbability *= mSceneObjects->at(j)->getSceneObjectProbability() * mSceneObjects->at(j)->getSceneObjectPriori();
77  ROS_INFO_STREAM(" > Multiplying with subset score: '" << mSceneObjects->at(j)->getSceneObjectProbability() << "' with priori '" << mSceneObjects->at(j)->getSceneObjectPriori() << "'.");
78  }
79  }
80 
81  // Debug message.
82  ROS_INFO_STREAM(" > Score for scene object subset '" << subset << "' is '" << hypothesisProbability << "'.");
83 
84  // Add hypothesis to scene probability. We score the empty subset with zero.
85  if(i > 0)
86  mProbability += hypothesisProbability;
87 
88  // +1 for the number of hypotheses.
89  numberOfHypotheses++;
90  }
91 
92  // Apply normalization term by dividing by the number of all hypotheses.
93  mProbability /= numberOfHypotheses;
94  }
95 
97  {
98  return mProbability;
99  }
100 
101 }
PowerSetForegroundInferenceAlgorithm(boost::shared_ptr< std::vector< boost::shared_ptr< SceneObjectDescription > > > &pSceneObjects)
void doInference(std::vector< ISM::Object > pEvidenceList, std::ofstream &pRuntimeLogger)
#define ROS_INFO_STREAM(args)
boost::shared_ptr< std::vector< boost::shared_ptr< SceneObjectDescription > > > mSceneObjects


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