lead/tsp_data/tsp_test.ipynb

2344 lines
193 KiB
Plaintext
Raw Normal View History

2025-03-17 16:40:01 +08:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['pr439.tsp', 'pla7397.tsp', 'gr96.tsp', 'rd100.tsp', 'swiss42.tsp', 'rl5934.tsp', 'pcb442.tsp', 'u2319.tsp', 'gil262.tsp', 'pcb3038.tsp', 'brazil58.tsp', 'lin105.tsp', 'brg180.tsp', 'fl417.tsp', 'tsp225.tsp', 'si1032.tsp', 'fl1400.tsp', 'nrw1379.tsp', 'd2103.tsp', 'kroA150.tsp', 'pcb1173.tsp', 'd198.tsp', 'fl1577.tsp', 'gr666.tsp', 'ch130.tsp', 'kroB100.tsp', 'bays29.tsp', 'u1060.tsp', 'berlin52.tsp', 'eil51.tsp', 'rl1304.tsp', 'u2152.tsp', 'si535.tsp', 'ulysses16.tsp', 'gr21.tsp', 'u724.tsp', 'gr24.tsp', 'kroD100.tsp', 'linhp318.tsp', 'pr299.tsp', 'rd400.tsp', 'gr202.tsp', 'vm1084.tsp', 'rat575.tsp', 'd1655.tsp', 'ch150.tsp', 'd15112.tsp', 'pr107.tsp', 'kroB200.tsp', 'dantzig42.tsp', 'hk48.tsp', 'brd14051.tsp', 'a280.tsp', 'd1291.tsp', 'gr229.tsp', 'pr264.tsp', 'pr76.tsp', 'gr17.tsp', 'd493.tsp', 'dsj1000.tsp', 'pr136.tsp', 'rat195.tsp', 'rl11849.tsp', 'att532.tsp', 'kroA100.tsp', 'fri26.tsp', 'pla85900.tsp', 'ali535.tsp', 'ulysses22.tsp', 'kroB150.tsp', 'bier127.tsp', 'kroC100.tsp', 'usa13509.tsp', 'eil76.tsp', 'pr124.tsp', 'rl1323.tsp', 'p654.tsp', 'gr431.tsp', 'rl1889.tsp', 'd657.tsp', 'eil101.tsp', 'fnl4461.tsp', 'pr2392.tsp', 'rat783.tsp', 'ts225.tsp', 'u1432.tsp', 'gr48.tsp', 'u1817.tsp', 'lin318.tsp', 'd18512.tsp', 'rl5915.tsp', 'att48.tsp', 'st70.tsp', 'rat99.tsp', 'fl3795.tsp', 'burma14.tsp', 'u159.tsp', 'pla33810.tsp', 'kroA200.tsp', 'u574.tsp', 'pr1002.tsp', 'pr152.tsp', 'gr137.tsp', 'pa561.tsp', 'gr120.tsp', 'si175.tsp', 'bayg29.tsp', 'pr226.tsp', 'vm1748.tsp', 'pr144.tsp', 'kroE100.tsp']\n"
2025-03-17 16:40:01 +08:00
]
}
],
"source": [
"import os\n",
"import numpy as np\n",
"import time\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"from tsp_algo import *\n",
"\n",
"# 获取tsp_data目录下所有tsp文件\n",
2025-05-13 15:46:02 +08:00
"data_dir = \"../\"\n",
"data_dir2 = \"../tsp_data/data/tsplib/\"\n",
2025-03-17 16:40:01 +08:00
"test_files = [f for f in os.listdir(data_dir2) if f.endswith('tsp')]\n",
"print(test_files)\n",
"\n",
"# 定义评估函数\n",
"def evaluate_tsp(tsp_func, distances):\n",
" \"\"\"评估TSP算法的性能\"\"\"\n",
" try:\n",
" # 计时并执行TSP\n",
" start_time = time.time()\n",
" path = tsp_func(distances)\n",
" end_time = time.time()\n",
" execution_time = end_time - start_time\n",
" \n",
" # 计算路径长度\n",
" total_distance = 0\n",
" n = len(distances)\n",
" for i in range(n):\n",
" total_distance += distances[path[i]][path[(i+1)%n]]\n",
" \n",
" print(f\"执行时间:{execution_time:.4f}秒, 路径长度:{total_distance:.2f}\")\n",
" return total_distance, execution_time\n",
" \n",
" except Exception as e:\n",
" print(f\"评估过程出错: {str(e)}\")\n",
" return float('inf'), float('inf')\n",
"\n",
"# 定义数据加载函数 \n",
"def load_tsp_data(filename):\n",
" \"\"\"读取TSP问题数据\"\"\"\n",
" try:\n",
" cities = []\n",
" filepath = os.path.join(data_dir2, filename)\n",
" with open(filepath, 'r') as f:\n",
" reading_coords = False\n",
" for line in f:\n",
" if line.strip() == \"NODE_COORD_SECTION\":\n",
" reading_coords = True\n",
" continue\n",
" if line.strip() == \"EOF\":\n",
" break\n",
" if reading_coords:\n",
" parts = line.strip().split()\n",
" if len(parts) == 3:\n",
" x, y = float(parts[1]), float(parts[2])\n",
" cities.append((x, y))\n",
" \n",
" # 计算距离矩阵\n",
" n = len(cities)\n",
" distances = np.zeros((n, n))\n",
" for i in range(n):\n",
" for j in range(n):\n",
" if i != j:\n",
" distances[i,j] = np.sqrt((cities[i][0] - cities[j][0])**2 + \n",
" (cities[i][1] - cities[j][1])**2)\n",
" \n",
" return distances\n",
" \n",
" except Exception as e:\n",
" print(f\"读取数据出错: {str(e)}\")\n",
" return None"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"过滤后的文件列表:\n",
"burma14.tsp: 14\n",
"ulysses16.tsp: 16\n",
"gr17.tsp: 17\n",
"gr21.tsp: 21\n",
"ulysses22.tsp: 22\n",
"gr24.tsp: 24\n",
"fri26.tsp: 26\n",
"bays29.tsp: 29\n",
"bayg29.tsp: 29\n",
"swiss42.tsp: 42\n",
"dantzig42.tsp: 42\n",
"hk48.tsp: 48\n",
"gr48.tsp: 48\n",
"att48.tsp: 48\n",
"eil51.tsp: 51\n",
"berlin52.tsp: 52\n",
"brazil58.tsp: 58\n",
"st70.tsp: 70\n",
"pr76.tsp: 76\n",
"eil76.tsp: 76\n",
"gr96.tsp: 96\n",
"rat99.tsp: 99\n",
"rd100.tsp: 100\n",
"kroB100.tsp: 100\n",
"kroD100.tsp: 100\n",
"kroA100.tsp: 100\n",
"kroC100.tsp: 100\n",
"kroE100.tsp: 100\n",
"eil101.tsp: 101\n",
"lin105.tsp: 105\n",
"pr107.tsp: 107\n",
"gr120.tsp: 120\n",
"pr124.tsp: 124\n",
"bier127.tsp: 127\n",
"ch130.tsp: 130\n",
"pr136.tsp: 136\n",
"gr137.tsp: 137\n",
"pr144.tsp: 144\n",
"kroA150.tsp: 150\n",
"ch150.tsp: 150\n",
"kroB150.tsp: 150\n",
"pr152.tsp: 152\n",
"u159.tsp: 159\n",
"si175.tsp: 175\n",
"brg180.tsp: 180\n",
"rat195.tsp: 195\n",
"d198.tsp: 198\n",
"kroB200.tsp: 200\n",
"kroA200.tsp: 200\n",
"gr202.tsp: 202\n",
"tsp225.tsp: 225\n",
"ts225.tsp: 225\n",
"pr226.tsp: 226\n",
"gr229.tsp: 229\n",
"gil262.tsp: 262\n",
"pr264.tsp: 264\n",
"a280.tsp: 280\n",
"pr299.tsp: 299\n",
"linhp318.tsp: 318\n",
"lin318.tsp: 318\n",
"rd400.tsp: 400\n",
"fl417.tsp: 417\n",
"gr431.tsp: 431\n",
"pr439.tsp: 439\n",
"pcb442.tsp: 442\n",
"d493.tsp: 493\n",
"att532.tsp: 532\n",
"si535.tsp: 535\n",
"ali535.tsp: 535\n",
"pa561.tsp: 561\n",
"u574.tsp: 574\n",
"rat575.tsp: 575\n",
"p654.tsp: 654\n",
"d657.tsp: 657\n",
"gr666.tsp: 666\n",
"u724.tsp: 724\n",
"rat783.tsp: 783\n"
]
}
],
"source": [
"def get_file_number(filename):\n",
" \"\"\"从文件名中提取数字部分\"\"\"\n",
" try:\n",
" # 假设文件名格式为\"file_123.tsp\"\n",
" number = int(''.join(filter(str.isdigit, filename)))\n",
" return number\n",
" except ValueError:\n",
" print(f\"无法从文件名提取数字: {filename}\")\n",
" return float('inf')\n",
"\n",
"# 过滤文件列表仅保留数字小于1000的文件\n",
"filtered_files = [f for f in test_files if get_file_number(f) < 1000]\n",
"\n",
"# 按数字大小排序\n",
"filtered_files.sort(key=get_file_number)\n",
"\n",
"# 更新test_files\n",
"test_files = filtered_files\n",
"\n",
"print(\"过滤后的文件列表:\")\n",
"for file in test_files:\n",
" print(f\"{file}: {get_file_number(file)}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
2025-03-17 16:40:01 +08:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"测试实例: burma14.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:38.69\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0001秒, 路径长度:38.69\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0004秒, 路径长度:32.44\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0127秒, 路径长度:38.41\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.0236秒, 路径长度:30.88\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0015秒, 路径长度:38.80\n",
"\n",
"测试实例: ulysses16.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0001秒, 路径长度:104.73\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:104.73\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0006秒, 路径长度:79.39\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0131秒, 路径长度:98.29\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.0275秒, 路径长度:75.10\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0011秒, 路径长度:104.65\n",
"\n",
"测试实例: gr17.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: gr21.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: ulysses22.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0001秒, 路径长度:89.64\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0001秒, 路径长度:89.64\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0013秒, 路径长度:76.99\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0149秒, 路径长度:89.49\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.0332秒, 路径长度:76.59\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0010秒, 路径长度:91.92\n",
"\n",
"测试实例: gr24.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: fri26.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: bays29.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: bayg29.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: swiss42.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: dantzig42.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: hk48.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: gr48.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: att48.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0003秒, 路径长度:40526.42\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0003秒, 路径长度:40526.42\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0110秒, 路径长度:37314.09\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0375秒, 路径长度:40526.42\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.0738秒, 路径长度:35594.44\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0019秒, 路径长度:37686.87\n",
"\n",
"测试实例: eil51.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0003秒, 路径长度:513.61\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0002秒, 路径长度:513.61\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0160秒, 路径长度:496.25\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0369秒, 路径长度:513.61\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.0695秒, 路径长度:465.91\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0017秒, 路径长度:458.95\n",
"\n",
"测试实例: berlin52.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0003秒, 路径长度:8980.92\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0003秒, 路径长度:8980.92\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0145秒, 路径长度:9014.89\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0420秒, 路径长度:8901.85\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.0648秒, 路径长度:7938.36\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0023秒, 路径长度:8835.06\n",
"\n",
"测试实例: brazil58.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: st70.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0003秒, 路径长度:805.53\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0003秒, 路径长度:805.53\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0586秒, 路径长度:778.99\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0601秒, 路径长度:805.53\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.0983秒, 路径长度:753.15\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0041秒, 路径长度:871.65\n",
"\n",
"测试实例: pr76.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0007秒, 路径长度:153461.92\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0007秒, 路径长度:153461.92\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0521秒, 路径长度:125936.21\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0669秒, 路径长度:145445.91\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1357秒, 路径长度:111623.46\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0041秒, 路径长度:123787.14\n",
"\n",
"测试实例: eil76.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0006秒, 路径长度:711.99\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0006秒, 路径长度:711.99\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0502秒, 路径长度:612.39\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0650秒, 路径长度:669.24\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1130秒, 路径长度:622.71\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0046秒, 路径长度:577.27\n",
"\n",
"测试实例: gr96.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0010秒, 路径长度:707.09\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0008秒, 路径长度:707.09\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0906秒, 路径长度:651.44\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0877秒, 路径长度:678.04\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1959秒, 路径长度:623.53\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0050秒, 路径长度:573.48\n",
"\n",
"测试实例: rat99.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0011秒, 路径长度:1564.72\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0014秒, 路径长度:1564.72\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.1013秒, 路径长度:1482.02\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0813秒, 路径长度:1564.72\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.2110秒, 路径长度:1377.07\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0055秒, 路径长度:1492.74\n",
"\n",
"测试实例: rd100.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0014秒, 路径长度:9941.16\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0008秒, 路径长度:9941.16\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.1103秒, 路径长度:8979.37\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0916秒, 路径长度:9941.16\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1830秒, 路径长度:8864.57\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0057秒, 路径长度:10510.18\n",
"\n",
"测试实例: kroB100.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0013秒, 路径长度:29155.04\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0013秒, 路径长度:29155.04\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.1989秒, 路径长度:25580.92\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1028秒, 路径长度:29155.04\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1727秒, 路径长度:25392.46\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0031秒, 路径长度:25679.71\n",
"\n",
"测试实例: kroD100.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0013秒, 路径长度:26950.46\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0011秒, 路径长度:26950.46\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0972秒, 路径长度:25204.27\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0926秒, 路径长度:26950.46\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1731秒, 路径长度:24720.72\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0050秒, 路径长度:26072.81\n",
"\n",
"测试实例: kroA100.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0008秒, 路径长度:26856.39\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0011秒, 路径长度:26856.39\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.1127秒, 路径长度:24307.78\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0879秒, 路径长度:26856.39\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1697秒, 路径长度:23182.14\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0055秒, 路径长度:22683.29\n",
"\n",
"测试实例: kroC100.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0011秒, 路径长度:26327.36\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0012秒, 路径长度:26327.36\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0993秒, 路径长度:25262.17\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0777秒, 路径长度:26327.36\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1771秒, 路径长度:23392.80\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0034秒, 路径长度:24294.06\n",
"\n",
"测试实例: kroE100.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0012秒, 路径长度:27587.19\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0012秒, 路径长度:27587.19\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0974秒, 路径长度:25902.00\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0787秒, 路径长度:27587.19\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1789秒, 路径长度:23845.70\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0045秒, 路径长度:25221.45\n",
"\n",
"测试实例: eil101.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0006秒, 路径长度:825.24\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0007秒, 路径长度:825.24\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.0935秒, 路径长度:702.96\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0784秒, 路径长度:847.59\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.2062秒, 路径长度:702.70\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0059秒, 路径长度:720.41\n",
"\n",
"测试实例: lin105.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0014秒, 路径长度:20362.76\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0013秒, 路径长度:20362.76\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.1062秒, 路径长度:16934.62\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0898秒, 路径长度:20362.76\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.2152秒, 路径长度:18234.30\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0048秒, 路径长度:19041.58\n",
"\n",
"测试实例: pr107.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0015秒, 路径长度:46678.15\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0010秒, 路径长度:46678.15\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.1361秒, 路径长度:52587.76\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.0982秒, 路径长度:47029.63\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1367秒, 路径长度:45055.24\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0038秒, 路径长度:51115.61\n",
"\n",
"测试实例: gr120.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: pr124.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0019秒, 路径长度:69299.43\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0014秒, 路径长度:69299.43\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.2075秒, 路径长度:65318.19\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1241秒, 路径长度:69299.43\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1977秒, 路径长度:62203.14\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0073秒, 路径长度:68371.30\n",
"\n",
"测试实例: bier127.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0022秒, 路径长度:135751.78\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0020秒, 路径长度:135751.78\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.2092秒, 路径长度:140690.94\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1129秒, 路径长度:135751.78\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1844秒, 路径长度:124341.92\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0067秒, 路径长度:138054.23\n",
"\n",
"测试实例: ch130.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0016秒, 路径长度:7575.29\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0015秒, 路径长度:7575.29\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.1986秒, 路径长度:7279.21\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1079秒, 路径长度:7575.29\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1865秒, 路径长度:7093.18\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0061秒, 路径长度:7091.76\n",
"\n",
"测试实例: pr136.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0011秒, 路径长度:120777.86\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0017秒, 路径长度:120777.86\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.2612秒, 路径长度:109587.25\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1175秒, 路径长度:118776.81\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.2230秒, 路径长度:110107.30\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0071秒, 路径长度:123247.21\n",
"\n",
"测试实例: gr137.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0016秒, 路径长度:1022.22\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0016秒, 路径长度:1022.22\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.2303秒, 路径长度:821.29\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1218秒, 路径长度:1022.22\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.4495秒, 路径长度:849.98\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0058秒, 路径长度:901.99\n",
"\n",
"测试实例: pr144.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0021秒, 路径长度:61650.72\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0013秒, 路径长度:61650.72\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.2701秒, 路径长度:73033.13\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1208秒, 路径长度:61650.72\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.1746秒, 路径长度:61399.21\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0086秒, 路径长度:60133.16\n",
"\n",
"测试实例: kroA150.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0028秒, 路径长度:33609.87\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0019秒, 路径长度:33609.87\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.3224秒, 路径长度:29966.54\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1338秒, 路径长度:33609.87\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.3611秒, 路径长度:28865.70\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0073秒, 路径长度:31060.89\n",
"\n",
"测试实例: ch150.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0021秒, 路径长度:8194.61\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0020秒, 路径长度:8194.61\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.3264秒, 路径长度:7994.29\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1287秒, 路径长度:8194.61\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.3433秒, 路径长度:7161.32\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0076秒, 路径长度:7589.72\n",
"\n",
"测试实例: kroB150.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0020秒, 路径长度:32825.75\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0018秒, 路径长度:32825.75\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.3046秒, 路径长度:31588.68\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1527秒, 路径长度:32825.75\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.3598秒, 路径长度:27629.77\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0073秒, 路径长度:29848.14\n",
"\n",
"测试实例: pr152.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0018秒, 路径长度:85702.95\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0021秒, 路径长度:85702.95\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.3183秒, 路径长度:88530.82\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1537秒, 路径长度:85702.95\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.2798秒, 路径长度:80138.53\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0075秒, 路径长度:92682.12\n",
"\n",
"测试实例: u159.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0027秒, 路径长度:54669.03\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0025秒, 路径长度:54669.03\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.4279秒, 路径长度:49981.41\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.1361秒, 路径长度:57436.69\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.3134秒, 路径长度:50450.56\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0080秒, 路径长度:51577.24\n",
"\n",
"测试实例: si175.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: brg180.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: rat195.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0029秒, 路径长度:2761.96\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0037秒, 路径长度:2761.96\n",
"\n",
"使用算法: 插入法\n",
"执行时间:0.6782秒, 路径长度:2814.57\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.2262秒, 路径长度:2761.96\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.5450秒, 路径长度:2490.60\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0096秒, 路径长度:2575.61\n",
"\n",
"测试实例: d198.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0035秒, 路径长度:18620.07\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0034秒, 路径长度:18620.07\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 插入法\n",
"执行时间:0.7665秒, 路径长度:17631.80\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.2328秒, 路径长度:18620.07\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.6346秒, 路径长度:17340.94\n",
2025-03-17 16:40:01 +08:00
"\n",
2025-05-13 15:46:02 +08:00
"使用算法: MEoH-TSP\n",
"执行时间:0.0096秒, 路径长度:19454.99\n",
2025-05-13 15:46:02 +08:00
"\n",
"测试实例: kroB200.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0048秒, 路径长度:36981.59\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0044秒, 路径长度:36981.59\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 插入法\n",
"执行时间:0.8086秒, 路径长度:35421.70\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.2236秒, 路径长度:36981.59\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.7370秒, 路径长度:33640.13\n",
2025-03-17 16:40:01 +08:00
"\n",
2025-05-13 15:46:02 +08:00
"使用算法: MEoH-TSP\n",
"执行时间:0.0096秒, 路径长度:34079.08\n",
2025-05-13 15:46:02 +08:00
"\n",
"测试实例: kroA200.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0036秒, 路径长度:35798.41\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0041秒, 路径长度:35798.41\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 插入法\n",
"执行时间:0.7806秒, 路径长度:35337.51\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.2562秒, 路径长度:35798.41\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.9131秒, 路径长度:30670.41\n",
2025-03-17 16:40:01 +08:00
"\n",
2025-05-13 15:46:02 +08:00
"使用算法: MEoH-TSP\n",
"执行时间:0.0094秒, 路径长度:33224.38\n",
2025-05-13 15:46:02 +08:00
"\n",
"测试实例: gr202.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0035秒, 路径长度:619.40\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0036秒, 路径长度:619.40\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 插入法\n",
"执行时间:0.8228秒, 路径长度:570.14\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.2452秒, 路径长度:619.40\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.9537秒, 路径长度:529.30\n",
2025-05-13 15:46:02 +08:00
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0115秒, 路径长度:559.57\n",
2025-03-17 16:40:01 +08:00
"\n",
"测试实例: tsp225.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0056秒, 路径长度:4829.00\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0053秒, 路径长度:4829.00\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 插入法\n",
"执行时间:1.1286秒, 路径长度:4468.20\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.3133秒, 路径长度:4786.42\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: AAD-TSP\n",
"执行时间:1.3025秒, 路径长度:4169.09\n",
2025-05-13 15:46:02 +08:00
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0135秒, 路径长度:4430.19\n",
2025-03-17 16:40:01 +08:00
"\n",
"测试实例: ts225.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0054秒, 路径长度:152493.55\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0043秒, 路径长度:152493.55\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 插入法\n",
"执行时间:1.1650秒, 路径长度:160009.16\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.2852秒, 路径长度:146183.10\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.7431秒, 路径长度:139697.02\n",
2025-03-17 16:40:01 +08:00
"\n",
2025-05-13 15:46:02 +08:00
"使用算法: MEoH-TSP\n",
"执行时间:0.0119秒, 路径长度:131162.09\n",
2025-05-13 15:46:02 +08:00
"\n",
"测试实例: pr226.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0060秒, 路径长度:94685.45\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0057秒, 路径长度:94685.45\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 插入法\n",
"执行时间:1.1606秒, 路径长度:91024.65\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.2520秒, 路径长度:94402.09\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.6014秒, 路径长度:86898.96\n",
2025-03-17 16:40:01 +08:00
"\n",
2025-05-13 15:46:02 +08:00
"使用算法: MEoH-TSP\n",
"执行时间:0.0098秒, 路径长度:96212.20\n",
2025-05-13 15:46:02 +08:00
"\n",
"测试实例: gr229.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0042秒, 路径长度:2014.71\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0041秒, 路径长度:2014.71\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 插入法\n",
"执行时间:1.1942秒, 路径长度:1825.83\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.2973秒, 路径长度:2014.71\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: AAD-TSP\n",
"执行时间:1.0651秒, 路径长度:1764.18\n",
2025-03-17 16:40:01 +08:00
"\n",
2025-05-13 15:46:02 +08:00
"使用算法: MEoH-TSP\n",
"执行时间:0.0106秒, 路径长度:1987.56\n",
2025-05-13 15:46:02 +08:00
"\n",
"测试实例: gil262.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0061秒, 路径长度:3241.47\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0059秒, 路径长度:3241.47\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: 插入法\n",
"执行时间:1.7562秒, 路径长度:2804.23\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.3549秒, 路径长度:3259.42\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: AAD-TSP\n",
"执行时间:1.7680秒, 路径长度:2757.03\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0148秒, 路径长度:2748.90\n",
"\n",
"测试实例: pr264.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0072秒, 路径长度:58022.86\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0077秒, 路径长度:58022.86\n",
"\n",
"使用算法: 插入法\n",
"执行时间:1.8404秒, 路径长度:58225.34\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.3514秒, 路径长度:58328.28\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:0.7800秒, 路径长度:56762.06\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0110秒, 路径长度:59000.73\n",
"\n",
"测试实例: a280.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0078秒, 路径长度:3148.11\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0067秒, 路径长度:3148.11\n",
"\n",
"使用算法: 插入法\n",
"执行时间:2.3428秒, 路径长度:3101.79\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.4005秒, 路径长度:3182.09\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:1.3379秒, 路径长度:2828.71\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0235秒, 路径长度:3448.00\n",
"\n",
"测试实例: pr299.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0080秒, 路径长度:59899.01\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0081秒, 路径长度:59899.01\n",
"\n",
"使用算法: 插入法\n",
"执行时间:2.7502秒, 路径长度:58124.45\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.4686秒, 路径长度:59665.82\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:1.6891秒, 路径长度:52408.65\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0188秒, 路径长度:61338.05\n",
"\n",
"测试实例: linhp318.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0091秒, 路径长度:54033.58\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0095秒, 路径长度:54033.58\n",
"\n",
"使用算法: 插入法\n",
"执行时间:3.3922秒, 路径长度:49454.81\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.4706秒, 路径长度:54033.58\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:2.0133秒, 路径长度:49153.11\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0179秒, 路径长度:50085.92\n",
"\n",
"测试实例: lin318.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0090秒, 路径长度:54033.58\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0100秒, 路径长度:54033.58\n",
"\n",
"使用算法: 插入法\n",
"执行时间:3.0405秒, 路径长度:49454.81\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.4989秒, 路径长度:54033.58\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:2.1533秒, 路径长度:49153.11\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0144秒, 路径长度:50085.92\n",
"\n",
"测试实例: rd400.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0146秒, 路径长度:19168.05\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0130秒, 路径长度:19168.05\n",
"\n",
"使用算法: 插入法\n",
"执行时间:6.2033秒, 路径长度:18629.98\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.6545秒, 路径长度:19168.05\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:4.0579秒, 路径长度:16644.77\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0251秒, 路径长度:17599.52\n",
"\n",
"测试实例: fl417.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0158秒, 路径长度:15114.12\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0143秒, 路径长度:15114.12\n",
"\n",
"使用算法: 插入法\n",
"执行时间:6.8448秒, 路径长度:14179.84\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.6920秒, 路径长度:15256.42\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:7.5032秒, 路径长度:13630.60\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0222秒, 路径长度:13680.66\n",
"\n",
"测试实例: gr431.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0168秒, 路径长度:2516.25\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0160秒, 路径长度:2516.25\n",
"\n",
"使用算法: 插入法\n",
"执行时间:7.8286秒, 路径长度:2214.43\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.7390秒, 路径长度:2516.25\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: AAD-TSP\n",
"执行时间:4.9121秒, 路径长度:2153.00\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0279秒, 路径长度:2263.78\n",
"\n",
"测试实例: pr439.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0166秒, 路径长度:131282.09\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0173秒, 路径长度:131282.09\n",
"\n",
"使用算法: 插入法\n",
"执行时间:8.2489秒, 路径长度:130067.88\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.7680秒, 路径长度:137778.50\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:4.0377秒, 路径长度:118466.33\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0248秒, 路径长度:134814.09\n",
"\n",
"测试实例: pcb442.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0197秒, 路径长度:61984.05\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0184秒, 路径长度:61984.05\n",
"\n",
"使用算法: 插入法\n",
"执行时间:8.5325秒, 路径长度:60891.83\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.7655秒, 路径长度:61234.77\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:4.3366秒, 路径长度:54291.55\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0263秒, 路径长度:58899.52\n",
"\n",
"测试实例: d493.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0233秒, 路径长度:43646.38\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0215秒, 路径长度:43646.38\n",
"\n",
"使用算法: 插入法\n",
"执行时间:12.0897秒, 路径长度:39982.31\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:0.9611秒, 路径长度:43710.70\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:7.7181秒, 路径长度:38869.88\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0307秒, 路径长度:43050.15\n",
"\n",
"测试实例: att532.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0246秒, 路径长度:112099.45\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0269秒, 路径长度:112099.45\n",
"\n",
"使用算法: 插入法\n",
"执行时间:14.9640秒, 路径长度:102201.61\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:1.0704秒, 路径长度:112099.45\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:9.3354秒, 路径长度:99085.86\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0358秒, 路径长度:103710.35\n",
"\n",
"测试实例: si535.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: ali535.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0307秒, 路径长度:2671.07\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0261秒, 路径长度:2671.07\n",
"\n",
"使用算法: 插入法\n",
"执行时间:16.0296秒, 路径长度:2366.95\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:1.0984秒, 路径长度:2671.07\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:12.9402秒, 路径长度:2269.30\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0365秒, 路径长度:2630.32\n",
"\n",
"测试实例: pa561.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0000秒, 路径长度:0.00\n",
"\n",
"使用算法: 插入法\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: EoH-TSP\n",
"评估过程出错: Sample larger than population or is negative\n",
"\n",
"使用算法: AAD-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"使用算法: MEoH-TSP\n",
"评估过程出错: index 0 is out of bounds for axis 0 with size 0\n",
"\n",
"测试实例: u574.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0293秒, 路径长度:46881.87\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0276秒, 路径长度:46881.87\n",
"\n",
"使用算法: 插入法\n",
"执行时间:18.8292秒, 路径长度:44144.83\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:1.2302秒, 路径长度:46881.87\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:15.4360秒, 路径长度:39154.50\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0414秒, 路径长度:46620.28\n",
"\n",
"测试实例: rat575.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0319秒, 路径长度:8449.32\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0291秒, 路径长度:8449.32\n",
"\n",
"使用算法: 插入法\n",
"执行时间:19.3889秒, 路径长度:7853.86\n",
"\n",
"使用算法: EoH-TSP\n",
"执行时间:1.4636秒, 路径长度:8430.71\n",
"\n",
"使用算法: AAD-TSP\n",
"执行时间:11.6080秒, 路径长度:7398.48\n",
"\n",
"使用算法: MEoH-TSP\n",
"执行时间:0.0455秒, 路径长度:7808.10\n",
"\n",
"测试实例: p654.tsp\n",
"\n",
"使用算法: 贪心算法\n",
"执行时间:0.0374秒, 路径长度:43411.56\n",
"\n",
"使用算法: 最近邻算法\n",
"执行时间:0.0393秒, 路径长度:43411.56\n",
"\n",
"使用算法: 插入法\n"
2025-03-17 16:40:01 +08:00
]
}
],
"source": [
"# 用于存储每个算法在每个实例上的结果 \n",
"results = {}\n",
"results_time = {}\n",
"\n",
"# 遍历每个测试实例\n",
"for test_file in test_files:\n",
" print(f\"\\n测试实例: {test_file}\")\n",
" \n",
" # 加载数据\n",
" distances = load_tsp_data(test_file)\n",
" if distances is None:\n",
" continue\n",
" \n",
" # 这里可以添加多个待评估的TSP算法\n",
" algorithms = {\n",
" \"贪心算法\": greedy_tsp,\n",
" \"最近邻算法\": nearest_neighbor_tsp,\n",
" \"插入法\": insertion_tsp,\n",
" # \"tsp_01\": tsp_01,\n",
" \"EoH-TSP\": tsp_02,\n",
" \"AAD-TSP\": tsp_04,\n",
2025-05-13 15:46:02 +08:00
" \"MEoH-TSP\": tsp_06,\n",
2025-03-17 16:40:01 +08:00
" }\n",
" \n",
" # 评估每个算法\n",
" for alg_name, alg_func in algorithms.items():\n",
" print(f\"\\n使用算法: {alg_name}\")\n",
" score, etime = evaluate_tsp(alg_func, distances)\n",
" \n",
" if alg_name not in results:\n",
" results[alg_name] = {}\n",
" if alg_name not in results_time:\n",
" results_time[alg_name] = {}\n",
" results[alg_name][test_file] = score\n",
" results_time[alg_name][test_file] = etime\n",
"\n",
"# 打印总结果\n",
"print(\"\\n所有算法在各个实例上的表现:\")\n",
"for alg_name, scores in results.items():\n",
" print(f\"\\n{alg_name}:\")\n",
" for test_file, score in scores.items():\n",
" print(f\" {test_file}: 路径长度 = {score:.2f}\")\n",
" for test_file, etime in results_time[alg_name].items():\n",
" print(f\" {test_file}: 执行时间 = {etime:.4f}秒\")\n",
"\n",
"# 将结果整理成表格\n",
"data = {}\n",
"for test_file in test_files:\n",
" instance_name = test_file.replace('.tsp', '')\n",
" data[instance_name] = {}\n",
" for alg_name in results:\n",
" if test_file in results[alg_name]:\n",
" data[instance_name][alg_name] = results[alg_name][test_file]\n",
"\n",
"# 将运行时间整理成表格\n",
"data_time = {}\n",
"for test_file in test_files:\n",
" instance_name = test_file.replace('.tsp', '')\n",
" data_time[instance_name] = {}\n",
" for alg_name in results_time:\n",
" if test_file in results_time[alg_name]:\n",
" data_time[instance_name][alg_name] = results_time[alg_name][test_file]\n",
"\n",
"import random\n",
"\n",
"# 转换为DataFrame\n",
"df_results = pd.DataFrame(data).T\n",
"df_time = pd.DataFrame(data_time).T\n",
"\n",
"# 打印结果表格\n",
"print(\"\\n各算法在不同实例上的路径长度:\")\n",
"print(df_results.round(2)) # 路径长度保留2位小数\n",
"# 统计每个算法的运行时长\n",
"print(\"\\n各算法在不同实例上的运行时长:\")\n",
"print(df_time.round(4)) # 运行时间保留4位小数\n"
]
},
{
"cell_type": "code",
"execution_count": null,
2025-03-17 16:40:01 +08:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"各算法在不同实例上的路径长度:\n",
2025-05-13 15:46:02 +08:00
" 贪心算法 最近邻算法 插入法 EoH-TSP AAD-TSP MEoH-TSP\n",
"ulysses8 38.48 38.48 37.83 38.11 37.83 38.48\n",
"ulysses16 104.73 104.73 79.39 88.25 74.14 104.65\n",
"PR76 153461.92 153461.92 125936.21 153461.92 112991.57 123787.14\n",
"eil76 711.99 711.99 612.39 669.24 622.71 577.27\n",
"GR96 707.09 707.09 651.44 641.82 571.02 573.48\n",
"eil101 825.24 825.24 702.96 847.59 702.70 720.41\n",
"CHN144 35884.30 35884.30 35048.39 35884.30 32744.18 35658.61\n",
"PBK411 1838.48 1838.48 1602.35 1835.85 1554.96 1776.60\n",
"RBU737 4416.15 4416.15 4097.20 4436.28 3870.50 4101.04\n",
"XIT1083 4584.27 4584.27 4328.99 4673.87 4051.52 4397.83\n",
2025-03-17 16:40:01 +08:00
"\n",
"各算法在不同实例上的运行时长:\n",
2025-05-13 15:46:02 +08:00
" 贪心算法 最近邻算法 插入法 EoH-TSP AAD-TSP MEoH-TSP\n",
"ulysses8 0.0000 0.0000 0.0001 0.0065 0.0169 0.0003\n",
"ulysses16 0.0001 0.0001 0.0005 0.0114 0.0243 0.0011\n",
"PR76 0.0007 0.0007 0.0446 0.0522 0.1132 0.0038\n",
"eil76 0.0008 0.0005 0.0396 0.0517 0.1012 0.0043\n",
"GR96 0.0013 0.0095 0.0993 0.0772 0.2481 0.0061\n",
"eil101 0.0006 0.0007 0.0900 0.0815 0.1857 0.0053\n",
"CHN144 0.0019 0.0024 0.2761 0.1257 0.2748 0.0072\n",
"PBK411 0.0146 0.0171 6.5032 0.7277 4.4427 0.0255\n",
"RBU737 0.0504 0.0444 40.5620 1.9295 26.4296 0.0562\n",
"XIT1083 0.0971 0.1277 121.7319 4.1403 80.2114 0.1036\n"
2025-03-17 16:40:01 +08:00
]
}
],
"source": [
"# 创建排序用的临时索引\n",
"temp_results_idx = pd.Index([int(''.join(filter(str.isdigit, idx))) for idx in df_results.index])\n",
"temp_time_idx = pd.Index([int(''.join(filter(str.isdigit, idx))) for idx in df_time.index])\n",
"\n",
"# 按数字排序但保留原始名称\n",
"df_results = df_results.iloc[temp_results_idx.argsort()]\n",
"df_time = df_time.iloc[temp_time_idx.argsort()]\n",
"\n",
"# 打印结果表格\n",
"print(\"\\n各算法在不同实例上的路径长度:\")\n",
"print(df_results.round(2)) # 路径长度保留2位小数\n",
"# 统计每个算法的运行时长 \n",
"print(\"\\n各算法在不同实例上的运行时长:\")\n",
"print(df_time.round(4)) # 运行时间保留4位小数"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
2025-05-13 15:46:02 +08:00
{
"name": "stderr",
"output_type": "stream",
"text": [
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n",
"findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei\n"
]
},
2025-03-17 16:40:01 +08:00
{
"data": {
2025-05-13 15:46:02 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABJQAAANnCAYAAABnCwJ8AAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjAsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvlHJYcgAAAAlwSFlzAAAPYQAAD2EBqD+naQAA/7pJREFUeJzs/XucllW9P/6/BhgGEBlURBRRRMxTHtI8BOUxMbUk8rC18gS2NWt3+G7BbbmVNqYG2tbyo6WpZWGmpaJl5iE1AUUUJdFQkGMC4oGDBAw43L8/+M29HZlBLhjOz+fjcT+aua611vW+uL17cL9Ya10VpVKpFAAAAABYRc3WdwEAAAAAbFwESgAAAAAUIlACAAAAoBCBEgAAAACFCJQAAAAAKESgBAAAAEAhAiUAAAAACmmxvgtYE8uWLcuMGTOy5ZZbpqKiYn2XAwAAALDRKpVKee+997LDDjukWbOVz0HaqAOlGTNmpEuXLuu7DAAAAIBNxvTp07PjjjuutM1GHShtueWWSZbfaLt27dZzNQAAAAAbr/nz56dLly7lvGVlNupAqW6ZW7t27QRKAAAAAE1gVbYVsik3AAAAAIUIlAAAAAAoRKAEAAAAQCECJQAAAAAKESgBAAAAUIhACQAAAIBCBEoAAAAAFCJQAgAAAKAQgRIAAAAAhQiUAAAAACikxfouYENQKpWydOnSLFu2bH2XAhu1Zs2apUWLFmnWTFYNAACwKdusA6Xa2tq8/fbbee+997J06dL1XQ5sEpo1a5Y2bdqkXbt2qa6uXt/lAAAAG5jZs2dn8ODB+fOf/5zJkydn2bJl6dy5c44++ugMGDAg3bt3b7Df008/nauuuiojR47MggULsssuu+T0009P//7906pVq0I1vPbaa/nDH/6Qxx9/PH//+9/zzjvvZMstt8x+++2XM888M2eddVaD/1C+aNGiPPTQQ3n22Wfz7LPP5rnnnsv8+fOz6667ZuLEiav157GxqiiVSqX1XcTqmj9/fqqrqzNv3ry0a9euUN/a2tpMnz49NTU1qa6uTtu2bdO8efNUVFSspWph01YqlbJs2bIsXrw4CxYsyMKFC7PVVltlu+2287kCAACSJK+++moOO+ywzJ49O5WVlenWrVsqKyszceLELF68OG3atMmDDz6Yww8/vF6/oUOH5qyzzkptbW06d+6cjh07Zty4cVm6dGkOOuigPPHEE2nTps0q1VBbW5sWLf5vfs2OO+6YTp06Zdq0aZk9e3aSpFevXhk2bNgKQdWLL76YT3ziEyuMuakESkVyls12htLbb7+dmpqa7LTTTmnduvX6Lgc2GVtssUW22WabzJkzJ7NmzUrLli2z9dZbr++yAACADcA3vvGNzJ49Oz179sydd96ZHXfcMUnyzjvvpG/fvrn//vtzzjnn5PXXXy//w/SUKVPSr1+/1NbWZvDgwbnwwgtTUVGRqVOn5thjj83o0aMzYMCAXH/99atUQ6lUSvv27fPNb34z55xzTrp161Y+d9ddd+Xss8/Oww8/nEsuuSRXX311vb6VlZU59NBDc9BBB+Xggw/O0qVL07dv3yb609m4bJYzlEqlUl5//fW0bds2nTp1WosVwubtn//8Z5YsWZJddtnFLCUAANjMLVy4MFtuuWWWLVuWv//979lnn33qnZ8zZ0622WablEqlvPLKK9lzzz2TLA+hbrjhhvTq1St/+ctf6vUZOXJkevbsmcrKykyfPj3bbbfdR9ZRKpUyd+7cbLXVVg2e/9GPfpT/+q//ylZbbZW33357pXvEPvHEEznyyCM3yxlKm+XOuUuXLs3SpUvTtm3b9V0KbNKqq6tTU1OT999/f32XAgAArGdLliwpPwzrg7OC6my11Vbl1Q113yFKpVLuvffeJEm/fv1W6NOjR4/sscceWbp0aYYNG7ZKdVRUVDQaJiXLl7slywOut956a5XG3BxtloFS3X/AzZs3X8+VwKatbl1ybW3teq4EAABY39q3b58uXbokWT6z6MNeffXVvPPOO2nfvn122223JMm0adMyc+bMJEnPnj0bHLfu+KhRo5qkzsWLF5d/tkVO4zbLQKmOJTiwdvmMAQAAH3T55ZcnSfr27Zs//OEPeeeddzJv3rz85S9/yRe/+MVUVFRk8ODB5c2wJ0yYkCSpqqrKDjvs0OCYdbOd6tquqbvuuitJ8vGPf7zwA8A2J5vtptwAAADAunXmmWembdu2GTRoUE4++eR65/bdd988+OCD+dznPlc+NmfOnCTLZzc19g/WdcvX6tquiXHjxuWGG25IkgwYMGCNx9uUbdYzlAAAAIB1p1QqZdKkSXnnnXfSvHnzdO/ePXvttVdatmyZcePG5aabbsq7775bbl+3/Kxly5aNjllVVZUkWbRo0RrVNnfu3Jx00klZsmRJjj/++JxxxhlrNN6mTqAEAAAArBPnn39++vfvny5dumTixImZMGFCXn755UyfPj3HH3987r333hx55JHlfVjrlr4tWbKk0TFramqSrNl+RzU1NfniF7+Y1157LXvvvXd+85vfrPZYmwuBEgAAALDWjR07NjfffHMqKytz5513pmvXruVzHTt2zNChQ9OhQ4f8/e9/L+9jVLecbe7cuSmVSg2OW7fUbWVPbluZ999/P//2b/+WJ598Ml27ds3DDz+82mNtTgRKAAAAwFo3YsSIlEqlfOxjHys/7e2D2rVrl4MPPjhJ8txzzyVJ+WlvNTU1mTFjRoPjTpo0qV7bIkqlUs4555wMGzYs22+/fR599NFGN/+mPoESAAAAsNa99957H9mmbhZS3d5JO+20Uzp16pRkeSDVkLrjhxxySOGavvnNb+Y3v/lNttlmmzzyyCPZddddC4+xuRIosV4MHz48FRUV5dff/va31R7r8ssvL4+z5ZZbZuHChavUb+DAgfVqqHtVVVWlY8eO2W233XL88cfn0ksvXaP6GrtOkdfZZ5+9wrgvvPBCvvnNb2b//fdP+/bt07Jly2y33XbZZ599csIJJ+Sqq67K008/naVLl67Qd8qUKY1eq6qqKttvv32OOeaY/O///m/mzZu32vcOAABQp24G0WuvvZbp06evcH7+/PkZPXp0kuRjH/tYkqSioiJ9+vRJktxyyy0r9Bk5cmTGjx+fysrKnHjiiYXq+f73v58bbrghW265ZR566KHsvffehfpv7lqs7wI2Bl3/60/ru4S1aspVJ6zza95+++0r/H7YYYet1li//vWvyz8vWLAg99xzT7761a+udm1LlizJW2+9lbfeeisTJ07Mn//85wwaNCh77rlnfvCDH+SUU05Z7bGbQm1tbb797W/nhhtuWGEN8ezZszN79uyMGzcuDz74YJLkxhtvzPnnn7/K4y9ZsiSzZs3KrFmz8uijj+bqq6/O73//+3zqU59q0vsAAAA2L7169UqHDh3y9ttv57TTTsvQoUPL+yjNnj07/fr1y9tvv51WrVrl5JNPLvfr379/brnlljz88MMZMmRILrzwwlRUVGTq1Knp27dvkuTcc88tz2Sq8/vf/z4XXnhhdtxxxwwfPrzeuR//+Me54oor0rp16/zxj3/MJz/5ybV785ug1Q6UZs+encGDB+fPf/5zJk+enGXLlqVz5845+uijM2DAgHTv3r3Bfk8//XSuuuqqjBw5MgsWLMguu+yS008/Pf379y/v3s6mraamJnfffXeSpG3btlmwYEHuvvvu/PSnPy28K/8zzzyT1157rd5Yt99+e+FA6dZbb81BBx2UZPkUy3nz5uWtt97K6NGj88c//jEvvfRS/vGPf+TUU09N3759c/PNN6dZs1Wb4HfBBRfU+z/DDxo9enT5/wC//vWv54ILLmiw3Qc3hPvWt76VG264IUmy/fbb57zzzkuPHj2y7bbbZtGiRZkyZUqefvrpDBs2LNOmTfvI+nr37p3LL7+8/PvixYszfvz4/L//9//yzDPPZMaMGTnhhBPy8ssvZ/vtt1+lewYAAPiwtm3b5vbbb8+XvvSljBw5Mt27d0+3bt1SWVmZiRMnZsmSJWnRokV+9rOfpXPnzuV+u+yyS26++eacc84
2025-03-17 16:40:01 +08:00
"text/plain": [
"<Figure size 1200x900 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# 提取EoH-TSP和AAD-TSP的运行时间数据\n",
"selected_algos = ['EoH-TSP', 'AAD-TSP']\n",
"df_selected = df_time[selected_algos]\n",
"\n",
"# 设置matplotlib支持中文显示\n",
"plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签\n",
"plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号\n",
"plt.rcParams['font.size'] = 16 # 设置更大的字号\n",
"\n",
"# 创建柱状图\n",
"plt.figure(figsize=(12, 9))\n",
"bar_width = 0.5\n",
"x = np.arange(len(df_selected.index))\n",
"\n",
"# 绘制柱状图\n",
"bars1 = plt.bar(x - bar_width/2, df_selected['EoH-TSP'], bar_width, label='AAD-TSP')\n",
"bars2 = plt.bar(x + bar_width/2, df_selected['AAD-TSP'], bar_width, label='EoH-TSP')\n",
"\n",
"# 在柱形上添加数值标注\n",
"for bars in [bars1, bars2]:\n",
" for bar in bars:\n",
" height = bar.get_height()\n",
" plt.text(bar.get_x() + bar.get_width()/2., height,\n",
" f'{height:.2f}',\n",
" ha='center', va='bottom',fontsize=16)\n",
"\n",
"# 设置图表属性\n",
"# plt.xlabel('测试实例')\n",
"# plt.title('在不同实例上的运行时间')\n",
"plt.xticks(x, df_selected.index, rotation=45,fontsize=20)\n",
"plt.legend(fontsize=20)\n",
"\n",
"# 调整布局避免标签被截断\n",
"plt.tight_layout()\n",
"plt.savefig('tsp_time.png',dpi=300)\n",
"plt.show()"
]
},
{
"cell_type": "code",
2025-05-13 15:46:02 +08:00
"execution_count": 5,
2025-03-17 16:40:01 +08:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
2025-05-13 15:46:02 +08:00
"测试实例: GR96.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: test\n",
2025-05-13 15:46:02 +08:00
"执行时间:0.2226秒, 路径长度:629.57\n",
2025-03-17 16:40:01 +08:00
"\n",
2025-05-13 15:46:02 +08:00
"测试实例: XIT1083.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: test\n",
2025-05-13 15:46:02 +08:00
"执行时间:169.8405秒, 路径长度:4018.53\n",
2025-03-17 16:40:01 +08:00
"\n",
2025-05-13 15:46:02 +08:00
"测试实例: RBU737.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: test\n",
2025-05-13 15:46:02 +08:00
"执行时间:60.1185秒, 路径长度:3735.38\n",
2025-03-17 16:40:01 +08:00
"\n",
2025-05-13 15:46:02 +08:00
"测试实例: ulysses16.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
"使用算法: test\n",
2025-05-13 15:46:02 +08:00
"执行时间:0.0236秒, 路径长度:74.00\n",
2025-03-17 16:40:01 +08:00
"\n",
"测试实例: PBK411.tsp\n",
"\n",
"使用算法: test\n",
2025-05-13 15:46:02 +08:00
"执行时间:8.7138秒, 路径长度:1544.15\n",
2025-03-17 16:40:01 +08:00
"\n",
"测试实例: PR76.tsp\n",
"\n",
"使用算法: test\n",
2025-05-13 15:46:02 +08:00
"执行时间:0.1272秒, 路径长度:120233.54\n",
2025-03-17 16:40:01 +08:00
"\n",
2025-05-13 15:46:02 +08:00
"测试实例: CHN144.tsp\n",
2025-03-17 16:40:01 +08:00
"\n",
2025-05-13 15:46:02 +08:00
"使用算法: test\n",
"执行时间:0.4914秒, 路径长度:33138.13\n",
"\n",
"测试实例: eil76.tsp\n",
"\n",
"使用算法: test\n",
"执行时间:0.1449秒, 路径长度:588.83\n",
"\n",
"测试实例: eil101.tsp\n",
"\n",
"使用算法: test\n",
"执行时间:0.2218秒, 路径长度:693.38\n",
"\n",
"测试实例: ulysses8.tsp\n",
"\n",
"使用算法: test\n",
"执行时间:0.0171秒, 路径长度:37.83\n",
"\n",
"算法在各个实例上的表现:\n",
"\n",
"test:\n",
" GR96.tsp: 路径长度 = 629.57\n",
" XIT1083.tsp: 路径长度 = 4018.53\n",
" RBU737.tsp: 路径长度 = 3735.38\n",
" ulysses16.tsp: 路径长度 = 74.00\n",
" PBK411.tsp: 路径长度 = 1544.15\n",
" PR76.tsp: 路径长度 = 120233.54\n",
" CHN144.tsp: 路径长度 = 33138.13\n",
" eil76.tsp: 路径长度 = 588.83\n",
" eil101.tsp: 路径长度 = 693.38\n",
" ulysses8.tsp: 路径长度 = 37.83\n",
" GR96.tsp: 执行时间 = 0.2226秒\n",
" XIT1083.tsp: 执行时间 = 169.8405秒\n",
" RBU737.tsp: 执行时间 = 60.1185秒\n",
" ulysses16.tsp: 执行时间 = 0.0236秒\n",
" PBK411.tsp: 执行时间 = 8.7138秒\n",
" PR76.tsp: 执行时间 = 0.1272秒\n",
" CHN144.tsp: 执行时间 = 0.4914秒\n",
" eil76.tsp: 执行时间 = 0.1449秒\n",
" eil101.tsp: 执行时间 = 0.2218秒\n",
" ulysses8.tsp: 执行时间 = 0.0171秒\n"
2025-03-17 16:40:01 +08:00
]
}
],
"source": [
"# 用于存储算法结果\n",
"test_results = {}\n",
"test_time = {}\n",
"\n",
"# 遍历测试实例\n",
"for test_case in test_files:\n",
" print(f\"\\n测试实例: {test_case}\")\n",
" \n",
" # 加载数据\n",
" dist_matrix = load_tsp_data(test_case)\n",
" if dist_matrix is None:\n",
" continue\n",
" \n",
" # 仅测试单个算法\n",
" test_algo = {\n",
" \"test\": tsp_05 # 这里可以改成想测试的其他算法\n",
" }\n",
" \n",
" # 评估算法\n",
" for algo_name, algo_func in test_algo.items():\n",
" print(f\"\\n使用算法: {algo_name}\")\n",
" path_length, exec_time = evaluate_tsp(algo_func, dist_matrix)\n",
" \n",
" if algo_name not in test_results:\n",
" test_results[algo_name] = {}\n",
" if algo_name not in test_time:\n",
" test_time[algo_name] = {}\n",
" \n",
" test_results[algo_name][test_case] = path_length\n",
" test_time[algo_name][test_case] = exec_time\n",
"\n",
"# 打印结果\n",
"print(\"\\n算法在各个实例上的表现:\")\n",
"for algo_name, scores in test_results.items():\n",
" print(f\"\\n{algo_name}:\")\n",
" for test_case, score in scores.items():\n",
" print(f\" {test_case}: 路径长度 = {score:.2f}\")\n",
" for test_case, etime in test_time[algo_name].items():\n",
" print(f\" {test_case}: 执行时间 = {etime:.4f}秒\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "lead",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.11"
}
},
"nbformat": 4,
"nbformat_minor": 2
}