00001 00060 #ifndef HYPOTHESIS_H_ 00061 #define HYPOTHESIS_H_ 00062 00063 #include <string> 00064 #include <list> 00065 00066 namespace mhf { 00067 00068 class AssignmentSet; 00069 class SemanticObject; 00070 class Assignment; 00071 class ProbabilityModel; 00072 class AssignmentMatrix; 00073 00074 class Hypothesis { 00075 00076 public: 00077 /* CONSTRUCTORS / DESTRUCTORS */ 00078 00079 // Constructor 00080 Hypothesis(const double& global_timestamp, double probability = -1); 00081 00082 // Destructor 00083 virtual ~Hypothesis(); 00084 00085 Hypothesis* clone() const; 00086 00087 00088 /* GETTERS */ 00089 00090 const AssignmentSet* getAssignments() const; 00091 00092 const Hypothesis* getBestLeaf() const; 00093 00094 std::list<Hypothesis*>& getChildHypotheses(); 00095 00096 int getHeight() const; 00097 00098 // returns the number of objects in the hypothesis 00099 int getNumObjects() const; 00100 00101 // returns the list of objects contained in this hypothesis 00102 const std::list<SemanticObject*>& getObjects() const; 00103 00104 //double getObjectProbability(MHTObject* obj) const; 00105 00106 const Hypothesis* getParent() const; 00107 00108 // returns probability of this hypothesis 00109 double getProbability() const; 00110 00111 double getTimestamp() const; 00112 00113 AssignmentMatrix* getAssignmentMatrix() const; 00114 00115 /* SETTERS */ 00116 00117 void setAssignments(AssignmentSet* assignments); 00118 00119 void setInactive(); 00120 00121 void setProbability(double prob); 00122 00123 //void setObjectProbability(MHTObject* obj, double p); 00124 00125 /* HYPOTHESIS MODIFIERS */ 00126 00127 void addChildHypothesis(Hypothesis* h); 00128 00129 // Add object to the object list 00130 void addObject(SemanticObject* obj); 00131 00132 void clearAssignmentSet(); 00133 00134 void clear(); 00135 00136 void addPotentialAssignment(Assignment* assignment); 00137 00138 void applyAssignments(); 00139 00140 /* TREE UPDATE METHODS */ 00141 00142 void findActiveLeafs(std::list<Hypothesis*>& active_leafs); 00143 00144 double calculateBranchProbabilities(); 00145 00146 int calculateHeigth(); 00147 00148 Hypothesis* determineBestLeaf(); 00149 00150 00151 /* TREE CLEAR / DELETE METHODS */ 00152 00153 void clearInactive(); 00154 00155 void deleteChildren(); 00156 00157 Hypothesis* deleteSinglePaths(); 00158 00159 protected: 00160 00161 double probability_; 00162 00163 double timestamp_; 00164 00165 std::list<SemanticObject*> objects_; 00166 00167 Hypothesis* parent_; 00168 00169 std::list<Hypothesis*> children_; 00170 00171 AssignmentSet* assignment_set_; 00172 00173 AssignmentMatrix* assignment_matrix_; 00174 00175 Hypothesis* best_leaf_; 00176 00177 int height_; 00178 00179 bool is_active_leaf_; 00180 00181 }; 00182 00183 } 00184 #endif /* HYPOTHESIS_H_ */