Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef ALGORITHMEVAL_H
00020 #define ALGORITHMEVAL_H
00021
00022 #include "Algorithm.h"
00023 #include "LocateAlgorithm.h"
00024 #include "RefineAlgorithm.h"
00025 #include "ProveAlgorithm.h"
00026 #include "AttentionAlgorithm.h"
00027 #include "Signature.h"
00028
00029 #define XML_NODE_ALGORITHMEVAL "AlgorithmEval"
00030 #define XML_NODE_EVAL "Eval"
00031 #define XML_NODE_ALGTYPE "AlgType"
00032 #define XML_NODE_AVGTIME "AvgTime"
00033
00034 #define XML_NODE_OBJECTEVALMAP "ObjEvalMap"
00035
00036
00037 #define ALGORITHMTYPE_LOCATE 0x000
00038 #define ALGORITHMTYPE_TRACK 0x010
00039 #define ALGORITHMTYPE_2OBJS 0x200
00040
00041 #define ALGORITHMTYPE_REFINE 0x100
00042 #define ALGORITHMTYPE_RPOVE 0x400
00043
00044 #define ALGORITHMTYPE_STOPTRACK 0x800
00045
00046
00047 #define ALGORITHMTYPE_STARTATTEND 0x1000
00048 #define ALGORITHMTYPE_STOPATTEND 0x2000
00049
00050
00051 #define ALGORITHMTYPE_LOOKUP 0x6400
00052 #define ALGORITHMTYPE_LOOKUPDB 0x6401
00053 #define ALGORITHMTYPE_LOOKUPALL 0x6402
00054
00055 #define ALGORITHMSPEC_ONETARGET 0
00056 #define ALGORITHMSPEC_SEVERALTARGET 1
00057
00058 namespace cop
00059 {
00064 template<typename T> class AlgorithmEval
00065 {
00066 public:
00067 AlgorithmEval(Algorithm<T>* alg, int type, double eval, double m_avgRunTime) :
00068 m_algorithm(alg),
00069 m_algorithmType(type),
00070 m_eval(eval),
00071 m_avgRunTime(m_avgRunTime)
00072 {
00073 if(alg == NULL)
00074 printf("Empty Algorithm\n");
00075 }
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 AlgorithmEval(XMLTag* tag);
00093
00094 std::pair<double, int> GetEval(ObjectID_t id) const
00095 {
00096 std::map<ObjectID_t, std::pair<double, int> >::const_iterator it;
00097 if((it = m_objectEval.find(id)) != m_objectEval.end())
00098 {
00099 return (*it).second;
00100 }
00101 else
00102 {
00103 std::pair<double, int> p;
00104 p.first = 0.0;
00105 p.second = 0;
00106 return p;
00107 }
00108 }
00109
00110 void SetEval(ObjectID_t id, double eval)
00111 {
00112 if(m_objectEval.find(id) != m_objectEval.end())
00113 {
00114 m_objectEval[id].first += eval;
00115 m_objectEval[id].second++;
00116 }
00117 else
00118 {
00119 m_objectEval[id].first = eval;
00120 m_objectEval[id].second = 1;
00121 }
00122 }
00123
00124 size_t MapLength() const{return m_objectEval.size();}
00125 const std::map<ObjectID_t, std::pair<double, int> > GetMap() const {return m_objectEval;}
00126
00127
00128
00129
00130
00131
00132
00133
00134 XMLTag* Save(std::string name = "");
00135
00136 Algorithm<T>* m_algorithm;
00137 int m_algorithmType;
00138 double m_eval;
00139 double m_avgRunTime;
00140 private:
00141 std::map<ObjectID_t, std::pair<double, int> > m_objectEval;
00142
00143 };
00144
00145 class Evaluator
00146 {
00147 public:
00151 virtual void EvalAlgorithm(Evaluable* alg, double eval, double time, Signature* relatedElemg) = 0;
00155 std::string GetName(){return caller_name;}
00156 void SetName(std::string name){caller_name = name;}
00157
00158
00159 std::string caller_name;
00160 };
00161
00162 }
00163 #endif