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

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

?? ls.c

?? 蟻群算法的程序
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*       AAAA    CCCC   OOOO   TTTTTT   SSSSS  PPPPP      AA  AA  CC     OO  OO    TT    SS      PP  PP      AAAAAA  CC     OO  OO    TT     SSSS   PPPPP      AA  AA  CC     OO  OO    TT        SS  PP      AA  AA   CCCC   OOOO     TT    SSSSS   PP################################################################    ACO algorithms for the TSP    ################################################################      Version: 1.0      File:    ls.c      Author:  Thomas Stuetzle      Purpose: implementation of local search routines      Check:   README and gpl.txt      Copyright (C) 1999  Thomas Stuetzle*//***************************************************************************    Program's name: acotsp    Ant Colony Optimization algorithms (AS, ACS, EAS, RAS, MMAS, BWAS) for the     symmetric TSP     Copyright (C) 2004  Thomas Stuetzle    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    email: stuetzle no@spam informatik.tu-darmstadt.de    mail address: Universitaet Darmstadt                  Fachbereich Informatik                  Hochschulstr. 10                  D-64283 Darmstadt		  Germany***************************************************************************/#include <stdio.h>#include <assert.h>#include <stdlib.h>#include <limits.h>#include "InOut.h"#include "TSP.h"#include "ants.h"#include "utilities.h"long int ls_flag;          /* indicates whether and which local search is used */ long int nn_ls;            /* maximal depth of nearest neighbour lists used in the 			      local search */ long int dlb_flag = TRUE;  /* flag indicating whether don't look bits are used. I recommend 			      to always use it if local search is applied */long int * generate_random_permutation( long int n )/*          FUNCTION:       generate a random permutation of the integers 0 .. n-1      INPUT:          length of the array      OUTPUT:         pointer to the random permutation      (SIDE)EFFECTS:  the array holding the random permutation is allocated in this                       function. Don't forget to free again the memory!      COMMENTS:       only needed by the local search procedures*/{   long int  i, help, node, tot_assigned = 0;   double    rnd;   long int  *r;   r = malloc(n * sizeof(int));     for ( i = 0 ; i < n; i++)      r[i] = i;   for ( i = 0 ; i < n ; i++ ) {     /* find (randomly) an index for a free unit */      rnd  = ran01 ( &seed );     node = (long int) (rnd  * (n - tot_assigned));      assert( i + node < n );     help = r[i];     r[i] = r[i+node];     r[i+node] = help;     tot_assigned++;   }   return r;}void two_opt_first( long int *tour ) /*          FUNCTION:       2-opt a tour       INPUT:          pointer to the tour that undergoes local optimization      OUTPUT:         none      (SIDE)EFFECTS:  tour is 2-opt      COMMENTS:       the neighbourhood is scanned in random order (this need                       not be the best possible choice). Concerning the speed-ups used 		      here consult, for example, Chapter 8 of		      Holger H. Hoos and Thomas Stuetzle, 		      Stochastic Local Search---Foundations and Applications, 		      Morgan Kaufmann Publishers, 2004.		      or some of the papers online available from David S. Johnson.*/{    long int c1, c2;             /* cities considered for an exchange */    long int s_c1, s_c2;         /* successor cities of c1 and c2     */    long int p_c1, p_c2;         /* predecessor cities of c1 and c2   */       long int pos_c1, pos_c2;     /* positions of cities c1, c2        */    long int i, j, h, l;    long int improvement_flag, improve_node, help, n_improves = 0, n_exchanges=0;    long int h1=0, h2=0, h3=0, h4=0;    long int radius;             /* radius of nn-search */    long int gain = 0;    long int *random_vector;    long int *pos;               /* positions of cities in tour */     long int *dlb;               /* vector containing don't look bits */       pos = malloc(n * sizeof(long int));    dlb = malloc(n * sizeof(long int));    for ( i = 0 ; i < n ; i++ ) {	pos[tour[i]] = i;	dlb[i] = FALSE;    }    improvement_flag = TRUE;    random_vector = generate_random_permutation( n );    while ( improvement_flag ) {	improvement_flag = FALSE;	for (l = 0 ; l < n; l++) {	    c1 = random_vector[l]; 	    DEBUG ( assert ( c1 < n && c1 >= 0); )		if ( dlb_flag && dlb[c1] )		    continue;	    improve_node = FALSE;	    pos_c1 = pos[c1];	    s_c1 = tour[pos_c1+1];	    radius = instance.distance[c1][s_c1];	    /* First search for c1's nearest neighbours, use successor of c1 */	    for ( h = 0 ; h < nn_ls ; h++ ) {		c2 = instance.nn_list[c1][h]; /* exchange partner, determine its position */		if ( radius > instance.distance[c1][c2] ) {		    s_c2 = tour[pos[c2]+1];		    gain =  - radius + instance.distance[c1][c2] + 			instance.distance[s_c1][s_c2] - instance.distance[c2][s_c2];		    if ( gain < 0 ) {			h1 = c1; h2 = s_c1; h3 = c2; h4 = s_c2; 			improve_node = TRUE;			goto exchange2opt;		    }		}		else 		    break;	    }      	    /* Search one for next c1's h-nearest neighbours, use predecessor c1 */	    if (pos_c1 > 0)		p_c1 = tour[pos_c1-1];	    else 		p_c1 = tour[n-1];	    radius = instance.distance[p_c1][c1];	    for ( h = 0 ; h < nn_ls ; h++ ) {		c2 = instance.nn_list[c1][h];  /* exchange partner, determine its position */		if ( radius > instance.distance[c1][c2] ) {		    pos_c2 = pos[c2];		    if (pos_c2 > 0)			p_c2 = tour[pos_c2-1];		    else 			p_c2 = tour[n-1];		    if ( p_c2 == c1 )			continue;		    if ( p_c1 == c2 )			continue;		    gain =  - radius + instance.distance[c1][c2] + 			instance.distance[p_c1][p_c2] - instance.distance[p_c2][c2];		    if ( gain < 0 ) {			h1 = p_c1; h2 = c1; h3 = p_c2; h4 = c2; 			improve_node = TRUE;			goto exchange2opt;		    }		}		else 		    break;	    }      	    if (improve_node) {	    exchange2opt:		n_exchanges++;		improvement_flag = TRUE;		dlb[h1] = FALSE; dlb[h2] = FALSE;		dlb[h3] = FALSE; dlb[h4] = FALSE;		/* Now perform move */		if ( pos[h3] < pos[h1] ) {		    help = h1; h1 = h3; h3 = help;		    help = h2; h2 = h4; h4 = help;		}		if ( pos[h3] - pos[h2] < n / 2 + 1) {		    /* reverse inner part from pos[h2] to pos[h3] */		    i = pos[h2]; j = pos[h3];		    while (i < j) {			c1 = tour[i];			c2 = tour[j];			tour[i] = c2;			tour[j] = c1;			pos[c1] = j;			pos[c2] = i;			i++; j--;		    }		}		else {		    /* reverse outer part from pos[h4] to pos[h1] */		    i = pos[h1]; j = pos[h4];		    if ( j > i )			help = n - (j - i) + 1;		    else 			help = (i - j) + 1;		    help = help / 2;		    for ( h = 0 ; h < help ; h++ ) {			c1 = tour[i];			c2 = tour[j];			tour[i] = c2;			tour[j] = c1;			pos[c1] = j;			pos[c2] = i;			i--; j++;			if ( i < 0 )			    i = n-1;			if ( j >= n )			    j = 0;		    }		    tour[n] = tour[0];		}	    } else {		dlb[c1] = TRUE;	    }      	}	if ( improvement_flag ) {	    n_improves++;	}    }    free( random_vector );    free( dlb );    free( pos );}void two_h_opt_first( long int *tour ) /*          FUNCTION:       2-h-opt a tour      INPUT:          pointer to the tour that undergoes local optimization      OUTPUT:         none      (SIDE)EFFECTS:  tour is 2-h-opt      COMMENTS:       for details on 2-h-opt see J. L. Bentley. Fast algorithms for geometric                       traveling salesman problems. ORSA Journal on Computing, 		      4(4):387--411, 1992. 		      The neighbourhood is scanned in random order (this need                       not be the best possible choice). Concerning the speed-ups used 		      here consult, for example, Chapter 8 of		      Holger H. Hoos and Thomas Stuetzle, 		      Stochastic Local Search---Foundations and Applications, 		      Morgan Kaufmann Publishers, 2004.		      or some of the papers online available from David S. Johnson.*/{    long int c1, c2;         /* cities considered for an exchange */    long int s_c1, s_c2;     /* successors of c1 and c2           */    long int p_c1, p_c2;     /* predecessors of c1 and c2         */       long int pos_c1, pos_c2;     /* positions of cities c1, c2        */    long int i, j, h, l;    long int improvement_flag, improve_node;    long int h1=0, h2=0, h3=0, h4=0, h5=0, help;    long int radius;             /* radius of nn-search */    long int gain = 0;    long int *random_vector;    long int two_move, node_move;    long int *pos;               /* positions of cities in tour */     long int *dlb;               /* vector containing don't look bits */       pos = malloc(n * sizeof(long int));    dlb = malloc(n * sizeof(long int));    for ( i = 0 ; i < n ; i++ ) {	pos[tour[i]] = i;	dlb[i] = FALSE;    }    improvement_flag = TRUE;    random_vector = generate_random_permutation( n );    while ( improvement_flag ) {	improvement_flag = FALSE; two_move = FALSE; node_move = FALSE;	for (l = 0 ; l < n; l++) {	    c1 = random_vector[l]; 	    DEBUG ( assert ( c1 < n && c1 >= 0); )		if ( dlb_flag && dlb[c1] )		    continue;	    improve_node = FALSE;	    pos_c1 = pos[c1];	    s_c1 = tour[pos_c1+1];	    radius = instance.distance[c1][s_c1];	    /* First search for c1's nearest neighbours, use successor of c1 */	    for ( h = 0 ; h < nn_ls ; h++ ) {		c2 = instance.nn_list[c1][h]; /* exchange partner, determine its position */		if ( radius > instance.distance[c1][c2] ) {		    pos_c2 = pos[c2];		    s_c2 = tour[pos_c2+1];		    gain =  - radius + instance.distance[c1][c2] + 			instance.distance[s_c1][s_c2] - instance.distance[c2][s_c2];		    if ( gain < 0 ) {			h1 = c1; h2 = s_c1; h3 = c2; h4 = s_c2; 			improve_node = TRUE; two_move = TRUE; node_move = FALSE;			goto exchange;		    }		    if (pos_c2 > 0)			p_c2 = tour[pos_c2-1];		    else 			p_c2 = tour[n-1];		    gain = - radius + instance.distance[c1][c2] + instance.distance[c2][s_c1]			+ instance.distance[p_c2][s_c2] - instance.distance[c2][s_c2]			- instance.distance[p_c2][c2]; 		    if ( c2 == s_c1 )			gain = 0;		    if ( p_c2 == s_c1 )			gain = 0;		    gain = 0;		    if ( gain < 0 ) {			h1 = c1; h2 = s_c1; h3 = c2; h4 = p_c2; h5 = s_c2; 			improve_node = TRUE; node_move = TRUE; two_move = FALSE;			goto exchange;		    }		}		else 		    break;	    }      	    /* Second search for c1's nearest neighbours, use predecessor c1 */	    if (pos_c1 > 0)		p_c1 = tour[pos_c1-1];	    else 		p_c1 = tour[n-1];	    radius = instance.distance[p_c1][c1];	    for ( h = 0 ; h < nn_ls ; h++ ) {		c2 = instance.nn_list[c1][h];  /* exchange partner, determine its position */		if ( radius > instance.distance[c1][c2] ) {		    pos_c2 = pos[c2];		    if (pos_c2 > 0)			p_c2 = tour[pos_c2-1];		    else 			p_c2 = tour[n-1];		    if ( p_c2 == c1 )			continue;		    if ( p_c1 == c2 )			continue;		    gain =  - radius + instance.distance[c1][c2] + 			instance.distance[p_c1][p_c2] - instance.distance[p_c2][c2];		    if ( gain < 0 ) {			h1 = p_c1; h2 = c1; h3 = p_c2; h4 = c2; 			improve_node = TRUE; two_move = TRUE; node_move = FALSE;			goto exchange;		    }		    s_c2 = tour[pos[c2]+1];		    gain = - radius + instance.distance[c2][c1] + instance.distance[p_c1][c2]			+ instance.distance[p_c2][s_c2] - instance.distance[c2][s_c2]			- instance.distance[p_c2][c2]; 		    if ( p_c1 == c2 )			gain = 0;		    if ( p_c1 == s_c2 )			gain = 0;		    if ( gain < 0 ) {			h1 = p_c1; h2 = c1; h3 = c2; h4 = p_c2; h5 = s_c2; 			improve_node = TRUE; node_move = TRUE; two_move = FALSE;			goto exchange;		    }		}		else 		    break;	    }      	exchange:	    if (improve_node) {		if ( two_move ) {		    improvement_flag = TRUE;		    dlb[h1] = FALSE; dlb[h2] = FALSE;		    dlb[h3] = FALSE; dlb[h4] = FALSE;		    /* Now perform move */		    if ( pos[h3] < pos[h1] ) {			help = h1; h1 = h3; h3 = help;			help = h2; h2 = h4; h4 = help;		    }		    if ( pos[h3] - pos[h2] < n / 2 + 1) {			/* reverse inner part from pos[h2] to pos[h3] */			i = pos[h2]; j = pos[h3];			while (i < j) {			    c1 = tour[i];			    c2 = tour[j];			    tour[i] = c2;			    tour[j] = c1;			    pos[c1] = j;			    pos[c2] = i;			    i++; j--;			}		    }		    else {			/* reverse outer part from pos[h4] to pos[h1] */			i = pos[h1]; j = pos[h4];			if ( j > i )			    help = n - (j - i) + 1;			else 			    help = (i - j) + 1;			help = help / 2;			for ( h = 0 ; h < help ; h++ ) {			    c1 = tour[i];			    c2 = tour[j];			    tour[i] = c2;			    tour[j] = c1;			    pos[c1] = j;			    pos[c2] = i;			    i--; j++;			    if ( i < 0 )				i = n-1;			    if ( j >= n )				j = 0;			}			tour[n] = tour[0];		    }		} else if ( node_move ) {		    improvement_flag = TRUE;		    dlb[h1] = FALSE; dlb[h2] = FALSE; dlb[h3] = FALSE; 		    dlb[h4] = FALSE; dlb[h5] = FALSE;		    /* Now perform move */		    if ( pos[h3] < pos[h1] ) {			help = pos[h1] - pos[h3];			i = pos[h3];			for ( h = 0 ; h < help ; h++ ) {			    c1 = tour[i+1];			    tour[i] = c1;			    pos[c1] = i;			    i++;			}			tour[i] = h3;			pos[h3] = i;			tour[n] = tour[0];		    } else {			/* pos[h3] > pos[h1] */ 			help = pos[h3] - pos[h1];			/*  	    if ( help < n / 2 + 1) { */			i = pos[h3];			for ( h = 0 ; h < help - 1 ; h++ ) {			    c1 = tour[i-1];			    tour[i] = c1;			    pos[c1] = i;			    i--;			}			tour[i] = h3;			pos[h3] = i;			tour[n] = tour[0];			/*  	  } */		    }  		} else {		    fprintf(stderr,"this should never occur, 2-h-opt!!\n"); 		    exit(0);		}		two_move = FALSE; node_move = FALSE;	    } else {		dlb[c1] = TRUE;	    }      	}    }    free( random_vector );    free( dlb );    free( pos );}void three_opt_first( long int *tour )/*          FUNCTION:       3-opt the tour      INPUT:          pointer to the tour that is to optimize      OUTPUT:         none      (SIDE)EFFECTS:  tour is 3-opt      COMMENT:        this is certainly not the best possible implementation of a 3-opt                       local search algorithm. In addition, it is very lengthy; the main 		      reason herefore is that awkward way of making an exchange, where 		      it is tried to copy only the shortest possible part of a tour. 		      Whoever improves the code regarding speed or solution quality, please 		      drop me the code at stuetzle no@spam informatik.tu-darmstadt.de		      The neighbourhood is scanned in random order (this need                       not be the best possible choice). Concerning the speed-ups used 		      here consult, for example, Chapter 8 of		      Holger H. Hoos and Thomas Stuetzle, 		      Stochastic Local Search---Foundations and Applications, 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩视频免费直播| 亚洲视频一区在线观看| 国产精品沙发午睡系列990531| 国产精品盗摄一区二区三区| 日韩成人免费看| 91在线精品一区二区三区| 精品久久久久99| 偷拍亚洲欧洲综合| av高清不卡在线| 久久久久久久久97黄色工厂| 亚洲狠狠爱一区二区三区| 成人h动漫精品| 久久这里都是精品| 麻豆精品一区二区| 欧美男男青年gay1069videost| 国产精品二三区| 国产一区二区三区视频在线播放| 69久久夜色精品国产69蝌蚪网| 美腿丝袜亚洲三区| 欧美色偷偷大香| 日韩理论片网站| 成人免费av网站| 久久精品人人做人人综合| 久久91精品久久久久久秒播| 欧美日本一区二区在线观看| 一级特黄大欧美久久久| 色久优优欧美色久优优| 亚洲免费伊人电影| 色综合天天综合网国产成人综合天| 日本一区二区三区视频视频| 国产一区二区三区四区五区入口| 26uuu精品一区二区在线观看| 裸体一区二区三区| 精品国产91九色蝌蚪| 黄色日韩网站视频| 久久精品一区八戒影视| 国产精品一区二区三区99| 久久一二三国产| 国产成人精品一区二区三区网站观看| 欧美大片日本大片免费观看| 六月婷婷色综合| 精品福利一区二区三区| 国产精品一卡二卡| 国产精品麻豆欧美日韩ww| 91在线国产观看| 亚洲一卡二卡三卡四卡无卡久久| 欧美色爱综合网| 色网站国产精品| 亚洲大片免费看| 日韩精品资源二区在线| 国产精品一品二品| 亚洲欧美日韩国产综合在线| 欧美中文字幕一区| 久久精品国产一区二区三区免费看| wwwwww.欧美系列| www.av亚洲| 石原莉奈一区二区三区在线观看| 日韩欧美一区在线观看| 国产馆精品极品| 亚洲理论在线观看| 日韩午夜三级在线| 成人永久免费视频| 亚洲国产视频直播| 久久精品视频在线免费观看| 91年精品国产| 麻豆一区二区在线| 亚洲人成小说网站色在线| 欧美日本不卡视频| 成人免费va视频| 丝袜脚交一区二区| 国产性做久久久久久| 一本到三区不卡视频| 激情综合色丁香一区二区| ...av二区三区久久精品| 欧美成人精品1314www| 99久久综合99久久综合网站| 日本女优在线视频一区二区| 中文字幕欧美日本乱码一线二线| 欧美亚洲日本国产| 丁香六月久久综合狠狠色| 亚洲成人高清在线| 中文字幕欧美区| 欧美成人一区二区三区在线观看| 精品欧美一区二区在线观看| 日本韩国一区二区三区视频| 黑人巨大精品欧美黑白配亚洲| 亚洲综合成人网| 国产精品久久久久久久午夜片| 日韩视频永久免费| 欧美主播一区二区三区| fc2成人免费人成在线观看播放 | 日本欧美加勒比视频| 亚洲国产成人自拍| 精品国产成人系列| 欧美日韩国产在线播放网站| 91在线一区二区| 国产91丝袜在线播放0| 免费的成人av| 午夜激情综合网| 亚洲一区二区三区免费视频| 中文在线免费一区三区高中清不卡| 欧美成人a∨高清免费观看| 欧美日韩五月天| 欧美在线不卡视频| 一本色道久久综合亚洲aⅴ蜜桃| 成人性色生活片免费看爆迷你毛片| 麻豆久久久久久| 久草精品在线观看| 日本vs亚洲vs韩国一区三区| 午夜精品福利久久久| 亚洲福利电影网| 夜夜嗨av一区二区三区网页 | 欧美久久久久久久久久| 色综合久久久久综合体桃花网| 夫妻av一区二区| 粉嫩高潮美女一区二区三区| 国产精品小仙女| 国产suv一区二区三区88区| 国产麻豆日韩欧美久久| 久久99国产精品免费网站| 黑人巨大精品欧美一区| 狠狠色丁香婷婷综合| 国产米奇在线777精品观看| 国产精品一区二区三区99| 大白屁股一区二区视频| 成人黄色电影在线| 一本大道av一区二区在线播放| 色噜噜狠狠一区二区三区果冻| 91传媒视频在线播放| 欧美私人免费视频| 欧美一区二区久久| 国产欧美日韩在线| 日韩毛片视频在线看| 性久久久久久久久久久久| 麻豆精品国产91久久久久久| 久久成人免费网| 高清久久久久久| 91久久线看在观草草青青| 欧美疯狂性受xxxxx喷水图片| 91麻豆精品国产| 国产视频一区二区在线| 亚洲精品亚洲人成人网在线播放| 午夜精品一区二区三区免费视频 | 欧美日韩一区二区三区在线看| 欧美精品日韩精品| 久久久影视传媒| 亚洲影院免费观看| 国产最新精品免费| 日本高清不卡aⅴ免费网站| 欧美一区二区三区公司| 欧美激情自拍偷拍| 天堂精品中文字幕在线| 国产精品白丝av| 欧美日韩久久久久久| 国产欧美一区二区精品秋霞影院| 一个色综合网站| 国产成人av影院| 欧美人与z0zoxxxx视频| 国产精品久久三区| 蜜臀精品久久久久久蜜臀| 色综合久久88色综合天天6| 精品成人一区二区三区四区| 一区二区国产视频| 国产精品羞羞答答xxdd| 欧美日韩国产另类不卡| 日本一区免费视频| 麻豆精品久久久| 色女孩综合影院| 国产嫩草影院久久久久| 美日韩一区二区三区| 91国偷自产一区二区开放时间| 精品国产成人在线影院| 日韩精品成人一区二区三区| 成人国产亚洲欧美成人综合网| 日韩一级欧美一级| 亚洲国产精品一区二区www在线| 国产成人av电影在线| 欧美一区二区三区四区久久| 亚洲精品伦理在线| 成人18精品视频| 国产欧美一区二区三区在线老狼| 欧美aaaaa成人免费观看视频| 色综合久久中文综合久久牛| 亚洲国产成人私人影院tom| 韩国理伦片一区二区三区在线播放| 9191精品国产综合久久久久久| 亚洲美腿欧美偷拍| 91小宝寻花一区二区三区| 国产嫩草影院久久久久| 激情小说欧美图片| 精品久久久影院| 国产在线一区二区综合免费视频| 7777精品伊人久久久大香线蕉完整版 | 最新日韩在线视频| 成人av在线资源| 亚洲色大成网站www久久九九| 成人av电影观看| 亚洲精品菠萝久久久久久久| 一本久久综合亚洲鲁鲁五月天| 一区在线观看视频|