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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? accl.c~

?? 螞蟻聚類算法源代碼(ant based clustering algorithm)
?? C~
?? 第 1 頁 / 共 2 頁
字號:
/*  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) {         return a.th_drop(q/double(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))) {	    	/* 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 */    if (ran0(&idum) < th_drop(fvalue)) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品天干天干在观线| 玉足女爽爽91| 亚洲女同一区二区| 日本视频中文字幕一区二区三区| 国产精品一区二区你懂的| 欧美伊人久久大香线蕉综合69| 日韩精品一区二区三区在线播放 | 欧美另类久久久品| 国产精品女同互慰在线看| 日本欧美一区二区三区| 91免费看`日韩一区二区| www欧美成人18+| 日韩高清不卡一区二区| 欧美在线观看视频一区二区三区 | 东方aⅴ免费观看久久av| 91精品国产色综合久久ai换脸 | 男男gaygay亚洲| 欧日韩精品视频| 亚洲日本丝袜连裤袜办公室| 国产精品一区在线观看乱码| 91精品一区二区三区在线观看| 综合激情网...| 成人爱爱电影网址| 国产校园另类小说区| 精品中文av资源站在线观看| 欧美肥妇free| 视频一区国产视频| 在线成人av网站| 亚洲成人一区在线| 欧美三级在线播放| 亚洲一区影音先锋| 欧美三级电影网站| 亚洲国产精品一区二区久久恐怖片| 91视视频在线观看入口直接观看www | 欧美伊人久久大香线蕉综合69| 亚洲少妇屁股交4| 一本一道久久a久久精品| 亚洲黄一区二区三区| 色欧美片视频在线观看| 亚洲综合小说图片| 欧美另类z0zxhd电影| 日韩国产在线一| 91精品国模一区二区三区| 日本美女一区二区三区视频| 精品三级av在线| 国产大陆精品国产| 国产精品国产三级国产| 一本大道久久a久久综合| 亚洲国产一区二区视频| 欧美三级在线看| 韩国三级电影一区二区| 久久理论电影网| 99riav久久精品riav| 伊人开心综合网| 4438亚洲最大| 国产成人丝袜美腿| 亚洲精品自拍动漫在线| 欧美妇女性影城| 国产在线国偷精品产拍免费yy| 中文字幕免费观看一区| 欧美亚洲国产怡红院影院| 热久久久久久久| 亚洲国产精品成人综合| 在线观看网站黄不卡| 黄页网站大全一区二区| 自拍偷拍亚洲欧美日韩| 91精品欧美一区二区三区综合在| 国内成+人亚洲+欧美+综合在线| 一区精品在线播放| 欧美一卡二卡三卡| 成人免费看视频| 日韩中文字幕区一区有砖一区| 久久日韩精品一区二区五区| 日本道免费精品一区二区三区| 天堂va蜜桃一区二区三区漫画版| 久久精品亚洲精品国产欧美kt∨ | 亚洲欧美激情在线| 日韩精品资源二区在线| 91蜜桃免费观看视频| 久久成人免费日本黄色| 一区二区三区四区在线免费观看| 日韩精品中文字幕一区二区三区 | 欧美不卡视频一区| 色噜噜久久综合| 国产一区二区三区在线看麻豆| 亚洲精品乱码久久久久| 久久久蜜桃精品| 欧美精品丝袜久久久中文字幕| 成人91在线观看| 激情六月婷婷久久| 首页国产欧美日韩丝袜| 成人免费小视频| 国产喂奶挤奶一区二区三区| 91精品国产综合久久精品麻豆| 91在线一区二区| 国产一区二区不卡在线| 日产国产高清一区二区三区| 亚洲激情欧美激情| 中文字幕亚洲综合久久菠萝蜜| 欧美mv日韩mv国产网站app| 欧美中文字幕一区| 色婷婷综合久久久久中文| 成人午夜激情影院| 国产精品一区二区不卡| 黑人巨大精品欧美黑白配亚洲| 天天操天天干天天综合网| 一二三区精品视频| 亚洲欧洲综合另类在线| 国产精品嫩草久久久久| 国产亚洲综合性久久久影院| 欧美成人性福生活免费看| 欧美一级一区二区| 欧美一级在线视频| 日韩亚洲欧美一区| 日韩欧美亚洲国产精品字幕久久久| 欧美日韩一卡二卡三卡 | 久久综合久久久久88| 欧美一区二区三区性视频| 欧美日韩精品综合在线| 欧美日韩精品欧美日韩精品一 | 日韩成人伦理电影在线观看| 水蜜桃久久夜色精品一区的特点| 亚洲a一区二区| 日韩国产成人精品| 美女在线视频一区| 黄页网站大全一区二区| 国产91丝袜在线18| 色伊人久久综合中文字幕| 欧美偷拍一区二区| 欧美日本韩国一区二区三区视频| 欧美日韩一本到| 欧美一区二区二区| 久久久噜噜噜久噜久久综合| 中文字幕巨乱亚洲| 亚洲精品一二三| 日日嗨av一区二区三区四区| 男男视频亚洲欧美| 粉嫩嫩av羞羞动漫久久久 | 国产精品国产三级国产aⅴ中文 | 亚洲欧洲三级电影| 一区二区三区在线视频观看58| 亚洲成人综合视频| 国产精品一区二区在线观看网站| 成人av综合一区| 欧美日韩aaaaa| 精品成人一区二区三区四区| 亚洲国产高清在线| 亚洲午夜视频在线| 国产在线精品一区在线观看麻豆| caoporm超碰国产精品| 欧美日韩成人在线| 国产亚洲精久久久久久| 亚洲一区二区欧美日韩 | 久久久影视传媒| 亚洲欧美一区二区在线观看| 日日夜夜精品视频天天综合网| 国产精品一卡二卡在线观看| 欧美在线免费观看亚洲| wwwwxxxxx欧美| 一区二区三区 在线观看视频| 久久疯狂做爰流白浆xx| 欧美性猛片aaaaaaa做受| 国产人成一区二区三区影院| 亚洲国产综合色| 成人精品视频网站| 日韩一级精品视频在线观看| 自拍偷拍亚洲激情| 国产一区不卡视频| 欧美视频在线播放| 国产三级精品三级| 喷白浆一区二区| 欧美日韩一区二区三区高清| 国产精品黄色在线观看| 国产一区在线视频| 欧美精品 国产精品| 亚洲精品v日韩精品| 成人午夜免费视频| 欧美sm极限捆绑bd| 日韩专区中文字幕一区二区| 91丨porny丨中文| 国产精品三级电影| 九九国产精品视频| 欧美一区二区三区男人的天堂| 亚洲综合丁香婷婷六月香| 成人a免费在线看| 国产日韩欧美不卡| 国产高清在线精品| 精品国产a毛片| 久久国产尿小便嘘嘘尿| 在线播放中文一区| 首页亚洲欧美制服丝腿| 在线观看一区二区精品视频| 亚洲人成伊人成综合网小说| 成人免费视频视频在线观看免费 | 亚洲最大成人网4388xx| 99r国产精品| 亚洲精品一卡二卡| 欧美优质美女网站| 亚洲国产精品一区二区尤物区| 在线视频一区二区三|