AlgorithmSelector.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009 by Ulrich Friedrich Klank <klank@in.tum.de>
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 3 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 /************************************************************************
00020                         AlgorithmSelector.h - Copyright klank
00021 
00022 
00023 **************************************************************************/
00024 
00025 
00026 #ifndef ALGORITHMSELECTOR_H
00027 #define ALGORITHMSELECTOR_H
00028 
00029 #include <string>
00030 #include <vector>
00031 
00032 #include "AlgorithmEval.h"
00033 #include "Signature.h"
00034 #ifdef LOGFILE
00035 #include "LogFile.h"
00036 #define STD_LOGFILENAME "AlgActions.log"
00037 #endif /*LOGFILE*/
00038 
00040 #include <ANN/ANN.h>
00041 
00045 typedef double Probability_1D_t; /* < Type for storing Probability of a location to occur*/
00046 
00047 
00048 namespace cop
00049 {
00050 
00051   typedef std::vector<std::pair<RelPose*, Probability_1D_t> > PossibleLocations_t;/* < Type for a list of relposes with their a-priori probability */
00052   typedef std::vector<std::pair<RelPose*, Signature*> > SignatureLocations_t;
00053 
00054   /***/
00055 
00056   #define XML_NODE_ALGORITHMSELECTOR "AlgorithmSelector"
00057 
00061   template<typename T>
00062   class AlgorithmSelector : public Evaluator
00063   {
00064   public:
00065     // Constructors/Destructors
00066     //
00070       AlgorithmSelector(
00071   #ifdef LOGFILE
00072           LogFile& log
00073   #endif /*LOGFILE*/
00074           )  :
00075           m_tree(NULL),
00076           m_paLength(0),
00077           m_paAllocatedLength(0),
00078           m_paDim(4)
00079 #ifdef LOGFILE
00080           ,m_logfile(log)
00081   #endif /*LOGFILE*/
00082           {
00083             m_mutexAlgEval = new boost::mutex();
00084           }
00085     AlgorithmSelector (XMLTag* node
00086   #ifdef LOGFILE
00087           , LogFile& log
00088   #endif /*LOGFILE*/
00089           );
00093     ~AlgorithmSelector ( ){delete m_mutexAlgEval;}
00102     int AddAlgorithm(Algorithm<T>* alg, int nType, double dEval, double dTime);
00103 
00109     XMLTag* Save(std::string name = "");
00118     virtual Algorithm<T>* BestAlgorithm(int type, const Signature& sig, const std::vector<Sensor*> &sensors);
00127     std::vector<Algorithm<T>*> BestAlgorithmList(int type, const Signature &sig, const std::vector<Sensor*> &sensors);
00128 
00132     int CountAlgorithms(){return m_algorithmlist.size();}
00136     const std::vector<AlgorithmEval<T> >& GetAlgorithmList() const {return m_algorithmlist;};
00140     virtual void EvalAlgorithm(Evaluable* alg, double eval, double time, Signature* relatedElemg);
00145     void ReevaluatePose(Algorithm<T>* alg, RelPose*& pose);
00146 
00147 
00148   protected:
00152     int InsertInList(AlgorithmEval<T> eval);
00153 
00157     bool CheckTypeCompatibility(int listedType, int askedType);
00158 
00160     double ReEvalKernel(double val);
00161 
00162 
00166     std::vector<AlgorithmEval<T> >& GetAlgorithmList(std::vector<AlgorithmEval<T> >* eval = NULL) ;
00167 
00172     Algorithm<T>* getAlgorithm(int index);
00173 
00174   private:
00178     std::vector<AlgorithmEval<T> > m_algorithmlist;
00179 
00183       ANNkd_tree    *m_tree;
00184       ANNpointArray m_pointArray;
00185       double        *m_pointEval;
00186       int           m_paLength;
00187       int           m_paAllocatedLength;
00188       int           m_paDim;
00189 
00190       typedef boost::mutex::scoped_lock lock;
00191       boost::mutex  *m_mutexAlgEval;    
00192 
00196   public:
00197   #ifdef LOGFILE
00198       LogFile& m_logfile;
00199   #endif /*LOGFILE*/
00200   };
00201 }
00202 #endif // ALGORITHMSELECTOR_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


cognitive_perception
Author(s): Ulrich F Klank
autogenerated on Thu May 23 2013 07:38:34