Hash Functions for Combinatorial Optimisation Problems
Fitness functions are a measure of solution quality. However they fail to differentiate between different solutions with the same fitness, and this lack of ability to distinguish between solutions can have a detrimental effect on the search process. In this work, we investigate, for the Travelling Salesman Problem (TSP) (and soon other problems), the impact of using a hash function to differentiate solutions during the search process. We first introduce a new efficient hash function that minimises the risk of collision (two different permutations having identical hash values). We then analyse its impact on three different metaheuristics: Iterative Local Search (ILS), Genetic Algorithm (GA) and Memetic Algorithm (MA). Experiments conducted on the TSP show that the use of our hash function is more efficient to detect cycles in ILS and provides a more relevant convergence rate of a population in GA and MA. Whereas this work is not intended to provide an improvement over the state-of-the-art, it nevertheless reveals a positive effect when using the hash functions during the optimisation process.
Source Code
Solution Samples
Collision Computations
Instance | |SLO| | CLO | FitLO | |Srand| | Crand | Fitrand |
---|---|---|---|---|---|---|
berlin52 | 2,708 | 5,495 | 799 | 27,040 | 64,662 | 6,833 |
st70 | 4,904 | 229,647 | 99 | 49,000 | 1,876,506 | 1,170 |
eil76 | 5,793 | 456,422 | 72 | 57,760 | 4,140,456 | 766 |
pr76 | 5,789 | 2,838 | 3,788 | 57,760 | 18,107 | 43,331 |
gr96 | 9,216 | 10,633 | 3,872 | 92,160 | 71,134 | 49,124 |
rat99 | 9,847 | 457,303 | 189 | 98,010 | 3,317,137 | 2,613 |
kroA100 | 10,007 | 30,902 | 2,163 | 100,000 | 170,251 | 32,619 |
kroB100 | 10,014 | 32,978 | 2,028 | 100,000 | 172,655 | 32,317 |
kroC100 | 10,001 | 30,277 | 2,168 | 100,000 | 169,127 | 32,881 |
kroD100 | 10,007 | 30,805 | 2,034 | 100,000 | 185,716 | 30,723 |
kroE100 | 10,020 | 33,600 | 1,970 | 100,000 | 167,732 | 33,161 |
rd100 | 10,001 | 71,443 | 1,025 | 100,000 | 598,845 | 12,060 |
eil101 | 10,211 | 1,376,150 | 80 | 102,010 | 10,621,646 | 975 |
lin105 | 11,043 | 59,275 | 1,443 | 110,250 | 288,911 | 26,055 |
pr107 | 11,455 | 41,307 | 2,549 | 114,490 | 58,422 | 73,334 |
pr124 | 15,384 | 36,773 | 4,028 | 153,760 | 116,389 | 82,802 |
bier127 | 16,153 | 17,641 | 7,199 | 161,290 | 187,417 | 68,143 |
ch130 | 16,903 | 350,821 | 734 | 169,000 | 2,419,326 | 9,609 |
gr137 | 18,798 | 37,181 | 5,593 | 187,690 | 179,311 | 89,176 |
pr144 | 20,784 | 59,098 | 5,889 | 207,360 | 199,699 | 98,182 |
ch150 | 22,523 | 477,971 | 893 | 225,000 | 3,921,003 | 10,792 |
kroA150 | 22,569 | 128,766 | 2,807 | 225,000 | 707,170 | 46,224 |
kroB150 | 22,630 | 135,785 | 2,708 | 225,000 | 680,086 | 47,674 |
pr152 | 23,132 | 72,564 | 4,750 | 231,040 | 196,547 | 117,041 |
u159 | 25,287 | 70,763 | 5,647 | 252,810 | 529,831 | 70,958 |
rat195 | 38,093 | 4,736,380 | 310 | 380,250 | 25,838,895 | 5,329 |
d198 | 39,375 | 1,337,616 | 1,047 | 392,040 | 3,001,233 | 38,231 |
gr202 | 40,882 | 404,695 | 3,256 | 408,040 | 3,439,300 | 36,831 |
ts225 | 50,649 | 128,149 | 12,854 | 506,250 | 824,742 | 170,884 |
gr229 | 52,449 | 177,592 | 10,401 | 524,410 | 921,695 | 167,730 |
gil262 | 68,789 | 16,165,285 | 308 | 686,440 | 96,690,038 | 4,930 |
a280 | 78,631 | 14,368,564 | 414 | 784,000 | 90,806,864 | 6,746 |
lin318 | 101,375 | 2,219,290 | 3,951 | 1,011,240 | 10,188,376 | 78,223 |
rd400 | 160,396 | 18,439,021 | 1,398 | 1,600,000 | 81,553,529 | 29,261 |
fl417 | 174,140 | 28,258,436 | 1,424 | 1,738,890 | 31,432,278 | 80,618 |
gr431 | 185,990 | 2,026,980 | 15,233 | 1,953,640 | 34,978,940 | 91,416 |
pcb442 | 195,604 | 7,548,302 | 4,649 | 1,857,610 | 7,752,811 | 303,216 |
rat575 | 330,697 | 234,671,318 | 592 | 3,306,250 | 676,190,119 | 16,898 |
Instance | SLO | Srand | ||||
---|---|---|---|---|---|---|
Ffit | η | h3 | Ffit | η | h3 | |
eil51 | 126,875 | 0 | 0 | 1,068,752 | 2 | 0 |
berlin52 | 5,495 | 0 | 0 | 64,662 | 0 | |
st70 | 229,647 | 0 | 0 | 1,876,506 | 0 | 0 |
eil76 | 456,422 | 1 | 0 | 4,140,456 | 2 | 1 |
pr76 | 2,838 | 0 | 0 | 18,107 | 0 | 0 |
gr96 | 10,633 | 0 | 0 | 71,134 | 1 | 0 |
rat99 | 457,303 | 0 | 0 | 3,317,137 | 2 | 0 |
kroA100 | 30,902 | 0 | 0 | 170,251 | 1 | 0 |
kroB100 | 32,978 | 0 | 1 | 172,655 | 0 | 1 |
kroC100 | 30,277 | 0 | 0 | 169,127 | 0 | 1 |
kroD100 | 30,805 | 0 | 0 | 185,716 | 0 | 2 |
kroE100 | 33,600 | 0 | 0 | 167,732 | 0 | 1 |
rd100 | 71,443 | 0 | 0 | 598,845 | 0 | 1 |
eil101 | 1,376,150 | 0 | 0 | 10,621,646 | 1 | 0 |
lin105 | 59,275 | 0 | 0 | 288,911 | 0 | 1 |
pr107 | 41,307 | 0 | 0 | 58,422 | 0 | 1 |
pr124 | 36,773 | 0 | 0 | 116,389 | 0 | 0 |
bier127 | 17,641 | 7 | 0 | 187,417 | 0 | 5 |
ch130 | 350,821 | 0 | 1 | 2,419,326 | 0 | 4 |
gr137 | 37,181 | 0 | 0 | 179,311 | 0 | 3 |
pr144 | 59,098 | 0 | 0 | 199,699 | 0 | 0 |
ch150 | 477,971 | 0 | 0 | 3,921,003 | 0 | 4 |
kroA150 | 128,766 | 0 | 0 | 707,170 | 0 | 4 |
kroB150 | 135,785 | 0 | 1 | 680,086 | 0 | 3 |
pr152 | 72,564 | 0 | 0 | 196,547 | 0 | 1 |
u159 | 70,763 | 0 | 0 | 529,831 | 0 | 2 |
rat195 | 4,736,380 | 0 | 0 | 25,838,895 | 1 | 5 |
d198 | 1,337,616 | 0 | 0 | 3,001,233 | 0 | 10 |
gr202 | 404,695 | 0 | 0 | 3,439,300 | 0 | 13 |
ts225 | 128,149 | 0 | 0 | 824,742 | 0 | 19 |
gr229 | 177,592 | 0 | 1 | 921,695 | 0 | 15 |
gil262 | 16,165,285 | 0 | 0 | 96,690,038 | 0 | 26 |
a280 | 14,368,564 | 0 | 2 | 90,806,864 | 0 | 31 |
lin318 | 2,219,290 | 0 | 1 | 10,188,376 | 0 | 45 |
rd400 | 18,439,021 | 0 | 2 | 81,553,529 | 0 | 99 |
fl417 | 28,258,436 | 1 | 3 | 31,432,278 | 0 | 97 |
gr431 | 2,026,980 | 0 | 2 | 34,978,940 | 0 | 127 |
pcb442 | 7,548,302 | 0 | 3 | 34,978,940 | 0 | 138 |
rat575 | 234,671,318 | 0 | 4 | 676,190,119 | 0 | 382 |
AVERAGE | 8,586,280.54 | 0.23 | 0.54 | 28,794,148.38 | 0.26 | 26.72 |
Instance | SLO | Srand | ||||||
---|---|---|---|---|---|---|---|---|
h3 | h1 | hp1 | hp2 | h3 | h1 | hp1 | hp2 | |
eil51 | 0 | 1 | 0 | 0 | 0 | 62 | 0 | 1 |
berlin52 | 0 | 0 | 0 | 0 | 0 | 74 | 2 | 1 |
st70 | 0 | 6 | 0 | 0 | 0 | 140 | 11 | 5 |
eil76 | 0 | 2 | 1 | 0 | 1 | 158 | 11 | 6 |
pr76 | 0 | 4 | 0 | 0 | 0 | 171 | 8 | 12 |
gr96 | 0 | 3 | 1 | 0 | 0 | 281 | 10 | 19 |
rat99 | 0 | 5 | 0 | 0 | 0 | 359 | 18 | 21 |
kroA100 | 0 | 4 | 1 | 0 | 0 | 363 | 22 | 19 |
kroB100 | 1 | 4 | 0 | 0 | 1 | 315 | 12 | 17 |
kroC100 | 0 | 0 | 1 | 2 | 1 | 333 | 22 | 13 |
kroD100 | 0 | 4 | 1 | 0 | 2 | 374 | 11 | 20 |
kroE100 | 0 | 8 | 1 | 0 | 1 | 332 | 20 | 18 |
rd100 | 0 | 1 | 0 | 0 | 1 | 341 | 16 | 20 |
eil101 | 0 | 3 | 0 | 0 | 0 | 314 | 15 | 22 |
lin105 | 0 | 6 | 0 | 0 | 1 | 409 | 16 | 18 |
pr107 | 0 | 7 | 0 | 0 | 1 | 399 | 14 | 13 |
pr124 | 0 | 12 | 0 | 0 | 0 | 720 | 33 | 32 |
bier127 | 0 | 6 | 0 | 0 | 5 | 706 | 28 | 28 |
ch130 | 1 | 7 | 1 | 0 | 4 | 691 | 27 | 25 |
gr137 | 0 | 13 | 0 | 2 | 3 | 769 | 45 | 28 |
pr144 | 0 | 7 | 0 | 2 | 0 | 918 | 35 | 29 |
ch150 | 0 | 11 | 0 | 0 | 4 | 992 | 49 | 48 |
kroA150 | 0 | 15 | 1 | 2 | 4 | 893 | 39 | 44 |
kroB150 | 1 | 14 | 0 | 0 | 3 | 937 | 36 | 49 |
pr152 | 0 | 16 | 0 | 0 | 1 | 1,007 | 51 | 63 |
u159 | 0 | 10 | 0 | 2 | 2 | 1,173 | 49 | 42 |
rat195 | 0 | 22 | 1 | 2 | 5 | 1,703 | 83 | 94 |
d198 | 0 | 33 | 2 | 4 | 10 | 1,979 | 80 | 89 |
gr202 | 0 | 21 | 1 | 2 | 13 | 2,054 | 84 | 99 |
ts225 | 0 | 37 | 2 | 1 | 19 | 2,642 | 142 | 110 |
gr229 | 1 | 47 | 2 | 2 | 15 | 2,701 | 152 | 137 |
gil262 | 0 | 36 | 1 | 4 | 26 | 4,150 | 192 | 186 |
a280 | 2 | 74 | 5 | 4 | 31 | 4,510 | 224 | 200 |
lin318 | 1 | 40 | 2 | 4 | 45 | 6,341 | 308 | 313 |
rd400 | 2 | 119 | 11 | 5 | 99 | 11,328 | 571 | 509 |
fl417 | 3 | 130 | 6 | 8 | 97 | 12,964 | 564 | 595 |
gr431 | 2 | 146 | 8 | 5 | 127 | 13,981 | 662 | 644 |
pcb442 | 3 | 187 | 11 | 12 | 138 | 15,106 | 605 | 666 |
rat575 | 4 | 473 | 16 | 27 | 382 | 28,843 | 1,360 | 1,293 |
AVERAGE | 0.54 | 39.33 | 1.95 | 2.31 | 26.72 | 3,116.23 | 144.28 | 142.26 |