vidalt / HGS-CVRP

Modern implementation of the hybrid genetic search (HGS) algorithm specialized to the capacitated vehicle routing problem (CVRP). This code also includes an additional neighborhood called SWAP*.
https://arxiv.org/abs/2012.10384
MIT License
338 stars 78 forks source link

Question about divRank and fitRank in updateBiasedFitnesses() #21

Closed riven521 closed 2 years ago

riven521 commented 2 years ago

As mentioned in the paper "Vidal, T. (2022). Hybrid genetic search for the CVRP: Open-source implementation and SWAP* neighborhood.", the fitness in HGS is based on objective value and diversity considerations with formula (1).

The diversity is measured as its average broken-pairs distance; We found the calculation of diversity rank in the function updateBiasedFitnesses() is as follows: double divRank = (double)i / (double)(pop.size() - 1); while the solution quality is double fitRank = (double)ranking[i].second / (double)(pop.size() - 1);

Are these two calculations reversed? Maybe it should be: double divRank = (double)ranking[i].second / (double)(pop.size() - 1); double fitRank = (double)i / (double)(pop.size() - 1);

since the ranking store the averageBrokenPairsDistance ranking.push_back({-pop[i]->averageBrokenPairsDistanceClosest(params->nbClose),i});

TheIronBorn commented 2 years ago

Remember that i here iterates through the sorted decreasing ranking so it represents the ith largest distance individual. ranking[i].second represents the pos of that same individual in the fitness sorted population.

vidalt commented 2 years ago

Thanks a lot, @TheIronBorn for following up and providing a very concise explanation. The code in the current form is indeed correct: the individuals in pop are kept sorted by increasing penalized objective, therefore ranking[i].second provides the rank of the considered individual in terms of objective (fitRank). Moreover, since we perform a sort by diversity contribution in ranking, ranking[i] will correspond to the i^th best individual in terms of diversity contribution.

riven521 commented 2 years ago

Thanks for your reply~ @vidalt @TheIronBorn