📄 probmembupdate.cpp
字号:
/* Context : Fuzzy Clustering Algorithms Author : Frank Hoeppner, see also AUTHORS file Description : implementation of class module ProbMembUpdate 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 ProbMembUpdate_SOURCE#define ProbMembUpdate_SOURCE/* configuration include */#ifdef HAVE_CONFIG_H/*//FILETREE_IFDEF HAVE_CONFIG_H*/#include "config.h"/*//FILETREE_ENDIF*/#endif// necessary includes#include "ProbMembUpdate.hpp"// data// implementationtemplate < class ANALYSIS >ProbMembUpdate< ANALYSIS >::ProbMembUpdate ( Algorithm<ANALYSIS>* ap_alg ) : mp_succ_alg(ap_alg) { }template < class ANALYSIS >ProbMembUpdate< ANALYSIS >::~ProbMembUpdate ( ) { FUNCLOG("~ProbMembUpdate"); delete mp_succ_alg; }template < class ANALYSIS >voidProbMembUpdate< ANALYSIS >::operator() ( ANALYSIS& a_analysis ) { FUNCLOG("ProbMembUpdate"); typename ANALYSIS::link_iter i_link(a_analysis.links().begin()); const real_type exponent = 1.0/(a_analysis.option().fuzzifier()-1.0); bool exp_equal_one( exponent==1.0 ); real_type delta_membership(0); for ( typename ANALYSIS::prot_iter i_prot(a_analysis.prototypes().begin()); i_prot != a_analysis.prototypes().end(); ++i_prot ) { (*i_prot).total_pow_membxweight() = 0; } for ( typename ANALYSIS::data_iter i_data(a_analysis.data().begin()); i_data != a_analysis.data().end(); ++i_data ) { typename ANALYSIS::link_iter i_link_backup(i_link); real_type rez_sum(0); int zeroes(0); const real_type weight( (*i_data).weight() ); for ( typename ANALYSIS::prot_iter i_prot(a_analysis.prototypes().begin()); i_prot != a_analysis.prototypes().end(); ++i_prot ) { if ((*i_link).squared_distance()==0) ++zeroes; (*i_link).pow_distance() = (exp_equal_one) ? (*i_link).squared_distance() : pow((*i_link).squared_distance(),exponent); rez_sum += 1.0/((*i_link).pow_distance()); ++i_link; } i_link = i_link_backup; // update memberships if (zeroes>0) { const real_type uniform_membership( 1.0/zeroes ); const real_type uniform_pow_memb( pow(uniform_membership,a_analysis.option().fuzzifier()) ); for ( typename ANALYSIS::prot_iter i_prot(a_analysis.prototypes().begin()); i_prot != a_analysis.prototypes().end(); ++i_prot ) { if ((*i_link).squared_distance()==0) { delta_membership += SQR( (*i_link).membership()-uniform_membership ); (*i_link).membership() = uniform_membership; (*i_link).pow_membxweight() = weight*uniform_pow_memb; (*i_prot).total_pow_membxweight() += (*i_link).pow_membxweight(); } else { delta_membership += SQR( (*i_link).membership() ); (*i_link).membership() = 0; (*i_link).pow_membxweight() = 0; } ++i_link; } } else { for ( typename ANALYSIS::prot_iter i_prot(a_analysis.prototypes().begin()); i_prot != a_analysis.prototypes().end(); ++i_prot ) { const real_type u( 1.0/(rez_sum*((*i_link).pow_distance())) ); delta_membership += SQR( (*i_link).membership()-u ); (*i_link).membership() = u; (*i_link).pow_membxweight() = weight*pow(u,a_analysis.option().fuzzifier()); (*i_prot).total_pow_membxweight() += (*i_link).pow_membxweight(); ++i_link; } } } invariant(i_link==a_analysis.links().end(),"link size match",SOURCELOC); delta_membership=sqrt(delta_membership); a_analysis.option().change() = max(delta_membership,a_analysis.option().change()); (*mp_succ_alg)(a_analysis); }// template instantiation#endif // ProbMembUpdate_SOURCE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -