Coverage for moptipyapps / tsp / tsplib / __init__.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.13.2, created at 2026-01-28 08:47 +0000

1""" 

2The TSPLib example data for the Traveling Salesperson Problem (TSP). 

3 

4This package does not offer anything useful except for holding the TSPLib 

5files. You can find the documentation and actual classes for solving and 

6playing around with the TSP in package :mod:`~moptipyapps.tsp`. 

7 

8The original data of TSPLib can be found at 

9<http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/>. Before doing 

10anything with these data directly, you should make sure to read the FAQ 

11<http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/TSPFAQ.html> and the 

12documentation 

13<http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/tsp95.pdf>. 

14 

151. Gerhard Reinelt. TSPLIB - A Traveling Salesman Problem Library. 

16 *ORSA Journal on Computing* 3(4):376-384. November 1991. 

17 https://doi.org/10.1287/ijoc.3.4.376. 

18 http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/ 

192. Gerhard Reinelt. *TSPLIB95.* Heidelberg, Germany: Universität 

20 Heidelberg, Institut für Angewandte Mathematik. 1995. 

21 http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/tsp95.pdf 

22""" 

23 

24from importlib import resources # nosem # noqa: RUF067 

25from typing import TextIO, cast # noqa: RUF067 

26 

27from pycommons.io.path import UTF8 # noqa: RUF067 

28 

29 

30def open_resource_stream(file_name: str) -> TextIO: # noqa: RUF067 

31 """ 

32 Open a TSPLib resource stream. 

33 

34 :param file_name: the file name of the resource 

35 :return: the stream 

36 """ 

37 return cast("TextIO", resources.files(__package__).joinpath( 

38 file_name).open("r", encoding=UTF8))