用遗传算法解决tsp旅行商问题

问题为:30城市TSP问题(d*=423.741 by D B Fogel)TSP Benchmark 问题

城市坐标:

41 94;37 84;54 67;25 62;7 64;2 99;68 58;71 44;5462;83 69;64 60;18 54;2260;83 46;91 38;25 38;2442;58 69;71 71;74 78;8776;18 40;13 40;82 7;62 32;58 35;45 21;41 26;44 35;4 50

程序为:

采用轮盘赌选择、基于位置交叉PBX、两点互换变异

#include<iostream>
#include<ctime>
#include<cstdlib>
#include<cmath>
#include<cstdio>
using namespace std;
const int M=100,T=500,N=30;//种群大小和迭代次数和城市个数
const double pc=0.6,pm=0.05;//交叉率、变异率
int condition[30][2]={
	{41,94},{37,84},{54,67},{25,62},{7,64},{2,99},{68,58},{71,44},{54,62},{83,69},
	{64,60},{18,54},{22,60},{83,46},{91,38},{25,38},{24,42},{58,69},{71,71},{74,78},
	{87,76},{18,40},{13,40},{82,7},{62,32},{58,35},{45,21},{41,26},{44,35},{4,50}
};//30个城市的坐标
struct chromo//构造染色体
{
	int code[N];
	double fit;
	double sumfit;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值