⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quickclustering.cpp

📁 模糊聚類分析源碼。包含教學文件
💻 CPP
字号:
/*    Context       : Fuzzy Clustering Algorithms  Author        : Frank Hoeppner, see also AUTHORS file   Description   : implementation of class module QuickClustering                    History       :      Comment       :     This file was generated automatically. DO NOT EDIT.  Copyright     : Copyright (C) 1999-2000 Frank Hoeppner    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*//*  The University of Applied Sciences Oldenburg/Ostfriesland/Wilhelmshaven  hereby disclaims all copyright interests in the program package `fc'   (tool package for fuzzy cluster analysis) written by Frank Hoeppner.    Prof. Haass, President of Vice, 2000-Mar-10*/#ifndef QuickClustering_SOURCE#define QuickClustering_SOURCE/* configuration include */#ifdef HAVE_CONFIG_H/*//FILETREE_IFDEF HAVE_CONFIG_H*/#include "config.h"/*//FILETREE_ENDIF*/#endif// necessary includes#include "QuickClustering.hpp"// data// implementationtemplate < class ANALYSIS >QuickClustering< ANALYSIS >::QuickClustering  (  Algorithm<ANALYSIS>* ap_dist_alg,  Algorithm<ANALYSIS>* ap_alg  )  : mp_succ_alg(ap_alg)  , mp_dist_alg(ap_dist_alg)    {    }template < class ANALYSIS >QuickClustering< ANALYSIS >::~QuickClustering  (  )  {  FUNCLOG("~QuickClustering");    delete mp_succ_alg;  }template < class ANALYSIS >voidQuickClustering< ANALYSIS >::operator()  (  ANALYSIS& a_analysis  )  {  FUNCLOG("QuickClustering");    int c(a_analysis.option().number_prototypes());  if (c<1) c=a_analysis.option().max_no_of_clusters();  invariant(c>0,"number of prototypes > 0",SOURCELOC);  opt_type option(a_analysis.option());  data_set_type data;  link_set_type links;  ANALYSIS analysis(&option,&data,&a_analysis.prototypes(),&links);  adjust_set_size(links,c*(c+1));  data.push_back(data_type());  data_iter i_single(data.begin());  option.number_features()=1;  data_iter i_test_data(a_analysis.data().begin());  for (      typename ANALYSIS::prot_iter i_prot(a_analysis.prototypes().begin());      i_prot != a_analysis.prototypes().end();      ++i_prot      )    {    (*i_prot) = (*i_test_data);    data.push_back(*i_test_data);    ++option.number_features();    ++i_test_data;    }  link_iter i_link;  real_type minxq,minqr,minst;  int q,r,s,t;  for (;i_test_data!=a_analysis.data().end();++i_test_data)    {    (*i_single) = (*i_test_data);    trace("--- consider data object",*i_single);    (*mp_dist_alg)(analysis);    i_link = links.begin();    int pd(0),pp;    minxq=minqr=minst=POS_IMPOSSIBLE_RANGE;    for (        data_iter i_data(analysis.data().begin());        i_data != analysis.data().end();        ++i_data        )      {      if (pd>0) trace("prototype",*i_data);      pp=1;      for (          prot_iter i_prot(analysis.prototypes().begin());          i_prot != analysis.prototypes().end();          ++i_prot          )        {        const real_type d((*i_link).squared_distance());        if (pd==0)           {          if (d<minxq) { minxq=d; q=pp; }          }        else          { // q has been determined          if ((pd==q) && (pp!=q) && (d<minqr)) { minqr=d; r=pp; }          if ((pp!=pd) && (d<minst)) { minst=d; s=pp; t=pd; }          }        ++i_link; ++pp;        }      ++pd;      }    int i(1);    for (        prot_iter i_prot(analysis.prototypes().begin());        i_prot != analysis.prototypes().end();        ++i_prot        )      {      if (i==q) trace("nearest prototype q      :",*i_prot);      if (i==r) trace("closest prototype r to q :",*i_prot);      if ((i==s) || (i==t)) trace("one of closest prototypes:",*i_prot);      ++i;      }    if (minxq>minst)      {        trace("replace one of s,t by x");      real_type ds,dt;      i_link = links.begin();      for (int i=0;i<c;++i)         {         if (i==s) ds=(*i_link).squared_distance();        if (i==t) dt=(*i_link).squared_distance();        ++i_link;        }      if (ds>dt) t=s;       prot_iter i_prot(analysis.prototypes().begin());      data_iter i_data(analysis.data().begin()); ++i_data;      while (t>1) { ++i_data; ++i_prot; --t; }      (*i_prot) = (*i_test_data);      (*i_data) = (*i_test_data);      }    else if (minxq>minqr)      {      trace("replace q by x");      prot_iter i_prot(analysis.prototypes().begin());      data_iter i_data(analysis.data().begin()); ++i_data;      while (q>1) { ++i_data; ++i_prot; --q; }      (*i_prot) = (*i_test_data);      (*i_data) = (*i_test_data);      }    }  a_analysis.option().init()=FC_INIT_PROT;  call_successor(mp_succ_alg,a_analysis,"qc");    }// template instantiation#endif // QuickClustering_SOURCE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -