Main Page | Namespace List | Class Hierarchy | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

cluster.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (c) 2003, Cornell University
00004 All rights reserved.
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008 
00009    - Redistributions of source code must retain the above copyright notice,
00010        this list of conditions and the following disclaimer.
00011    - Redistributions in binary form must reproduce the above copyright
00012        notice, this list of conditions and the following disclaimer in the
00013        documentation and/or other materials provided with the distribution.
00014    - Neither the name of Cornell University nor the names of its
00015        contributors may be used to endorse or promote products derived from
00016        this software without specific prior written permission.
00017 
00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00022 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
00028 THE POSSIBILITY OF SUCH DAMAGE.
00029 
00030 */
00031 
00032 #if !defined _CLUSTER_H
00033 #define _CLUSTER_H
00034 
00035 #include "general.h"
00036 #include <stdio.h>
00037 #include "vec.h"
00038 #include <string>
00039 #include <iostream>
00040 
00041 using namespace TNT;
00042 using namespace std;
00043 
00044 namespace CLUS
00045 {
00046 
00047 /**  Cluster is the abstract base class for cluster hierarchy.
00048      This class can both identify and run a cluster.
00049      The H in front of distance functions means that that distance is used
00050      for the hierarchical version of the algorithm
00051  */
00052 class Cluster
00053 {
00054 public:
00055     enum State {Final,Splited,Splitable,Dead};
00056 
00057 protected:
00058     int inDim, outDim;
00059     const double* dataCache;
00060     double distanceInfer,distanceClus;
00061     double weight;
00062     double dimension;
00063     State state;
00064 
00065 public:
00066     inline Cluster(int InDim=0, int OutDim=0):
00067             inDim(InDim), outDim(OutDim), dataCache(NULL), distanceInfer(0.0),
00068             distanceClus(0.0),weight(1.0), state(Splitable)
00069     {}
00070     
00071     State GetState(void)
00072     {
00073         return state;
00074     }
00075 
00076     /// Initializes the cluster with random values
00077     void    RandomCluster(void)
00078     {}
00079     
00080     void    InitalizeOnPoint(const double*)
00081     {}
00082     
00083     double InferDistance(const double* DataCache)
00084     {
00085         return 0.0;
00086     }
00087     
00088     double ClusDistance(const double* DataCache)
00089     {
00090         return 0.0;
00091     }
00092     
00093     inline double LastInferDistance(void)
00094     {
00095         return distanceInfer;
00096     }
00097     
00098     inline double LastClusDistance(void)
00099     {
00100         return distanceClus;
00101     }
00102 
00103     /// Called after all distances of the
00104     /// clusters have been computed so the ponder of
00105     /// each cluster in final result can be computed
00106     void CorrectAppartGrade(double Coef)
00107     {}
00108     
00109     void HCorrectAppartGrade(double Coef)
00110     {}
00111 
00112     /** Finalizes one big step of the identification
00113                  process.  Computes the new prototype of the cluster
00114                  and returns the distance between the old and the
00115                  new prototype so a decision if the proces should
00116                  continue can be taken
00117     */
00118     double AdjustPrototypes(void)
00119     {
00120         return 0.0;
00121     }
00122     
00123     double HAdjustPrototypes(void)
00124     {
00125         return 0.0;
00126     }
00127     
00128     void AdjustYwithYoverD(Vector<double>& Y)
00129     {}
00130 
00131     void AdjustYwithYoverD(Vector<double>& Y, double)
00132     {}
00133 
00134     /// Returns the consequent value of the cluster for the
00135     /// last input introduced as a parameter of Distance
00136     double ComputeLastY(void)
00137     {
00138         return 0.0;
00139     }
00140     
00141     static string TypeName(void)
00142     {
00143         return string("Cluster");
00144     }
00145     
00146     void SaveToStream(ostream& )
00147     {}
00148     
00149     void LoadFromStream(ostream& )
00150     {}
00151 
00152     bool Split(Cluster& right, Cluster& save)
00153     {
00154         return false;
00155     }
00156     
00157     bool SetOptionDbl(char* optName,double value)
00158     {
00159         if ( strcmp(optName,"weight") )
00160         {
00161             weight=value;
00162             return true;
00163         }
00164         return false;
00165     }
00166 };
00167 
00168 } // namespace CLUS
00169 
00170 
00171 #endif    /* _CLUSTER_H */

Generated on Mon Jul 21 16:57:24 2003 for SECRET by doxygen 1.3.2