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

Travelling Salesman Problem (TSPLIB)

Collision Computations

Instance|SLO|CLOFitLO|Srand|CrandFitrand
berlin522,7085,49579927,04064,6626,833
st704,904229,6479949,0001,876,5061,170
eil765,793456,4227257,7604,140,456766
pr765,7892,8383,78857,76018,10743,331
gr969,21610,6333,87292,16071,13449,124
rat999,847457,30318998,0103,317,1372,613
kroA10010,00730,9022,163100,000170,25132,619
kroB10010,01432,9782,028100,000172,65532,317
kroC10010,00130,2772,168100,000169,12732,881
kroD10010,00730,8052,034100,000185,71630,723
kroE10010,02033,6001,970100,000167,73233,161
rd10010,00171,4431,025100,000598,84512,060
eil10110,2111,376,15080102,01010,621,646975
lin10511,04359,2751,443110,250288,91126,055
pr10711,45541,3072,549114,49058,42273,334
pr12415,38436,7734,028153,760116,38982,802
bier12716,15317,6417,199161,290187,41768,143
ch13016,903350,821734169,0002,419,3269,609
gr13718,79837,1815,593187,690179,31189,176
pr14420,78459,0985,889207,360199,69998,182
ch15022,523477,971893225,0003,921,00310,792
kroA15022,569128,7662,807225,000707,17046,224
kroB15022,630135,7852,708225,000680,08647,674
pr15223,13272,5644,750231,040196,547117,041
u15925,28770,7635,647252,810529,83170,958
rat19538,0934,736,380310380,25025,838,8955,329
d19839,3751,337,6161,047392,0403,001,23338,231
gr20240,882404,6953,256408,0403,439,30036,831
ts22550,649128,14912,854506,250824,742170,884
gr22952,449177,59210,401524,410921,695167,730
gil26268,78916,165,285308686,44096,690,0384,930
a28078,63114,368,564414784,00090,806,8646,746
lin318101,3752,219,2903,9511,011,24010,188,37678,223
rd400160,39618,439,0211,3981,600,00081,553,52929,261
fl417174,14028,258,4361,4241,738,89031,432,27880,618
gr431185,9902,026,98015,2331,953,64034,978,94091,416
pcb442195,6047,548,3024,6491,857,6107,752,811303,216
rat575330,697234,671,3185923,306,250676,190,11916,898
InstanceSLOSrand
Ffitηh3Ffitηh3
eil51126,875001,068,75220
berlin525,4950064,6620
st70229,647001,876,50600
eil76456,422104,140,45621
pr762,8380018,10700
gr9610,6330071,13410
rat99457,303003,317,13720
kroA10030,90200170,25110
kroB10032,97801172,65501
kroC10030,27700169,12701
kroD10030,80500185,71602
kroE10033,60000167,73201
rd10071,44300598,84501
eil1011,376,1500010,621,64610
lin10559,27500288,91101
pr10741,3070058,42201
pr12436,77300116,38900
bier12717,64170187,41705
ch130350,821012,419,32604
gr13737,18100179,31103
pr14459,09800199,69900
ch150477,971003,921,00304
kroA150128,76600707,17004
kroB150135,78501680,08603
pr15272,56400196,54701
u15970,76300529,83102
rat1954,736,3800025,838,89515
d1981,337,616003,001,233010
gr202404,695003,439,300013
ts225128,14900824,742019
gr229177,59201921,695015
gil26216,165,2850096,690,038026
a28014,368,5640290,806,864031
lin3182,219,2900110,188,376045
rd40018,439,0210281,553,529099
fl41728,258,4361331,432,278097
gr4312,026,9800234,978,9400127
pcb4427,548,3020334,978,9400138
rat575234,671,31804676,190,1190382
AVERAGE8,586,280.540.230.5428,794,148.380.2626.72
InstanceSLOSrand
h3h1hp1hp2h3h1hp1hp2
eil51010006201
berlin52000007421
st7006000140115
eil7602101158116
pr7604000171812
gr96031002811019
rat99050003591821
kroA100041003632219
kroB100140013151217
kroC100001213332213
kroD100041023741120
kroE100081013322018
rd100010013411620
eil101030003141522
lin105060014091618
pr107070013991413
pr1240120007203332
bier127060057062828
ch130171046912725
gr1370130237694528
pr144070209183529
ch1500110049924948
kroA1500151248933944
kroB1501140039373649
pr1520160011,0075163
u1590100221,1734942
rat1950221251,7038394
d19803324101,9798089
gr20202112132,0548499
ts22503721192,642142110
gr22914722152,701152137
gil26203614264,150192186
a28027454314,510224200
lin31814024456,341308313
rd40021191159911,328571509
fl4173130689712,964564595
gr43121468512713,981662644
pcb4423187111213815,106605666
rat5754473162738228,8431,3601,293
AVERAGE0.5439.331.952.3126.723,116.23144.28142.26