使用python解决TSP(旅行商问题)
来源:互联网 发布:淘宝店铺托管是什么 编辑:程序博客网 时间:2024/06/06 02:59
这段时间,因为要交一篇关于旅行商问题的作业,所以在github上搜索了一下,觉得用python解决比较方便,所以给大家简单的介绍一下如何使用所给的代码:
用python实现的TSP源码: GitHub链接:https://github.com/eldrtimo/python-salesman 百度云盘链接:链接:http://pan.baidu.com/s/1i57BhGx 密码:2w4b
这段代码使用python3实现的,可以在windows的dos环境下运行,而且还要借助于numpy(它是一种开源的python数值计算扩展)。所以必须要安装python3 和 相应的numpy;
1.安装python3
2.配置python的环境变量:把python安装路径添加到path环境变量中即可;
3.安装numpy;如果已安装python,会自动识别出python安装路径,直接点next即可。
这一切准备工作结束后,然后进入dos环境(win+r,输入cmd回车),进入源代码(python-salesman-master)所在目录,我这里是E盘,输入以下命令运行即可:
运行的命令:python main.py -nfi tspfiles
运行的结果部分截图如下:
命令中的参数介绍:
python main.py --helpusage: main.py [-h] [-n] [-f] [-i] [-p] PATH [PATH ...]Parse TSP files and calculate paths using simple algorithms.positional arguments: PATH Path to directory or .tsp file. If PATH is a directory, run on all .tsp files in the directory.optional arguments: -h, --help show this help message and exit -n, --nearest calculate distance traveled by nearest neighbor heuristic -f, --furthest calculate distance traveled by furthest insertion heuristic -i, --in-order calculate the distance traveled by the in-order-tour [1..n,1] -p, --print-tours print explicit tours
0 0
- 使用python解决TSP(旅行商问题)
- 模拟退火算法解决TSP(旅行商)问题
- 旅行商问题(TSP问题)
- 贪心算法:旅行商问题(TSP)
- TSP(旅行商问题)-状压dp
- 使用蚁群算法(ACO)、遗传算法(GA)、霍普菲尔德网络(Hopfield)解决旅行商问题(TSP)
- 模拟退火算法 解决旅行商(TSP)问题
- 用遗传算法解决tsp旅行商问题
- ACO蚁群算法解决TSP旅行商问题
- C语言编写遗传算法解决TSP旅行商问题
- ACO蚁群算法解决TSP旅行商问题
- 粒子群算法(PSO)解决旅行商问题(TSP)
- 贪心解决:TSP问题(Travelling Salesman Problem)即旅行商问题
- 总(tu)结(cao)粒子群算法(PSO)解决旅行商问题(TSP)
- python实现遗传算法求解TSP旅行商问题(详细解释)
- 2-opt求解TSP(旅行商)问题的python实现
- UVa Problem 116 Unidirectional TSP (单向旅行商问题)
- 双调旅行商问题(TSP)bitonic tours
- javascript异步编程原理
- Shell 基本运算符
- 云计算市场价值爆发,两马之战日趋激烈
- 排序算法和查找算法
- 07 线程异步
- 使用python解决TSP(旅行商问题)
- 【我的Java之旅】之Java概述
- Struts2 chap02-03总结-Action设置数据
- sqlite3移植到ARM开发板
- 达内学习笔记——零初始化
- jackjson的使用
- linux内核ioremap映射的透切理解
- 51nod 1242 斐波那契数列的第N项(矩阵快速幂)
- Majority Element