PyConcorde
==========
[![Build Status](https://travis-ci.org/jvkersch/pyconcorde.svg?branch=master)](https://travis-ci.org/jvkersch/pyconcorde)
What is it?
-----
PyConcorde is a Python wrapper around the [Concorde TSP
solver](http://www.math.uwaterloo.ca/tsp/concorde.html).
PyConcorde allows you to compute solutions to the Traveling Salesman Problem
with just a few lines of Python code. It uses the state-of-the-art Concorde
solver and provides a convenient Python layer around it.
<p align="center">
<a href="examples/us_state_capitals.py">
<img src="examples/us_state_capitals.png" alt="US state capital tour"/>
</a>
</p>
Note: until commit e065497 (pre version 0.1) PyConcorde was called PyTSP. It
was renamed to emphasize the central role of the underlying Concorde solver.
How do I install it?
------
PyConcorde runs under Python 2.7 and 3.5 and up. It needs the [Concorde TSP
solver](http://www.math.uwaterloo.ca/tsp/concorde.html) and [QSOpt linear
programming library](http://www.math.uwaterloo.ca/~bico/qsopt/). Further
instructions on building/downloading those can be found below.
To build PyConcorde, clone the repository:
git clone https://github.com/jvkersch/pyconcorde
cd pyconcorde
Then run
pip install -e .
This will download and build Concorde (and its dependency QSOpt) and then build
PyConcorde. While this may take a few minutes, downloading Concorde only
happens the first time the install script is run (unless you remove the `data`
directory).
If you already have Concorde and/or QSOpt installed (or an equivalent linear
solver), you can use those instead. Simply set the environment variable
`CONCORDE_DIR` (or `QSOPT_DIR`) to point to the folder where you installed
Concorde (or QSOpt).
Detailed instructions to build Concorde can be found at [this web
page](https://github.com/perrygeo/pytsp/wiki/Installing-Solvers).
What can I do with it?
-------
PyConcorde is a very light-weight library. The main entry point is the
`TSPSolver` class. Here we use it to read in the Berlin52 dataset, a dataset of
52 locations in Berlin (part of the TSPlib test data).
```python
>>> from concorde.tsp import TSPSolver
>>> from concorde.tests.data_utils import get_dataset_path
>>> fname = get_dataset_path("berlin52")
>>> solver = TSPSolver.from_tspfile(fname)
Problem Name: berlin52
Problem Type: TSP
52 locations in Berlin (Groetschel)
Number of Nodes: 52
Rounded Euclidean Norm (CC_EUCLIDEAN)
```
As you can see above, PyConcorde (or rather, Concorde) is somewhat chatty and
will print various message to the standard output. Now that we have a solver
instance, let's compute a solution. On my machine this is almost instantaneous.
```python
>>> solution = solver.solve()
(... output snipped for brevity ...)
```
Again, Concorde will display a variety of messages while it's running. The end
result is a `ComputedTour` object called `solution` with information about the
tour that we just computed:
```python
>>> solution.found_tour
True
>>> solution.optimal_value
7542.0
>>> solution.tour
array([ 0, 48, 31, 44, 18, 40, 7, 8, 9, 42, 32, 50, 10, 51, 13, 12, 46,
25, 26, 27, 11, 24, 3, 5, 14, 4, 23, 47, 37, 36, 39, 38, 35, 34,
33, 43, 45, 15, 28, 49, 19, 22, 29, 1, 6, 41, 20, 16, 2, 17, 30,
21], dtype=int32)
```
Other TSP solvers for Python
----------------------------
If you are looking for a pure Python TSP implementation, check
out [tsp-solver](https://github.com/dmishin/tsp-solver). It is not competitive
with Concorde in terms of speed or memory usage, but has the advantage of being
written in pure Python, which makes it more readily inspectable.
If you have another TSP algorithm that can be called from within Python, and
you want to have it added here, please open an issue.
Technical Notes
-------
PyConcorde needs Concorde and QSOpt. Downloading and building these packages
should happen automatically on Linux/Mac OS, but please file an issue if you
experience any trouble during this step.
Note that Windows is currently unsupported. If you get the library to work on
Windows, please open a ticket to describe any tweaks (or better yet, a Pull
Request).
License
-----
PyConcorde is licensed under the [Modified BSD license](COPYING). Note that
Concorde and QSOpt are released under different licenses, and that PyConcorde
does not include any code from these packages.
没有合适的资源?快使用搜索试试~ 我知道了~
TSP变压器代码_旅行商问题的变压器网络_python_Jupyter _代码_下载
共43个文件
py:9个
ipynb:6个
pt:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 155 浏览量
2022-06-22
15:20:40
上传
评论
收藏 65.85MB ZIP 举报
温馨提示
结果 网络训练(使用 RTX 2080 Ti 11GB) TSP50(1 个 GPU):运行笔记本“train_tsp_transformer_TSP50.ipynb” TSP100(2 个 GPU):运行笔记本“train_tsp_transformer_TSP100.ipynb” 网络测试 TSP50:运行笔记本“test_tsp_transformer_beamsearch_TSP50.ipynb”。最优差距:-0.004%。 TSP100:运行笔记本“test_tsp_transformer_beamsearch_TSP100.ipynb”。最优差距:0.371%。 可视化 TSP50:运行笔记本“visualization_TSP50.ipynb” TSP100:运行笔记本“visualization_TSP100.ipynb” 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
TSP_Transformer-main.zip (43个子文件)
TSP_Transformer-main
test_tsp_transformer_beamsearch_TSP50.ipynb 48KB
checkpoint
checkpoint_21-03-01--17-09-47-n100-gpu0,1.pkl 21.67MB
checkpoint_21-03-01--17-25-00-n50-gpu0.pkl 21.7MB
pic
tsp100.jpg 85KB
environment_gpu.yml 297B
data
10k_TSP50_len.pt 40KB
1000tsp50.pkl 391KB
1000tsp100.pkl 782KB
1000tsp20.pkl 157KB
10k_TSP50.pt 3.82MB
10k_TSP200.pt 15.26MB
10k_TSP100.pt 7.63MB
10k_TSP200_len.pt 40KB
10k_TSP100_len.pt 40KB
LICENSE 1KB
train_tsp_transformer_TSP100.ipynb 37KB
visualization_TSP100.ipynb 777KB
train_tsp_transformer_TSP50.ipynb 37KB
pyconcorde
MANIFEST.in 117B
concorde
tsp.py 2KB
tests
test_concorde_core.py 2KB
data
berlin52.tsp 916B
test_concorde_datagroup.py 1KB
__init__.py 0B
data_utils.py 596B
util.py 1KB
__init__.py 0B
_concorde.pyx 3KB
tools
build_manylinux.sh 463B
install_edm_osx.sh 525B
install_edm_linux.sh 532B
requirements.txt 13B
examples
us_state_capitals.tsv 2KB
us_state_capitals.png 72KB
requirements.txt 18B
us_state_capitals.py 2KB
setup.py 5KB
README.md 4KB
COPYING 1KB
.gitignore 54B
test_tsp_transformer_beamsearch_TSP100.ipynb 48KB
README.md 2KB
visualization_TSP50.ipynb 599KB
共 43 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- onenet_chongwukanhu_v06.apk
- 2022NOC软件创意编程赛项真题C++初中-决赛(有解析)
- 2022NOC软件创意编程赛项真题python初中-决赛(有解析)
- openLayer-本地数据加载 (day5)
- A题-正弦信号发生器.xdf
- 2022NOC软件创意编程赛项真题python小学高年级-决赛(有解析)
- mathml转换latex需要的xsl文件
- 2022NOC软件创意编程赛项真题图形化小学高年级-决赛(有解析)
- gbase驱动下载gbase-connector-java-8.3.81.53驱动下载
- 2022NOC软件创意编程赛项真题图形化小学低年级-决赛(有解析)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功