这是与软计算和优化相关的概念疑问。我正在实施离散入侵杂草优化(DIWO)来解决旅行商问题。我们从这篇研究论文中学习:
代码的DIWO部分片段:
# 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]
怀疑是在正常分配的步骤中," random.normal(...)"它产生相对于相应杂草(亲本)的种子。当我们打印种子时,它们的结果远远超过最佳值。比如我在' Berlin52.tsp'来自TSPLIB95的在线数据集,其最佳旅行成本为7542.但是当打印种子时,即使一粒种子的健康状况也不会接近最佳成本。
我的种子成本高于25000-30000。我知道种子基本上是杂草的排列,但不应该只有一个种子有点接近7542像9000s? 10,000s?至少。
也许错误在于探索和利用?任何帮助或推动这个方向将非常感谢!