statistictools.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
00003  *    martius@informatik.uni-leipzig.de                                    *
00004  *    fhesse@informatik.uni-leipzig.de                                     *
00005  *    der@informatik.uni-leipzig.de                                        *
00006  *    frankguettler@gmx.de                                                 *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  ***************************************************************************
00023  *                                                                         *
00024  *  DESCRIPTION                                                            *
00025  *                                                                         *
00026  *   $Log: statistictools.h,v $
00027  *   Revision 1.10  2008/04/29 09:56:21  guettler
00028  *   -debug printouts removed
00029  *
00030  *   Revision 1.9  2008/04/29 08:51:54  guettler
00031  *   -cosmetic changes of StatisticTools
00032  *   -StatisticTools now uses new function addInspectableValue of the
00033  *   interface Inspectable, not overloading getInternalParams and
00034  *   getInternalParamNames anymore
00035  *
00036  *   Revision 1.8  2008/01/17 09:59:27  der
00037  *   complexmeasure: preparations made for predictive information,
00038  *   fixed a minor bug
00039  *   statisticmeasure, statistictools: added support for adding
00040  *   std::list<AbstractMeasure*> to StatisticTools, some minor
00041  *   improvements
00042  *
00043  *   Revision 1.7  2007/12/06 10:18:10  der
00044  *   AbstractMeasure is now a abstract type for Measures,
00045  *   StatisticTools now supports AbstractMeasures,
00046  *   StatisticalMeasure, ComplexMeasure  now derived from
00047  *   AbstractMeasure,
00048  *   ComplexMeasure provides support for calculation e.g. entropy,
00049  *   uses Discretisizer,
00050  *   Discretisizer is a stand-alone class for support of discretisizing values
00051  *   TrackableMeasure derived from ComplexMeasure and provides support for calculating complex measures for Trackable objects
00052  *
00053  *   Revision 1.6  2007/10/01 13:27:47  robot3
00054  *   documentation
00055  *
00056  *   Revision 1.5  2007/09/28 10:08:49  robot3
00057  *   fixed memory bugs, statistics are from now on aligned right
00058  *
00059  *   Revision 1.4  2007/09/28 08:48:21  robot3
00060  *   corrected some minor bugs, files are still in develop status
00061  *
00062  *   Revision 1.3  2007/09/27 10:49:39  robot3
00063  *   removed some minor bugs,
00064  *   added CONVergence test
00065  *   changed little things for support of the new WSM
00066  *
00067  *   Revision 1.2  2007/05/08 10:18:15  der
00068  *   added a function for starting the measure after a given time.
00069  *   made some tests
00070  *
00071  *   Revision 1.1  2007/05/07 21:01:32  robot3
00072  *   statistictools is a class for easy visualization of measurements of observed values
00073  *   it is possible to add the observed value itself with mode ID
00074  *
00075  *                                                                         *
00076  ***************************************************************************/
00077 #ifndef _STATISTIC_TOOLS_H
00078 #define _STATISTIC_TOOLS_H
00079 
00080 #include "inspectable.h"
00081 #include "callbackable.h"
00082 #include "measuremodes.h"
00083 
00084 
00085 // begin forward declarations
00086 class AbstractMeasure;
00087 class StatisticMeasure;
00088 class ComplexMeasure;
00089 // end forward declarations
00090 
00091 class StatisticTools : public Inspectable, public Callbackable {
00092 
00093 public:
00094   StatisticTools() : beginMeasureCounter(0) { }
00095 
00096         /**
00097          * adds a variable to observe and measure the value
00098          * @param observedValue    the value to observe.
00099          * @param measureName      the name of the measured value
00100          * @param mode             the mode of measure
00101          * @param stepSpan         in most cases the stepSpan is important to get
00102          * the measured value of a number of steps, like AVG:
00103          * if stepSpan = 0, AVG is calculated over all steps
00104          * if stepSpan = n, AVG is calculated over the LAST n steps
00105          * The same counts for all the other MeasureModes.
00106          * @param additionalParam  is used for example for mode PEAK, the param is the limit value,
00107          * all values minus limit are displayed, values below the limit are set to 0.
00108          * In CONV mode (test the convergence), this value is the epsilon criteria.
00109          * @return measured value as adress. So it is possible to measure this value again
00110          */
00111   virtual double& addMeasure(double& observedValue, const char* measureName, MeasureMode mode, long stepSpan, double additionalParam=0);
00112 
00113   /**
00114    * Same as the method above, but instead of getting the calculated value back (the adress), you get
00115    * the StatisticMeasure itself
00116    */
00117   virtual StatisticMeasure* getMeasure(double& observedValue,const char* measureName, MeasureMode mode, long stepSpan, double additionalParam=0);
00118 
00119 
00120   /**
00121    * You can add another abstract measure you like. in some cases (e.g. complex
00122    * measures) it is better to let the measure decide how it likes to be initialized
00123    * @param measure the measure to add
00124    * @return the address value of the measure
00125    */
00126   virtual double& addMeasure(AbstractMeasure* measure);
00127 
00128   /**
00129    * You can add another abstract measure you like. in some cases (e.g. complex
00130    * measures) it is better to let the measure decide how it likes to be initialized
00131    * With this method you can add a list of AbstractMeasures.
00132    * @param measureList the list of measures to add
00133    * @return the address value of the first measure
00134    */
00135   virtual double& addMeasureList(std::list<AbstractMeasure*> measureList);
00136 
00137 
00138     /**
00139    * You can add another abstract measure you like. in some cases (e.g. complex
00140    * measures) it is better to let the measure decide how it likes to be initialized
00141    * With this method you can add a list of AbstractMeasures.
00142    * @param measureList the list of measures to add
00143    * @return the address value of the first measure
00144    */
00145   virtual double& addMeasureList(std::list<ComplexMeasure*> measureList);
00146 
00147 
00148     /**
00149    * You can add another abstract measure you like. in some cases (e.g. complex
00150    * measures) it is better to let the measure decide how it likes to be initialized
00151    * With this method you can add a list of AbstractMeasures.
00152    * @param measureList the list of measures to add
00153    * @return the address value of the first measure
00154    */
00155   virtual double& addMeasureList(std::list<StatisticMeasure*> measureList);
00156 
00157 
00158 
00159         /**
00160          * starts the measure at a specific time. This is useful if there are
00161          * values that have to be ignored at simulation start.
00162          * @param step number of steps (normally simsteps) to wait for beginning the measures
00163          */
00164         virtual void beginMeasureAt(long step);
00165 
00166   /**
00167    * Tells you wether the measures have already been started.
00168    * @return true if measures have already been started, otherwise false
00169    */
00170   virtual bool measureStarted() { return (beginMeasureCounter==0?true:false); }
00171 
00172 
00173         /**
00174          * CALLBACKABLE INTERFACE
00175          *
00176          *      this method is invoked when a callback is done from the class where this
00177          * class is for callback registered
00178          */
00179         virtual void doOnCallBack();
00180 
00181 
00182 protected:
00183         std::list<AbstractMeasure*> activeMeasures;
00184         long beginMeasureCounter;
00185 };
00186 
00187 #endif

Generated on Tue Sep 16 22:00:22 2008 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7