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*.

Home Page:https://arxiv.org/abs/2012.10384

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What if `start` is greater than `end` ?

Renxian-Lu opened this issue · comments

When I use a instance with small customers for example 15, then start is greater than end. so the while loop can't be stopped.
Don't we need to check whether start is greater than end?

// Picking the beginning and end of the crossover zone
std::uniform_int_distribution<> distr(0, params.nbClients-1);
int start = distr(params.ran);
int end = distr(params.ran);
// Avoid that start and end coincide by accident
while (end == start) end = distr(params.ran);
// Copy from start to end
int j = start;
while (j % params.nbClients != (end + 1) % params.nbClients)
{
result.chromT[j % params.nbClients] = parent1.chromT[j % params.nbClients];
freqClient[result.chromT[j % params.nbClients]] = true;
j++;
}