scikit-opt 调研过很多遗传算法库,这个挺好用的。目标函数def demo_func(x): x1, x2, x3 = x return x1 ** 2 + (x2 - 0.05) ** 2 + x3 ** 2from ga import GA调用遗传算法求解:ga = GA(func=demo_func, lb=[-1, -10, -5], ub=[2, 10, 2], max_iter=500)...
python 哪个包里有 遗传算法
scikit-opt 调研过很多遗传算法库,这个挺好用的。
# 目标函数def demo_func(x): x1, x2, x3 = x return x1 ** 2 + (x2 - 0.05) ** 2 + x3 ** 2from ga import GA调用遗传算法求解:
ga = GA(func=demo_func, lb=[-1, -10, -5], ub=[2, 10, 2], max_iter=500)best_x, best_y = ga.fit()
甚至对tsp问题(Travelling Salesman Problem)也有很好的支持
ga_tsp = GA_TSP(func=cal_total_distance, points=points, pop=50, max_iter=200, Pm=0.001)best_points, best_distance = ga_tsp.fit()
2019-09-19