没有合适的资源?快使用搜索试试~ 我知道了~
遗传算法解决10城市TSP问题程序源代码.doc
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 144 浏览量
2022-05-08
14:32:02
上传
评论
收藏 56KB DOC 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/85320280/0001-8eb54787933def12c935afe62a771bc4_thumbnail-wide.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
8页
遗传算法解决10城市TSP问题程序源代码.doc
资源推荐
资源详情
资源评论
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/release/download_crawler_static/85320280/bg1.jpg)
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
#include "math.h"
#include "time.h"
#define num_C 10 //城市个数
#define N 100 //群体规模为 100
#define pc 0.9 //交叉概率为 0.9
#define pm 0.1 //变异概率为 10%
#define ps 0.6 //进行选择时保留的比例
#define genmax 200 //最大代数 200
int RandomInteger(int low,int high);
void Initial_gen(struct unit group[N]);
void Sort(struct unit group[N]);
void Copy_unit(struct unit *p1,struct unit *p2);
int search_son(int son[num_C],int k);
void Cross(struct unit *p1,struct unit *p2);
void Varation(struct unit group[N],int i);
void Evolution(struct unit group[N]);
void Calculate_cost(struct unit *p);
void Print_optimum(struct unit group[N]);
/* 定义个体信息 */
typedef struct unit
{
int path[num_C]; //个体的路径信息
int cost; //个体代价值
};
struct unit group[N]; //种群变量 group
int num_gen=0; //记录当前达到第几代
/***************************************************************************/
/* 城市间的距离信息: */
/* 北京 天津 武汉 深圳 长沙 成都 杭州 西安 拉萨 南昌 */
/* (0) (1) (2) (3) (4) (5) (6) (7) (8) (9) */
/* 北京(0) 0 118 1272 2567 1653 2097 1425 1177 3947 1574 */
/* 天津(1) 118 0 1253 2511 1633 2077 1369 1157 3961 1518 */
/* 武汉(2) 1272 1253 0 1462 380 1490 821 856 3660 385 */
/* 深圳(3) 2567 2511 1462 0 922 2335 1562 2165 3995 933 */
/* 长沙(4) 1653 1633 380 922 0 1700 1041 1135 3870 456 */
/* 成都(5) 2097 2077 1490 2335 1700 0 2311 920 2170 1920 */
/* 杭州(6) 1425 1369 821 1562 1041 2311 0 1420 4290 626 */
/* 西安(7) 1177 1157 856 2165 1135 920 1420 0 2870 1290 */
/* 拉萨(8) 3947 3961 3660 3995 3870 2170 4290 2870 0 4090 */
/* 南昌(9) 1574 1518 385 993 456 1920 626 1290 4090 0 */
/***************************************************************************/
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
老帽爬新坡
- 粉丝: 83
- 资源: 2万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)