From 8c585094e339400f891d31268dee6a691cc42f90 Mon Sep 17 00:00:00 2001 From: Thomas Weise Date: Sat, 19 Oct 2024 10:12:01 +0800 Subject: [PATCH] fixed typo in lower bound tour length for cn11, also added optimal tour --- moptipyapps/tsp/instance.py | 4 ++-- moptipyapps/tsp/known_optima.py | 15 +++++++++------ moptipyapps/tsp/tsplib/cn11.opt.tour | 17 +++++++++++++++++ moptipyapps/tsp/tsplib/cn11.tsp | 2 +- moptipyapps/version.py | 2 +- 5 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 moptipyapps/tsp/tsplib/cn11.opt.tour diff --git a/moptipyapps/tsp/instance.py b/moptipyapps/tsp/instance.py index 346b358d..76a01c58 100644 --- a/moptipyapps/tsp/instance.py +++ b/moptipyapps/tsp/instance.py @@ -114,7 +114,7 @@ Harbin (哈尔滨), Kunming (昆明), Wuhan (武汉), Xi'an (西安), Chongqing (重庆), Changsha (长沙), and Hong Kong (香港), determined using BaiDu Maps on 2024-10-18. -The optimal solution for this instance has length 14441 (km) and visits the +The optimal solution for this instance has length 9547 (km) and visits the cities in the following order: Shanghai (上海), Nanjing (南京), Hefei (合肥), Wuhan (武汉), Changsha (长沙), Hong Kong (香港), Kunming (昆明), Chongqing (重庆), @@ -198,7 +198,7 @@ "a280": 2579, "ali535": 202339, "att48": 10628, "att532": 27686, "bayg29": 1610, "bays29": 2020, "berlin52": 7542, "bier127": 118282, "br17": 39, "brazil58": 25395, "brd14051": 469385, "brg180": 1950, - "burma14": 3323, "ch130": 6110, "ch150": 6528, "cn11": 14441, + "burma14": 3323, "ch130": 6110, "ch150": 6528, "cn11": 9547, "d1291": 50801, "d15112": 1573084, "d1655": 62128, "d18512": 645238, "d198": 15780, "d2103": 80450, "d493": 35002, "d657": 48912, "dantzig42": 699, "dsj1000": 18660188, "eil101": 629, "eil51": 426, diff --git a/moptipyapps/tsp/known_optima.py b/moptipyapps/tsp/known_optima.py index f6267a06..9a053b86 100644 --- a/moptipyapps/tsp/known_optima.py +++ b/moptipyapps/tsp/known_optima.py @@ -36,10 +36,10 @@ #: the set of known optimal tours _TOURS: Final[tuple[str, ...]] = ( "a280", "att48", "bayg29", "bays29", "berlin52", "brg180", "ch130", - "ch150", "eil101", "eil51", "eil76", "fri26", "gr120", "gr202", "gr24", - "gr48", "gr666", "gr96", "kroA100", "kroC100", "kroD100", "lin105", - "pcb442", "pr1002", "pr76", "rd100", "st70", "tsp225", "ulysses16", - "ulysses22") + "ch150", "cn11", "eil101", "eil51", "eil76", "fri26", "gr120", "gr202", + "gr24", "gr48", "gr666", "gr96", "kroA100", "kroC100", "kroD100", + "lin105", "pcb442", "pr1002", "pr76", "rd100", "st70", "tsp225", + "ulysses16", "ulysses22") def _from_stream(stream: TextIO) -> np.ndarray: @@ -102,6 +102,9 @@ def opt_tour_from_resource(name: str) -> np.ndarray: >>> np.array2string(opt_tour_from_resource("ulysses16")) '[ 0 13 12 11 6 5 14 4 10 8 9 15 2 1 3 7]' + >>> np.array2string(opt_tour_from_resource("cn11")) + '[ 0 2 3 6 9 10 5 8 7 1 4]' + :param name: the name string :return: the optimal tour """ @@ -117,8 +120,8 @@ def list_resource_tours() -> tuple[str, ...]: >>> list_resource_tours() ('a280', 'att48', 'bayg29', 'bays29', 'berlin52', 'brg180', 'ch130', \ -'ch150', 'eil101', 'eil51', 'eil76', 'fri26', 'gr120', 'gr202', 'gr24', \ -'gr48', 'gr666', 'gr96', 'kroA100', 'kroC100', 'kroD100', 'lin105', \ +'ch150', 'cn11', 'eil101', 'eil51', 'eil76', 'fri26', 'gr120', 'gr202', \ +'gr24', 'gr48', 'gr666', 'gr96', 'kroA100', 'kroC100', 'kroD100', 'lin105', \ 'pcb442', 'pr1002', 'pr76', 'rd100', 'st70', 'tsp225', 'ulysses16', \ 'ulysses22') diff --git a/moptipyapps/tsp/tsplib/cn11.opt.tour b/moptipyapps/tsp/tsplib/cn11.opt.tour new file mode 100644 index 00000000..4eae56d5 --- /dev/null +++ b/moptipyapps/tsp/tsplib/cn11.opt.tour @@ -0,0 +1,17 @@ +NAME : cn11.opt.tour +TYPE : TOUR +DIMENSION : 11 +TOUR_SECTION +1 +3 +4 +7 +10 +11 +6 +9 +8 +2 +5 +-1 +EOF diff --git a/moptipyapps/tsp/tsplib/cn11.tsp b/moptipyapps/tsp/tsplib/cn11.tsp index ef16ad5f..78ccbae6 100644 --- a/moptipyapps/tsp/tsplib/cn11.tsp +++ b/moptipyapps/tsp/tsplib/cn11.tsp @@ -1,6 +1,6 @@ NAME: cn11 TYPE: TSP -COMMENT: The travel distances by car in km between the eleven Chinese cities Shanghai (上海), Beijing (北京), Nanjing (南京), Hefei (合肥), Harbin (哈尔滨), Kunming (昆明), Wuhan (武汉), Xi'an (西安), Chongqing (重庆), Changsha (长沙), and Hong Kong (香港), determined using BaiDu Maps on 2024-10-18. +COMMENT: The travel distances by car in km between the eleven Chinese cities Shanghai (上海), Beijing (北京), Nanjing (南京), Hefei (合肥), Harbin (哈尔滨), Kunming (昆明), Wuhan (武汉), Xi'an (西安), Chongqing (重庆), Changsha (长沙), and Hong Kong (香港), determined using BaiDu Maps on 2024-10-18. The optimal tour length is 9547. DIMENSION: 11 EDGE_WEIGHT_TYPE: EXPLICIT EDGE_WEIGHT_FORMAT: UPPER_DIAG_ROW diff --git a/moptipyapps/version.py b/moptipyapps/version.py index 9c53304f..d326999f 100644 --- a/moptipyapps/version.py +++ b/moptipyapps/version.py @@ -1,4 +1,4 @@ """An internal file with the version of the `moptipyapps` package.""" from typing import Final -__version__: Final[str] = "0.8.56" +__version__: Final[str] = "0.8.57"