diff --git a/AI_cup_2020_ClaudioMaggioni.xls b/AI_cup_2020_ClaudioMaggioni.xls index 4e5e344..539d2d9 100644 Binary files a/AI_cup_2020_ClaudioMaggioni.xls and b/AI_cup_2020_ClaudioMaggioni.xls differ diff --git a/aco/ant_colony.py b/aco/ant_colony.py index d60d3d4..119c43b 100644 --- a/aco/ant_colony.py +++ b/aco/ant_colony.py @@ -17,11 +17,10 @@ def ant_colony_opt(instance): "kroA100": (0.9, 8, 0.4, 1000, 750, 100, 30), # 21378 "lin318": (0.9, 8, 0.4, 1000, 500, 32, 30), # 43171 "pcb442": (0.9, 8, 0.4, 1000, 450, 24, 3), # 52466 - "pr439": (0.9, 8, 0.4, 1000, 450, 24, 2), # 11734 - "rat783": (0.9, 8, 0.4, 1000, 450, 24, 2), # 9232 - "u1060": (0.9, 8, 0.4, 1000, 350, 6, 3), # 238025 - #"fl1577": (0.9, 8, 0.4, 1000, 50, 9, 3), # 24145 - "fl1577": (0.9, 8, 0.4, 1000, 50, 10, 5), # 24145 + "pr439": (0.9, 8, 0.4, 1000, 1000, 15, 3), # 109721 + "rat783": (0.9, 8, 0.4, 1000, 300, 28, 4), # 9218 + "u1060": (0.9, 8, 0.4, 1000, 350, 8, 10), # 235506 + "fl1577": (0.9, 8, 0.4, 1000, 50, 10, 7), # 23020 } alpha, beta, evap, weight, ants, loops, optruns = params[instance.name] diff --git a/approach.md b/approach.md new file mode 100644 index 0000000..c9f4351 --- /dev/null +++ b/approach.md @@ -0,0 +1,14 @@ +# System information + +Here is a summary of the system characteristics of the machine used to measure the execution time and +execution results for my AI cup submission: + +| Characteristic | Value | +| :------------- | :----------: | +| Machine used | Macbook Pro 2018 15" | +| OS Version | MacOS Catalina 10.15.7 | +| Kernel | Mach 19.6.0 | +| Interpreter used (Python wrapper) | CPython 3.8.3 (default, Jul 2 2020, 11:26:31) | +| Compiler used (C++ companion program) | Apple clang version 12.0.0 (clang-1200.0.32.21) | +| Compiler optimization level (C++ companion program) | `-O2` | +| CPU | Intel i7-8750H (12) @ 2.20GHz | \ No newline at end of file diff --git a/execute.md b/execute.md index d8c1603..3c21a91 100644 --- a/execute.md +++ b/execute.md @@ -10,7 +10,7 @@ one must have the following requirements: acceptable compilers). ## Execution -`cd` in the `code` directory and execute `python3 ./run.py` from the terminal. +`cd` in the `code` directory and execute `python3 ./run.py all` from the terminal. The script will automatically compile the C++ companion program and start the TSP computation for each problem. Results will be saved in `.sol` files where `` is respectively the name @@ -20,6 +20,19 @@ Execution time for each problem will be computed using the same criteria used fo Times and lengths found will be saved in a file named `results.csv` which will be located in the same directory as `run.py`. +Should it be necessary to run the TSP algorithm problem by problem (e.g. if the execution time must be measured by an +external program, +execute first the command: + +```bash +c++ -O2 -lpthread --std=c++11 -o c_prob/aco aco.cc opt.cc +``` + +Then execute `python3 run.py ` where `` is the problem name without extension + (e.g. `rat783`) + +The `c++` may not be repeated when running multiple problems in a one-by-one fashion. + ## `.sol` file contents Solution files are made up of just one line, containing a valid Python expression representing an array. The array in question contains the order in which cities must be visited, representing each city by its number. diff --git a/run.py b/run.py index e6ba8bd..89b85f3 100644 --- a/run.py +++ b/run.py @@ -3,13 +3,13 @@ import pandas as pd from aco.io_tsp import ProblemInstance from aco.TSP_solver import TSPSolver import os +import sys def run(show_plots=False, verbose=False): - os.system("rm -f " + " ".join(glob.glob("sol/*") + glob.glob("c_prob/*"))) - os.system("c++ -O2 -lpthread --std=c++11 -o c_prob/aco aco.cc opt.cc") - problems = glob.glob('./problems/*.tsp') - - problems = ["./problems/fl1577.tsp"] + os.system("rm -f " + " ".join(glob.glob("sol/*.sol") + glob.glob("c_prob/*.txt"))) + if sys.argv[1] == "all": + os.system("c++ -O2 -lpthread --std=c++11 -o c_prob/aco aco.cc opt.cc") + problems = glob.glob('./problems/*.tsp') if sys.argv[1] == "all" else [f"./problems/{sys.argv[1]}.tsp"] results = [] index = [] diff --git a/sol/fl1577.sol b/sol/fl1577.sol deleted file mode 100644 index 6cca098..0000000 --- a/sol/fl1577.sol +++ /dev/null @@ -1 +0,0 @@ -[150, 151, 141, 140, 139, 138, 137, 136, 135, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 152, 201, 153, 200, 154, 199, 155, 198, 156, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 310, 309, 308, 307, 306, 305, 304, 303, 302, 301, 300, 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 874, 873, 872, 871, 870, 869, 868, 867, 866, 865, 864, 863, 862, 861, 860, 859, 858, 857, 856, 855, 854, 853, 852, 851, 850, 849, 848, 847, 846, 845, 844, 843, 842, 841, 840, 839, 838, 837, 836, 835, 834, 833, 832, 831, 830, 829, 828, 827, 826, 825, 824, 823, 822, 821, 820, 819, 818, 817, 816, 815, 814, 813, 812, 811, 810, 809, 959, 958, 960, 957, 961, 956, 962, 955, 963, 954, 964, 965, 991, 992, 1014, 1013, 1012, 990, 966, 953, 952, 967, 989, 1011, 1048, 1010, 1063, 1069, 1062, 993, 969, 968, 951, 950, 949, 970, 988, 994, 1009, 1008, 995, 971, 987, 996, 1007, 1006, 985, 986, 972, 948, 973, 947, 974, 946, 975, 997, 1049, 1050, 1051, 1052, 1060, 1077, 1078, 1079, 1075, 1074, 1090, 1073, 1072, 1087, 1086, 1071, 1061, 1070, 1080, 1081, 1082, 1091, 1092, 1093, 1085, 1083, 1068, 1084, 1094, 1095, 1096, 1064, 1065, 1066, 1067, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1201, 1202, 1203, 1204, 1404, 1405, 1452, 1495, 1453, 1406, 1454, 1407, 1408, 1455, 1498, 1456, 1409, 1457, 1410, 1411, 1459, 1412, 1460, 1413, 1414, 1461, 1504, 1462, 1426, 1425, 1471, 1470, 1424, 1423, 1469, 1422, 1468, 1421, 1467, 1420, 1466, 1419, 1465, 1418, 1417, 1416, 1464, 1415, 1463, 1547, 1505, 1548, 1549, 1506, 1550, 1507, 1508, 1551, 1552, 1553, 1554, 1509, 1555, 1510, 1556, 1557, 1511, 1558, 1512, 1559, 1513, 1560, 1561, 1546, 1545, 1503, 1544, 1502, 1543, 1542, 1501, 1458, 1500, 1541, 1499, 1540, 1539, 1497, 1538, 1496, 1537, 1536, 1494, 1535, 1493, 1451, 1403, 1562, 1563, 1514, 1472, 1427, 1473, 1428, 1429, 1430, 1515, 1564, 1565, 1516, 1474, 1517, 1566, 1475, 1431, 1432, 1476, 1567, 1568, 1477, 1433, 1434, 1478, 1435, 1518, 1569, 1570, 1519, 1436, 1571, 1572, 1479, 1480, 1520, 1573, 1521, 1574, 1575, 1522, 1437, 1438, 1576, 1534, 1450, 1402, 1401, 1449, 1492, 1533, 1491, 1448, 1400, 1447, 1490, 1532, 1531, 1489, 1399, 1446, 1530, 1488, 1529, 1487, 1528, 1486, 1527, 1485, 1526, 1525, 1483, 1524, 1482, 1523, 1481, 1391, 1439, 1392, 1440, 1393, 1394, 1441, 1484, 1442, 1395, 1443, 1396, 1444, 1397, 1445, 1398, 1200, 1199, 1198, 1197, 1196, 1195, 1194, 1193, 1192, 1191, 1190, 1189, 1188, 1187, 1186, 1185, 1184, 1183, 1182, 1181, 1180, 1179, 1178, 1177, 1176, 1175, 1174, 1173, 1172, 1171, 1170, 1169, 1168, 1167, 1166, 1165, 1164, 1163, 1162, 1161, 1160, 1159, 1158, 1157, 1156, 1155, 1154, 1153, 1152, 1151, 1150, 1149, 1148, 1147, 1146, 1145, 1144, 1143, 1142, 1141, 1140, 1139, 1099, 1098, 1097, 1100, 1101, 1088, 1089, 1076, 1055, 1004, 1056, 1003, 1057, 1058, 1059, 936, 937, 938, 939, 980, 981, 979, 940, 978, 982, 941, 977, 942, 976, 983, 1002, 1005, 1054, 1053, 1001, 984, 1000, 999, 998, 943, 944, 945, 935, 934, 928, 933, 929, 930, 931, 932, 879, 878, 877, 876, 875, 808, 807, 745, 806, 746, 805, 747, 804, 748, 803, 880, 881, 802, 749, 750, 801, 882, 751, 752, 800, 883, 799, 753, 754, 798, 884, 885, 886, 755, 756, 887, 888, 889, 757, 758, 759, 890, 891, 892, 760, 761, 762, 893, 894, 763, 764, 895, 896, 897, 765, 766, 767, 898, 899, 768, 769, 900, 901, 770, 771, 902, 903, 772, 773, 904, 905, 774, 775, 906, 907, 776, 777, 908, 909, 778, 779, 780, 910, 911, 912, 781, 782, 913, 914, 783, 784, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 797, 796, 795, 794, 793, 792, 791, 790, 789, 788, 787, 786, 785, 727, 687, 726, 688, 725, 689, 724, 690, 723, 691, 722, 692, 721, 693, 720, 694, 719, 695, 718, 696, 717, 697, 716, 698, 715, 714, 699, 615, 608, 614, 613, 700, 713, 701, 712, 702, 711, 710, 703, 612, 611, 610, 609, 709, 708, 707, 706, 705, 704, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 607, 616, 606, 617, 605, 618, 604, 619, 603, 620, 602, 621, 601, 622, 600, 623, 599, 624, 598, 625, 597, 626, 596, 627, 595, 594, 628, 686, 728, 685, 729, 684, 730, 683, 731, 682, 732, 681, 733, 680, 734, 679, 735, 678, 736, 677, 737, 676, 738, 675, 739, 674, 740, 673, 741, 672, 742, 671, 743, 670, 744, 669, 668, 667, 666, 665, 664, 663, 662, 661, 660, 659, 658, 657, 656, 567, 655, 568, 654, 569, 653, 570, 652, 571, 651, 572, 650, 573, 649, 574, 648, 575, 647, 576, 646, 577, 645, 578, 644, 579, 643, 580, 642, 581, 641, 582, 640, 583, 639, 584, 638, 585, 637, 586, 636, 587, 635, 588, 634, 589, 633, 590, 632, 591, 631, 592, 630, 629, 593, 527, 526, 525, 524, 523, 522, 521, 520, 519, 518, 517, 516, 499, 500, 501, 470, 471, 440, 472, 439, 473, 438, 437, 474, 498, 497, 475, 436, 435, 476, 496, 495, 494, 477, 434, 478, 433, 432, 479, 493, 492, 491, 480, 431, 481, 430, 482, 429, 483, 490, 502, 489, 503, 504, 505, 484, 485, 486, 487, 488, 315, 314, 311, 312, 313, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 428, 427, 426, 425, 424, 423, 422, 421, 420, 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, 399, 398, 397, 396, 395, 394, 393, 392, 391, 390, 389, 388, 387, 386, 385, 384, 447, 446, 445, 444, 443, 442, 441, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 566, 565, 564, 563, 562, 561, 560, 559, 558, 557, 556, 383, 382, 381, 380, 379, 378, 377, 376, 375, 374, 373, 372, 371, 370, 369, 368, 367, 366, 365, 364, 363, 362, 361, 360, 359, 358, 357, 356, 355, 354, 353, 352, 351, 350, 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, 337, 336, 157, 158, 159, 160, 161, 148, 149, 147, 146, 145, 144, 143, 142, 134, 1380, 1305, 1381, 1304, 1382, 1303, 1383, 1384, 1302, 1288, 1301, 1385, 1386, 1299, 1387, 1298, 1388, 1297, 1389, 1296, 1390, 1295, 1294, 1205, 1206, 1293, 1207, 1292, 1208, 1291, 1209, 1290, 1300, 1289, 1210, 1211, 1212, 1287, 1213, 1286, 1214, 1285, 1215, 1284, 1216, 1283, 1306, 1379, 1378, 1377, 1217, 1218, 1307, 1376, 1375, 1308, 1282, 1309, 1281, 1374, 1373, 1219, 1310, 1372, 1371, 1311, 1220, 1280, 1221, 1222, 1279, 1370, 1369, 1278, 1223, 1224, 1277, 1368, 1312, 1276, 1313, 1367, 1366, 1314, 1225, 1226, 1227, 1275, 1228, 1274, 1315, 1365, 1364, 9, 8, 19, 20, 57, 56, 55, 18, 17, 7, 15, 16, 40, 41, 42, 39, 38, 43, 74, 78, 77, 75, 76, 95, 96, 97, 109, 110, 108, 111, 107, 112, 106, 113, 105, 114, 133, 132, 131, 130, 129, 128, 115, 127, 116, 126, 117, 125, 118, 119, 120, 121, 61, 50, 60, 51, 46, 59, 58, 84, 83, 69, 82, 70, 71, 52, 72, 53, 54, 73, 80, 92, 91, 81, 100, 99, 98, 93, 94, 79, 44, 37, 45, 36, 10, 6, 5, 4, 21, 22, 23, 3, 2, 1, 0, 24, 25, 14, 13, 47, 48, 35, 49, 34, 12, 11, 33, 26, 32, 27, 31, 28, 29, 30, 64, 65, 66, 67, 68, 86, 85, 122, 123, 124, 101, 102, 87, 88, 89, 103, 104, 90, 63, 62, 1363, 1316, 1273, 1229, 1230, 1272, 1317, 1362, 1318, 1271, 1231, 1232, 1319, 1361, 1360, 1320, 1270, 1233, 1269, 1234, 1235, 1267, 1236, 1266, 1237, 1265, 1238, 1264, 1239, 1263, 1240, 1262, 1241, 1242, 1261, 1260, 1243, 1244, 1259, 1245, 1258, 1246, 1257, 1247, 1256, 1248, 1255, 1249, 1250, 1251, 1254, 1252, 1253, 1336, 1337, 1338, 1339, 1335, 1340, 1334, 1333, 1341, 1342, 1343, 1344, 1332, 1345, 1331, 1346, 1347, 1330, 1348, 1329, 1349, 1328, 1350, 1351, 1352, 1327, 1353, 1326, 1354, 1325, 1355, 1324, 1356, 1323, 1322, 1268, 1321, 1359, 1358, 1357, 150] diff --git a/sysinfo.md b/sysinfo.md index 03995b0..c9f4351 100644 --- a/sysinfo.md +++ b/sysinfo.md @@ -5,8 +5,10 @@ execution results for my AI cup submission: | Characteristic | Value | | :------------- | :----------: | +| Machine used | Macbook Pro 2018 15" | | OS Version | MacOS Catalina 10.15.7 | | Kernel | Mach 19.6.0 | -| Compiler used | Apple clang version 12.0.0 (clang-1200.0.32.21) | -| Compiler optimization level | `-O2` | +| Interpreter used (Python wrapper) | CPython 3.8.3 (default, Jul 2 2020, 11:26:31) | +| Compiler used (C++ companion program) | Apple clang version 12.0.0 (clang-1200.0.32.21) | +| Compiler optimization level (C++ companion program) | `-O2` | | CPU | Intel i7-8750H (12) @ 2.20GHz | \ No newline at end of file