43 throw std::invalid_argument(
"Unable to procees loading. OCM: number of slots must be > 0.");
53 throw std::invalid_argument(
"Unable to procees loading. Divergent number of slots between the OCM distributions.");
63 for(
unsigned int i = 0; i <
mEvaluators.size(); i++)
70 std::stringstream objs;
71 for(
unsigned int i = 0; i < pEvidenceList.size(); i++)
73 objs << pEvidenceList[i].type;
75 if(i < pEvidenceList.size() - 1)
80 ROS_INFO_STREAM(
" > There are '" << pEvidenceList.size() <<
"' objects: " << objs.str() <<
".");
97 unsigned int numberOfEvidence = pEvidenceList.size() + 1;
98 unsigned int numberOfHypotheses = pow(numberOfEvidence,
mNumberOfSlots);
99 unsigned int numberOfValidHypotheses = 0;
102 unsigned int sumOfFilledSlots = 0;
105 for(
unsigned int h = 0; h < numberOfHypotheses; h++)
108 bool dropped =
false;
111 unsigned int numberOfFilledSlots = 0;
114 std::vector<unsigned int> assignments;
120 unsigned int part = (h / ((
unsigned int) pow(numberOfEvidence,
s)) ) % numberOfEvidence;
124 numberOfFilledSlots++;
127 if(
std::find(assignments.begin(), assignments.end(), part) != assignments.end())
132 assignments.push_back(part);
136 if(assignments[0] == 0)
143 std::stringstream msgResult;
144 msgResult <<
"Assignment (";
147 for(
unsigned int i = 0; i < assignments.size(); i++)
149 if(assignments[i] == 0)
152 msgResult << pEvidenceList[assignments[i] - 1].type;
155 if(i < assignments.size() - 1)
160 msgResult <<
") generates results (";
167 for(
unsigned int i = 0; i <
mEvaluators.size(); i++)
170 double termScore =
mEvaluators[i]->calculateProbabilityForHypothesis(pEvidenceList, assignments);
176 msgResult << termScore;
187 msgResult <<
"). Hypothesis probability is '" << hValue <<
"'.";
194 hValue *= numberOfFilledSlots;
204 if(hValue > std::numeric_limits<double>::epsilon())
206 numberOfValidHypotheses++;
207 sumOfFilledSlots += numberOfFilledSlots;
211 ROS_DEBUG_STREAM(
"THERE ARE " << numberOfValidHypotheses <<
" hypotheses larger than zero.");
215 if(numberOfValidHypotheses > 0)
218 mVisualizer->normalizeHypothesisScore(sumOfFilledSlots);
223 evaluator->visualize(pEvidenceList);
boost::shared_ptr< Visualization::ProbabilisticPrimarySceneObjectVisualization > mVisualizer
bool find(const std::vector< double > &in, double toFind)
void load(boost::property_tree::ptree &pPt)
std::vector< boost::shared_ptr< TermEvaluator > > mEvaluators
void update(std::vector< ISM::Object > pEvidenceList)
void initializeVisualizer(boost::shared_ptr< Visualization::ProbabilisticPrimarySceneObjectVisualization > mSuperior)
#define ROS_DEBUG_STREAM(args)
#define ROS_INFO_STREAM(args)
unsigned int mNumberOfSlots
void setBestStatus(bool pStatus)
double getSceneObjectProbability()