Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

ArchiveStatistic.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   SpikeStream Application                                               *
00003  *   Copyright (C) 2007 by David Gamez                                     *
00004  *   david@davidgamez.eu                                                   *
00005  *   Version 0.1                                                           *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************/
00022 
00023 #ifndef ARCHIVESTATISTIC_H
00024 #define ARCHIVESTATISTIC_H
00025 
00026 //Qt includes
00027 #include <qstring.h>
00028 
00029 //Other includes
00030 #include <string>
00031 #include <vector>
00032 #include <google/dense_hash_map>
00033 using namespace std;
00034 using HASH_NAMESPACE::hash;
00035 using GOOGLE_NAMESPACE::dense_hash_map;
00036 
00037 //-------------------------- Archive Statistic -----------------------------
00038 /*! Abstract class used to gather statistics about an archive. 
00039         Inheriting classes add up information about neuron groups or neuron ids.*/
00040 //--------------------------------------------------------------------------
00041 class ArchiveStatistic {
00042 
00043         public:
00044                 ArchiveStatistic(unsigned int* fNeurCount, unsigned int* fNeurTotal);
00045                 virtual ~ArchiveStatistic();
00046                 virtual void recalculate();
00047                 virtual void recalculate(unsigned int neurID);
00048                 virtual void recalculateNeuronGrp();
00049                 virtual QString toQString() = 0;
00050                 unsigned int getID();
00051                 unsigned int getType();
00052                 void resetFiringNeuronCount();
00053                 void resetFiringNeuronTotal();
00054                 void setID(unsigned int id);
00055 
00056                 /* Static types of neuron statistic. These two types are processed
00057                         separately for efficiency reasons.*/
00058                 /*! This statistic is monitoring an entire neuron group.*/
00059                 static const unsigned int NEURON_GROUP = 10;
00060 
00061                 /*! This statistic is monitoring a selection of neuron ids.*/
00062                 static const unsigned int NEURON_ID = 20;
00063                 
00064                 /* Make NetworkDataXmlHandler a friend so it can set the reference
00065                         to the hash map.*/
00066                 friend class NetworkDataXmlHandler;
00067 
00068 
00069         protected:
00070                 //============================== VARIABLES =============================
00071                 /*! Is this monitoring a neuron group or a set of neuron ids?.*/
00072                 unsigned int type;
00073 
00074                 /*! Pointer to the hash map in the NetworkDataXmlHandler. At each timestep
00075                         the firing neuron ids are placed in this map and then the archive
00076                         statistics are invoked to carry out their analysis. */
00077                 static dense_hash_map<unsigned int, bool, hash<unsigned int> >* neuronIDHashMap;
00078 
00079                 /*! The number of neurons firing at the current timestep. This is a pointer
00080                         to the variable in the ArchiveStatisticsHolder struct, which contains one
00081                         or more ArchiveStatistics.*/
00082                 unsigned int* firingNeuronCount;
00083 
00084                 /*! The total number of neurons that have fired so far. This is a pointer
00085                         to the variable in the ArchiveStatisticsHolder struct, which contains one
00086                         or more ArchiveStatistics.*/
00087                 unsigned int* firingNeuronTotal;
00088 
00089 
00090         private:
00091                 //============================= VARIABLES =============================
00092                 /*! The unique id of this archive statistic. Used for deleting them.*/
00093                 unsigned int ID;
00094 
00095 };
00096 
00097 
00098 //--------------------- Archive Statistics Holder --------------------------
00099 /*! Holds a collection of archive statistics. This is created by the 
00100         ArchiveStatisticsDialog and displayed in the ArchiveWidget. Each of the 
00101         ArchiveStatistics in the vector should have been created with references 
00102         to the firingNeuronCount and the firingNeuronTotal in this struct.*/
00103 //--------------------------------------------------------------------------
00104 struct ArchiveStatisticsHolder {
00105         string description;
00106         unsigned int ID;
00107         vector<ArchiveStatistic*> archStatVector;
00108         unsigned int firingNeuronCount;
00109         unsigned int firingNeuronTotal;
00110 };
00111 
00112 
00113 //--------------------- Neuron Group Archive Statistic ---------------------
00114 /*! Totals up the neuron firing events for a neuron group. */
00115 //--------------------------------------------------------------------------
00116 class NeuronGrpArchiveStatistic : public ArchiveStatistic {
00117 
00118         public:
00119                 NeuronGrpArchiveStatistic(unsigned int* fNeurCount, unsigned int* fNeurTotal, unsigned int nGrpID);
00120                 ~NeuronGrpArchiveStatistic();
00121                 unsigned int getNeuronGrpID();
00122                 void recalculateNeuronGrp();
00123                 QString toQString();
00124 
00125 
00126         private:
00127                 //============================== VARIABLES =============================
00128                 /*! The id of the neuron group that is being monitored.*/
00129                 unsigned int neuronGrpID;
00130 
00131 
00132                 //=========================== METHODS =================================
00133                 /*! Declare copy constructor private so it cannot be used inadvertently.*/
00134                 NeuronGrpArchiveStatistic(const NeuronGrpArchiveStatistic&);
00135 
00136                 /*! Declare assignment private so it cannot be used inadvertently.*/
00137                 NeuronGrpArchiveStatistic operator = (const NeuronGrpArchiveStatistic&);
00138 
00139 };
00140 
00141 
00142 //---------------------- Range Archive Statistic ---------------------------
00143 /*! Totals up the number of times neurons within a particular range fire. 
00144         The range here is inclusive of both high and low values. */
00145 //--------------------------------------------------------------------------
00146 class RangeArchiveStatistic : public ArchiveStatistic {
00147 
00148         public:
00149                 RangeArchiveStatistic(unsigned int* fNeurCount, unsigned int* fNeurTotal, unsigned int rLow, unsigned int rHigh);
00150                 ~RangeArchiveStatistic();
00151                 void recalculate();
00152                 QString toQString();
00153 
00154 
00155         private:
00156                 //============================== VARIABLES =============================
00157                 /*! The low point of the range.*/
00158                 unsigned int rangeLow;
00159 
00160                 /*! The high point of the range.*/
00161                 unsigned int rangeHigh;
00162 
00163 
00164                 //=========================== METHODS =================================
00165                 /*! Declare copy constructor private so it cannot be used inadvertently.*/
00166                 RangeArchiveStatistic(const RangeArchiveStatistic&);
00167 
00168                 /*! Declare assignment private so it cannot be used inadvertently.*/
00169                 RangeArchiveStatistic operator = (const RangeArchiveStatistic&);
00170 
00171 };
00172 
00173 
00174 //------------------------ And Archive Statistic ---------------------------
00175 /*! Totals up the number of times the two specified neuron ids occur 
00176         together. */
00177 //--------------------------------------------------------------------------
00178 class AndArchiveStatistic : public ArchiveStatistic {
00179 
00180         public:
00181                 AndArchiveStatistic(unsigned int* fNeurCount, unsigned int* fNeurTotal, unsigned int fNeurID, unsigned int sNeurID);
00182                 ~AndArchiveStatistic();
00183                 void recalculate();
00184                 QString toQString();
00185 
00186 
00187         private:
00188                 //============================== VARIABLES =============================
00189                 /*! The first neuron id.*/
00190                 unsigned int firstNeuronID;
00191 
00192                 /*! The second neuron id.*/
00193                 unsigned int secondNeuronID;
00194 
00195 
00196                 //=========================== METHODS =================================
00197                 /*! Declare copy constructor private so it cannot be used inadvertently.*/
00198                 AndArchiveStatistic(const AndArchiveStatistic&);
00199 
00200                 /*! Declare assignment private so it cannot be used inadvertently.*/
00201                 AndArchiveStatistic operator = (const AndArchiveStatistic&);
00202 
00203 };
00204 
00205 
00206 //------------------------ Or Archive Statistic ----------------------------
00207 /*! Totals up the number of times that either one or the other neuron id
00208         occurs. Note that if both occur, the count will only be increased by 
00209         one.*/
00210 //--------------------------------------------------------------------------
00211 class OrArchiveStatistic : public ArchiveStatistic {
00212 
00213         public:
00214                 OrArchiveStatistic(unsigned int* fNeurCount, unsigned int* fNeurTotal, unsigned int fNeurID, unsigned int sNeurID);
00215                 ~OrArchiveStatistic();
00216                 void recalculate();
00217                 QString toQString();
00218 
00219 
00220         private:
00221                 //============================== VARIABLES =============================
00222                 /*! The first neuron id.*/
00223                 unsigned int firstNeuronID;
00224 
00225                 /*! The second neuron id.*/
00226                 unsigned int secondNeuronID;
00227 
00228 
00229                 //=========================== METHODS =================================
00230                 /*! Declare copy constructor private so it cannot be used inadvertently.*/
00231                 OrArchiveStatistic(const OrArchiveStatistic&);
00232 
00233                 /*! Declare assignment private so it cannot be used inadvertently.*/
00234                 OrArchiveStatistic operator = (const OrArchiveStatistic&);
00235 
00236 };
00237 
00238 
00239 //--------------------- Neuron ID Archive Statistic ------------------------
00240 /*! Totals up the number of times that a single neuron id occurs. */
00241 //--------------------------------------------------------------------------
00242 class NeuronIDArchiveStatistic : public ArchiveStatistic {
00243 
00244         public:
00245                 NeuronIDArchiveStatistic(unsigned int* fNeurCount, unsigned int* fNeurTotal, unsigned int neurID);
00246                 ~NeuronIDArchiveStatistic();
00247                 void recalculate();
00248                 QString toQString();
00249 
00250 
00251         private:
00252                 //============================== VARIABLES =============================
00253                 /*! The neuron id.*/
00254                 unsigned int neuronID;
00255 
00256 
00257                 //=========================== METHODS =================================
00258                 /*! Declare copy constructor private so it cannot be used inadvertently.*/
00259                 NeuronIDArchiveStatistic(const NeuronIDArchiveStatistic&);
00260 
00261                 /*! Declare assignment private so it cannot be used inadvertently.*/
00262                 NeuronIDArchiveStatistic operator = (const NeuronIDArchiveStatistic&);
00263 
00264 };
00265 
00266 
00267 #endif//ARCHIVESTATISTIC_H
00268 
00269 

Generated on Mon Sep 3 22:29:04 2007 for SpikeStream Application by  doxygen 1.4.4