智能优化算法系列:
(1)遗传算法求解CVRP
引言
前面的ortools虽好,但是不能够制定特意的算法,本次为大家推荐一款新的算法包,大家可以去调试比对
问题
本次的求解问题是:30个顾客,有顾客坐标,以及车场的坐标,指定5辆车,车辆载重为5,而每个点的需求是1。求最优收运或者配送路线
结果
代码
运行环境:python3.6.0,库scikit-opt==0.6.3
如下:
第一步:定义问题
import numpy as np
from scipy import spatial
import matplotlib.pyplot as plt
#CVRP问题求解
#num_customers顾客服务点
#num_vehicle车辆数
#num_points总数据点
#max_capacity车辆载重
num_customers = 30
num_vehicle = 5
num_points = 1 + num_customers
max_capacity = 5
#customers_coordinate = np.random.rand(num_points, 2) # for test
customers_coordinate = \
np.array([
[23,95],
[820,915],
[470,302],
[950,905],
[868,744],
[891,987],
[76,625],
[8,541],
[219,988],