0

This is a conceptual doubt related to Soft computing and Optimization. I am implementing the Discrete Invasive Weed Optimization (DIWO) to solve the Traveling Salesman Problem. We studied from this research paper:

https://www.researchgate.net/publication/280261944_A_discrete_invasive_weed_optimization_algorithm_for_solving_traveling_salesman_problem

The snippet of the DIWO part of the code:

# for every iteration i till iter_max
sd_iter = ( ( float(pow(iter_max-i,mod_index)) / float(pow(iter_max,mod_index)) ) * (sd_i-sd_f)) + sd_f
fmax = max(population)[0]           # weed with maximum fitness
fmin = min(population)[0]
print("Generation ",i, "Max Fitness =",fmax,"  Tour length = ",int(1/fmax))
for j in range(len(population)):
  #Calculate number of seeds for a given fitness
  s = no_seed(population[j][0],fmax,fmin)

  for k in range(s):
    cities = []                       #cities stores each seed's tour
    for z in range(max_city):
      # getting seeds using normal distribution function
      param = np.random.normal(population[j][1][z],sd_iter,None)
      param = int(param)
      val = param % max_city
      val += 1
      cities.append(val)

    count = [0] * max_city            #count[i] stores the number of times (i+1)'th city is repeated in 'cities'
    zero_count = []                   #zero_count contains cities which have not been included in 'cities' i.e. count[i+1] = 0
    for v in cities:
      count[v-1] += 1  
    for q in range(max_city):
      if count[q] == 0:
        zero_count.append(q+1)

    #Every city is to be visited and repetitions eliminated
    px = 0
    for q in range(len(cities)):
      if count[cities[q]-1] > 1:
        count[cities[q]-1] -= 1
        cities[q] = zero_count[px]
        px += 1

    first_city = cities[0]
    cities.append(first_city)
    cost = path_length(tsp,cities)
    fit = fitness(cost)
    seed = (fit,cities)

    population.append(seed)

    population.sort(reverse=True)

    #competitive exclusion
    population=population[0:gen_n_max]
final = population[0]

The doubt is in the step where normal distribution is being done in "random.normal(...)" which produces the seeds with respect to to the corresponding weed (parent). When we are printing the seeds, their result is coming way too high than the optimum value. Like for example I ran it on 'Berlin52.tsp' from the TSPLIB95 dataset available on line whose optimum tour cost is given as 7542. But when printing the seeds, not even ONE seed's fitness is anywhere close to the optimum cost.

I was getting seeds with costs in the range above 25000-30000. I understand seeds are basically the permutations of the weeds, but shouldn't atleast one seed be a bit close to 7542 like 9000s? 10,000s? at the very least.

Maybe the error lies in exploration and exploitation? Any help or nudge in the direction will be very much appreciated !

annu
  • 1

0 Answers0