
C++中使用遗传算法求解TSP问题的代码
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
本代码利用C++实现遗传算法解决旅行商问题(TSP),通过模拟自然选择和遗传机制寻找最优路径。
```cpp
const int city_num = 144; // 城市数目
const int individual_num = 2000; // 种群初始值
const int age = 500; // 遗传代数
const double varation_p = 0.1; // 变异因子
typedef struct City_xy {
int order;
double x, y;
} City_xy;
typedef struct City {
int mark;
} City;
typedef struct Population {
City city[145]; // 城市数组
double distance; // 个体城市序列距离之和
double Fitness; // 适应度
double Fitness_pi;
} Population;
```
全部评论 (0)
还没有任何评论哟~


