亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? accl.c

?? 螞蟻聚類算法源代碼(ant based clustering algorithm)
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
/*  Ant-based Clustering    Copyright (C) 2004 Julia Handl    Email: Julia.Handl@gmx.de    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*//***************************************************date: 7.4.2003author: Julia Handl (Julia.Handl@gmx.de)Description: implementation of ant-based clustering,see header file for more details***************************************************/#include <time.h>#include "accl.h"#include "tmatrix.h"#include "evaluation.h"#include "random.h"extern long idum;/***************************************************     antcolony***************************************************//* Constructor for the antcolony:   allocation of memory, storage of pointers and    initialization of random distribution*/accl::antcolony::antcolony(conf * c, grid * e) {    env = e;		       par = c;    ants = new ant[par->colonysize](c, e);    }/* Destructor for the antcolony:   deletion of memory*/accl::antcolony::~antcolony() {    delete [] ants; }/* Overloaded [] operator:   write-read access to individual ants*/accl::ant & accl::antcolony::operator[](int i) {    return ants[i];}/* Initialization of the antcolony:   initialization of the individual ants with a data element,   must preceed a call of accl::antcolony::cometolive()*/void accl::antcolony::init() {     for (int i=0; i<par->colonysize; i++) {	ants[i].init();     }}/* Main sorting routine (representing one ant "generation")   requires previous initialization with accl::antcolony::init()   requires subsequent completion with accl::antcolony::finish()*/void accl::antcolony::cometolive() {    /* initialization of counters needed       for the individual adaptation of alpha    */    if (par->adaptalpha == TRUE) {	for (int a=0; a<par->colonysize; a++) {	    ants[a].failure_ctr = 0;	    ants[a].activation_ctr = 0;	}    }    int j = 0;    /* main loop */    while (j++ < par->generation_length) {	/* random selection of one ant */	int a = int(ran0(&idum)*par->colonysize);	/* random move of the selected ant on the grid	   possibly biased by the memory 	*/	ants[a].move();	/* attempt to drop the data element at the current position	  a successful dropping operation must be followed by	  a successful picking operation (i.e. the ants keep trying	  until it finds a suitable data item)	*/	ants[a].dropandpick();	/* control of the adaptation of alpha	 */	if (par->adaptalpha == TRUE) {	    ants[a].activation_ctr++;	    /* do alpha adaptation for an ant after it has been	       active 100 times */	    if ( ants[a].activation_ctr >= 100) {		/* decrease alpha, if the ant is too successful*/		if (double(ants[a].failure_ctr) / double(ants[a].activation_ctr) <= 0.99 ) {		     ants[a].alpha -= 0.01;		     ants[a].alpha = max(ants[a].alpha, 0.01);		     ants[a].scalefactor = ants[a].alpha;		     /* reinitialize counters */		     ants[a].failure_ctr = 0;		     ants[a].activation_ctr = 0;		}		/* increase alpha, otherwise */		else {    		    ants[a].alpha += 0.01;		    ants[a].scalefactor = ants[a].alpha;// * par->mu;		    ants[a].failure_ctr = 0;		    ants[a].activation_ctr = 0;		}	    }	}    }}/* completion of the sorting process:   all ants drop their data elements    follows a call of accl::antcolony::cometolive   must preceed a statistical evaluation of the grid data*/void accl::antcolony::finish() {    for (int i=0; i<par->colonysize; i++) {    	ants[i].finish();    }}/***************************************************     memory***************************************************//* constructor for the memory:  memory allocation, iniialization and storage of a pointer to the environment*/accl::ant::memory::memory(grid * e, int s) {    env = e;    size = s;    pos = new position<int>[size];    index = new int[size];    for (int i=0; i<size; i++) {	index[i] = FREE;    }    initialized = FALSE;    ptr = 0;    braindead = TRUE;}/* destructor for the memory:       deletion of memory*/accl::ant::memory::~memory() {    delete [] index;    delete [] pos;}/* memorization of a new data element:   storage of both index and position of a   transported data item   organized as a fifo memory*/void inline accl::ant::memory::remember(int d, position<int> & p, double alpha) {   index[ptr] = d; pos[ptr] = p; ptr = (ptr+1) % size; /* activation of memory after insertion of a new data element    braindead ensures that an ant checks out    the stored position only once */ braindead = FALSE; /* start of memory use once it is "full" */ if ((initialized == FALSE) && (ptr == 0)) {     initialized = TRUE; }}/* brainstorming for a given data element:   scan the memory to look for the best matching data item   the respective grid position is stored within parameter p   the dropping probability dependent on the quality of the match is returned*/double accl::ant::memory::bestmatch(int data, position<int> &p, ant & a, int clusterphase, int lookahead) { double temp; double q; int retindex; /* loop to check similarity */ if (lookahead == TRUE) {     q = env->f(data, pos[0], a.radius, (int)(a.nsize), a.scalefactor, clusterphase); } else {     q = env->dissimilarity(data, index[0]); } retindex = 0; for (int i=1; i<size; i++) {     /* ignore free memory cells */     if (index[i] == FREE) continue;     if (lookahead == TRUE) {	 temp = env->f(data, pos[i], a.radius, int(a.nsize), a.scalefactor, clusterphase);     }     else {	 temp =  env->dissimilarity(data, index[i]);     }     if (lookahead == TRUE) {	 if (temp > q) {	     // best match so far	     retindex = i;	     // quality of match	     q = temp;	 }     }     else {	 if (temp < q) {	     // best match so far	     retindex = i;	     // quality of match	     q = temp;	 }     } } /* set position to that of best found match */ p = pos[retindex]; /* return the threshold for the use of the memory */ if (lookahead == TRUE) {   // cerr << q << " " << a.radius << " " << q/double(a.radius) << " " << a.th_drop(q) << endl;       return a.th_drop(q);       // return a.th_drop(q/a.radius); } else {     return a.th_drop(1.0-q); }}/***************************************************     ant***************************************************//* constructor for an individual ant:   initialization of individual parameter settings,   storage of pointers to the environment, memory allocation  and initialization of random distributions*/accl::ant::ant(conf * c, grid * e) {    env = e;    par = c;    /* individual parameter settings       (for now we just use the common ones)    */    kd = c->kd;    kp = c->kp;    if (c->adaptalpha == TRUE) {	alpha = ran0(&idum);	adapt = TRUE;    }    else {	alpha = c->alpha;	adapt = FALSE;    }    /* compute scaling factor for neighbourhood function ("size" of the neighbourhood) */     nsize = 0;    radius = c->radius;    if (par->weighting == TRUE) {	for (int dx=0; dx <= c->radius; dx++) {	    for (int dy=1; dy <= c->radius; dy++) {		nsize += 4*exp(-double(max(dx, dy))/double(par->radius));	    }	}    }    else {	nsize = (radius*2+1)*(radius*2+1)-1;    }    memsize = c->memorysize;    speed = (int)(0.5*c->imax);    scalefactor = alpha;    failure_ctr = 0;    activation_ctr = 0;    dat = FREE;    if (memsize > 0) {	mem = new memory(env, memsize);    }}/* destructor for an individual ant:   deletion of memory*/accl::ant::~ant() {    if (memsize > 0) delete mem;}/* initialization of an individual ant:   picking of a random data element*/void accl::ant::init() {    /* fill memory right in the beginning */    for (int i=0; i<par->memorysize; i++) {	int index = int(ran0(&idum)*(par->binsize - par->colonysize));	mem->remember(index, env->getposition(index),alpha);    }     /* pick up a random data element from the grid */    dat = env->remove_init(&pos);}/* finishing phase of ant activity:   drop carried data item at pickup position*/void accl::ant::finish() {    /* go to pickup position */    pos = lastpos;    /* drop data item at free grid position */    pos = env->searchdroppingsite(pos, dat);    env->add(pos, dat);    if (memsize > 0) {	mem->remember(dat, pos, alpha);    }    dat = FREE;}/* move of an individual ant:   if the memory is initialized, then   - determine the best match   - make a probabilistic decision whether to use the memory     (bias dependent on quality of match)   else random move*/void inline accl::ant::move() {    position<int> temp;    /* memory-based move */    if ((memsize > 0) &&	(mem->initialized == TRUE) &&	(mem->braindead == FALSE) &&	//	(ran0(&idum)-0.5 < mem->bestmatch(dat, temp, *this, par->clusterphase, par->lookahead))) {	(ran0(&idum) < mem->bestmatch(dat, temp, *this, par->clusterphase, par->lookahead))) {	    	/* go directly to the stored position */	pos = temp;	/* deactivate memory until next picking operation */	mem->braindead = TRUE;     }    /* random move */    else {	/* stepsize is randomly split in x and y part,	   orientation is also randomly determined	*/	double rnd = ran0(&idum);	int dx = (int)(ran0(&idum)*speed);	int dy = speed-dx;	if (rnd < 0.25) {	    dx = -dx;	    dy = -dy;	}	else if (rnd < 0.5) {	    dx = -dx;	}	else if (rnd < 0.75) {	    dy = -dy;	}	/* move with integrated border check (for	   toroidal grid)	*/	pos.add(dx, dy, par->imax, par->jmax);    }}    /* coupled drop and pick operation for an individual ant   a drop is tried, if it succeeds   - a new data element has to be picked up   - the grid index of all "free" data items is used     (currently randomly indexed)                                                  - the ant keeps trying until it's "loaded" again                                else the routine is finished*/void accl::ant::dropandpick() {    /* examine local neighbourhood */    double fvalue = env->f(dat, pos, radius, int(nsize), scalefactor, par->clusterphase);    /* probabilistic dropping decision */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美性做爰猛烈叫床潮| 国产精品久久久久久久久免费丝袜| 色激情天天射综合网| 成人免费观看av| 成人免费精品视频| caoporen国产精品视频| 成人高清免费观看| 色综合天天性综合| 一本久久a久久免费精品不卡| 日本高清成人免费播放| 欧美三级韩国三级日本三斤| 欧美日韩亚洲综合在线| 7777精品伊人久久久大香线蕉超级流畅 | 国产精品九色蝌蚪自拍| √…a在线天堂一区| 悠悠色在线精品| 日韩精品每日更新| 韩日欧美一区二区三区| 高清国产午夜精品久久久久久| 成人中文字幕电影| 欧美这里有精品| 91精品国产综合久久精品| 麻豆久久久久久久| 六月婷婷色综合| 国产高清不卡二三区| 91麻豆精东视频| 69堂国产成人免费视频| 亚洲精品一区二区三区在线观看 | 亚洲精品日韩综合观看成人91| 亚洲综合网站在线观看| 日本一道高清亚洲日美韩| 国产乱一区二区| 91免费视频观看| 欧美一区二区三区精品| 国产欧美日韩精品a在线观看| 亚洲黄色小视频| 久久精品国产99国产| 成人18精品视频| 欧美网站大全在线观看| 精品对白一区国产伦| 综合久久一区二区三区| 免费成人av在线| 成人黄色小视频在线观看| 欧美精品777| 国产欧美一区二区三区网站| 亚洲一区二区三区四区五区黄| 蜜臀av性久久久久蜜臀aⅴ四虎| 国产jizzjizz一区二区| 欧美精品777| 国产精品久久久久一区| 日韩精品一二三四| www.性欧美| 精品蜜桃在线看| 亚洲美女精品一区| 国产精品亚洲а∨天堂免在线| 欧美性色aⅴ视频一区日韩精品| 欧美mv日韩mv国产网站| 亚洲一区电影777| 国产激情偷乱视频一区二区三区| 欧美日韩精品三区| 国产精品成人一区二区艾草| 蜜乳av一区二区| 欧美自拍丝袜亚洲| 国产精品灌醉下药二区| 久久精品国产亚洲高清剧情介绍| 色久综合一二码| 国产欧美一区二区三区鸳鸯浴| 青青草国产精品97视觉盛宴| 91色乱码一区二区三区| 久久精品在线免费观看| 日韩高清一级片| 欧日韩精品视频| 自拍偷拍亚洲激情| 国产 欧美在线| 精品国产制服丝袜高跟| 丝袜国产日韩另类美女| 欧美在线视频日韩| 专区另类欧美日韩| 岛国av在线一区| 欧美精品一区二| 久久国产三级精品| 51精品秘密在线观看| 亚洲综合小说图片| 一本大道av伊人久久综合| 欧美激情在线一区二区三区| 国内精品写真在线观看| 日韩一级黄色片| 肉肉av福利一精品导航| 精品视频色一区| 亚洲曰韩产成在线| 色综合亚洲欧洲| 亚洲欧美激情插 | 亚洲国产精华液网站w| 极品瑜伽女神91| 欧美白人最猛性xxxxx69交| 日本中文字幕一区二区有限公司| 欧美影视一区在线| 亚洲成人av中文| 欧洲国内综合视频| 亚洲6080在线| 欧美一区二区三区影视| 日韩成人免费电影| 欧美一级高清片| 韩国一区二区三区| 久久这里只有精品首页| 激情都市一区二区| 久久看人人爽人人| 国产成人精品综合在线观看| 国产精品视频yy9299一区| 成人中文字幕在线| 亚洲码国产岛国毛片在线| 色婷婷综合久久久久中文一区二区| 亚洲精品久久久蜜桃| 欧美日韩一卡二卡三卡| 日本vs亚洲vs韩国一区三区| 欧美v亚洲v综合ⅴ国产v| 国产精品一区一区三区| 国产精品蜜臀在线观看| 91黄色激情网站| 舔着乳尖日韩一区| 欧美成人a视频| 粉嫩高潮美女一区二区三区| 17c精品麻豆一区二区免费| 色婷婷亚洲精品| 午夜精品一区在线观看| 欧美成人官网二区| 从欧美一区二区三区| 亚洲精品免费电影| 欧美一卡二卡在线| 国产成人综合自拍| 亚洲自拍偷拍图区| 日韩欧美一卡二卡| eeuss影院一区二区三区| 亚洲综合色视频| 欧美成人午夜电影| 99re在线精品| 天堂精品中文字幕在线| 久久久久久久久伊人| 99精品久久只有精品| 日韩av成人高清| 国产日韩精品一区二区三区| 色哟哟欧美精品| 精品一区二区三区在线视频| 国产精品丝袜91| 欧美男男青年gay1069videost | 91精品免费在线观看| 国产成人精品1024| 亚洲va国产天堂va久久en| 久久久国产精品不卡| 在线观看日韩一区| 国产精品影视网| 亚洲最大色网站| 国产日韩影视精品| 91精品国产入口| 91在线视频网址| 国产一区视频在线看| 亚洲成人综合网站| 国产精品灌醉下药二区| 日韩三级伦理片妻子的秘密按摩| 成人永久免费视频| 蜜臀精品久久久久久蜜臀| 日韩美女视频一区| 亚洲精品在线免费观看视频| 91福利在线看| 国产盗摄视频一区二区三区| 午夜欧美电影在线观看| 国产精品全国免费观看高清 | 久久久精品国产免费观看同学| 欧美三级电影网| 99麻豆久久久国产精品免费| 蜜桃一区二区三区在线观看| 亚洲精品久久嫩草网站秘色| 欧美韩日一区二区三区| 欧美一区二区三区日韩| 欧美综合在线视频| 99久久综合色| 国产91丝袜在线观看| 久久99九九99精品| 日本亚洲最大的色成网站www| 一区二区三区四区蜜桃 | 国产精品1区2区| 另类综合日韩欧美亚洲| 偷偷要91色婷婷| 亚洲无线码一区二区三区| 亚洲欧洲在线观看av| 国产精品996| 九九**精品视频免费播放| 日韩激情一二三区| 天天综合天天做天天综合| 一区二区高清在线| 伊人开心综合网| 亚洲人成网站在线| 亚洲女同一区二区| 最新不卡av在线| 综合网在线视频| ...xxx性欧美| 亚洲男人的天堂在线aⅴ视频| 国产精品伦理在线| 中文字幕永久在线不卡| 国产精品久久久久国产精品日日|