hypothesis.cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
32 #include <mtt/hypothesis.h>
33 
34 
35 Hypothesis::Hypothesis(int iteration, int cluster, int status)
36 {
37  Hypothesis();
38 
40  _cluster=cluster;
41  _status=status;
42 }
43 
45 {
46 // cout<<"deleted: "<<*this<<endl;
47 // _targets.clear();
48 }
49 
51 {
52  boost::format fm("H (%d-%d) %ld #%ld\n%.3f :%d");
53  fm % _iteration % _cluster % _id % _uid % _probability % _targets.size();
54  return fm.str();
55 }
56 
58 {
59  boost::format fm("H (%d-%d) %ld #%ld");
60  fm % _iteration % _cluster % _id % _uid;
61  return fm.str();
62 }
63 
64 void Hypothesis::setAttribute(string name,string value)
65 {
66  if(find(_attribute_names.begin(),_attribute_names.end(),name)==_attribute_names.end())//Not found
67  {
68  _attribute_names.push_back(name);
69  _attribute_values.push_back(value);
70 
71  return;
72  }
73 
74  for(uint i=0;i<_attribute_names.size();++i)
75  if(_attribute_names[i]==name)
76  {
77  _attribute_values[i]=value;
78  return;
79  }
80 }
81 
83 {
84  _euid++;
85  _uid=_euid;
86  _id=0;
87  _status=0;
88  _aux1=-1;
89  _cluster=-1;
90  _iteration=-1;
91  _probability=0;
92  _targets.clear();
93  _attribute_names.clear();
94  _attribute_values.clear();
95 
96  _n_det=0;
97  _n_occ=0;
98  _n_del=0;
99  _n_new=0;
100  _n_fal=0;
101  _prod=1;
102 
103  _parent_uid=-1;
104 
105 // _n_children=0;
106 }
107 
108 ostream& operator<<(ostream& o,Hypothesis& h)
109 {
110  o<<"hypothesis uid: "<<h._uid;
111  o<<" cluster: "<<h._cluster;
112  o<<" iteration: "<<h._iteration;
113  o<<" status: "<<h._status;
114  return o;
115 }
116 
117 
119 {
120  return h1->_probability < h2->_probability;
121 }
122 
124 {
125  return h1->_probability > h2->_probability;
126 }
127 
129 {
130  return h1->_uid<h2->_uid;
131 }
vector< string > _attribute_names
Attribute names used in the graphviz representation of this hypothesis.
Definition: hypothesis.h:88
vector< string > _attribute_values
Values for the corresponding attributes.
Definition: hypothesis.h:90
Hypothesis class declaration.
long _uid
Unique id for all currently existing hypotheses.
Definition: hypothesis.h:66
long iteration
Current iteration counter, used in the naming of tree nodes.
Definition: pmht.cpp:61
int _iteration
Iteration for this hypothesis.
Definition: hypothesis.h:58
string name()
Create hypothesis name.
Definition: hypothesis.cpp:57
bool compareHypothesesByProbabilityDescending(HypothesisPtr h1, HypothesisPtr h2)
Compare two hypotheses by probability, but descending.
Definition: hypothesis.cpp:123
bool compareHypothesesByProbability(HypothesisPtr h1, HypothesisPtr h2)
Compare two hypotheses by probability.
Definition: hypothesis.cpp:118
double _prod
Probability of current target to measurement assignment.
Definition: hypothesis.h:80
int _n_det
Number of detected targets.
Definition: hypothesis.h:70
double _probability
Hypothesis probability.
Definition: hypothesis.h:68
boost::shared_ptr< Hypothesis > HypothesisPtr
Definition: cluster.h:44
int _status
Current status.
Definition: hypothesis.h:62
int _n_fal
Number of failed targets.
Definition: hypothesis.h:78
vector< TargetPtr > _targets
List of hypothesis targets.
Definition: hypothesis.h:93
int _n_del
Number of deleted targets.
Definition: hypothesis.h:74
int _n_occ
Number of occluded targets.
Definition: hypothesis.h:72
void setAttribute(string name, string value)
Add a new attribute to the hypothesis, these attributes are only used in the graphviz plugin...
Definition: hypothesis.cpp:64
bool compareHypotheses(HypothesisPtr h1, HypothesisPtr h2)
Compare two hypotheses by uid.
Definition: hypothesis.cpp:128
static long _euid
Static extremely unique id for all hypotheses (since program start)
Definition: hypothesis.h:64
long _id
Main id of the hypothesis.
Definition: hypothesis.h:60
long _parent_uid
Id of the parent hypothesis.
Definition: hypothesis.h:85
int _cluster
Id of the cluster this hypothesis belongs to.
Definition: hypothesis.h:56
string nameUI()
Create hypothesis name formated to the user interface.
Definition: hypothesis.cpp:50
Hypothesis()
Hypothesis constructor, variable initialization.
Definition: hypothesis.cpp:82
Hypotheses tree nodes.
Definition: hypothesis.h:50
int _aux1
Auxiliary int variable, multi use, value not assured between calls.
Definition: hypothesis.h:54
ostream & operator<<(ostream &o, Hypothesis &h)
Definition: hypothesis.cpp:108
~Hypothesis()
Class destructor.
Definition: hypothesis.cpp:44
int _n_new
Number of new targets.
Definition: hypothesis.h:76


mtt
Author(s): Jorge Almeida
autogenerated on Mon Mar 2 2015 01:32:18