TSPLIB-python-parser
====================
![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)
[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity)
[![codecov](https://codecov.io/gh/tsartsaris/TSPLIB-python-parser/branch/master/graph/badge.svg?token=WHYO2U5B4S)](https://codecov.io/gh/tsartsaris/TSPLIB-python-parser)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
This is a parser to read 2D Symmetric traveling salesman problem STSP problems data into python dict
## How to use it
- command line
```commandline
parser.py --file <filename> --plot true
```
- from python script
```python
TSPParser(filename="filename", plot_tsp=True)
```
## What it does
feed it with a file like
(***~~cheat~~***)
```commandline
NAME: ulysses16.tsp
TYPE: TSP
COMMENT: Odyssey of Ulysses (Groetschel/Padberg)
DIMENSION: 16
EDGE_WEIGHT_TYPE: GEO
DISPLAY_DATA_TYPE: COORD_DISPLAY
NODE_COORD_SECTION
1 38.24 20.42
2 39.57 26.15
3 40.56 25.32
4 36.26 23.12
5 33.48 10.54
6 37.56 12.19
7 38.42 13.11
8 37.52 20.44
9 41.23 9.10
10 41.17 13.05
11 36.08 -5.21
12 38.47 15.13
13 38.15 15.35
14 37.51 15.17
15 35.49 14.32
16 39.36 19.56
EOF
```
you will end up having a dict like
```python
{'1': (38.24, 20.42), '2': (39.57, 26.15),
'3': (40.56, 25.32), '4': (36.26, 23.12),
'5': (33.48, 10.54), '6': (37.56, 12.19),
'7': (38.42, 13.11), '8': (37.52, 20.44),
'9': (41.23, 9.1), '10': (41.17, 13.05),
'11': (36.08, -5.21), '12': (38.47, 15.13),
'13': (38.15, 15.35), '14': (37.51, 15.17),
'15': (35.49, 14.32), '16': (39.36, 19.56)}
```
***As an addon you plot the cities with matplotlib and the current route based on the order in the initial file***
![](tsp_plot.jpg)
没有合适的资源?快使用搜索试试~ 我知道了~
解析器将 tsplib 问题数据读入 python 字典_python_代码_下载
共13个文件
py:5个
license:1个
md:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 32 浏览量
2022-06-22
17:23:49
上传
评论
收藏 48KB ZIP 举报
温馨提示
这是一个解析器,用于将二维对称旅行商问题 STSP 问题数据读入 python dict 如何使用它 命令行 parser.py --file <filename> --plot true 来自 python 脚本 TSPParser(filename="filename", plot_tsp=True) 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
TSPLIB-python-parser-master.zip (13个子文件)
TSPLIB-python-parser-master
.gitignore 2KB
tsp_plot.jpg 32KB
README.md 2KB
tsplib_parser
tsp_file_parser.py 4KB
__init__.py 0B
.github
workflows
main.yml 938B
tests
__init__.py 0B
test_tsp_file_parser.py 1KB
LICENSE 34KB
coverage.xml 6KB
parser.py 857B
ulysses16.tsp 423B
requirements.txt 280B
共 13 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
- 以下是一个简化的示例,它使用pygame库来模拟烟花动画的框架.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功