import numpy as np
rnd = np.random
rnd.seed(0)
import random
random.seed(0)
M=1000
# data
nbX = 5
source = 0 #出发点
puits = nbX #回去点,共有nbx-1个顾客,2个车站
# sets
V = range(3) #vehicles
X = list(range(nbX)) #clients
U = [(x1, x2) for x1 in X for x2 in X] #arcs
# 两点之间的距离
random.seed(0)
D = {
u: int(random.uniform(1, 10)) for u in U}
# diagonale vide
for x in X:
D[(x, x)] = 0
# inegalité triangulaire
for j in X:
for i in X:
for k in X:
D[(i, k)] = min(D[(i, k)], D[(i, j)] + D[(j, k)])
# fenetres de temps
E = [max(D[(source, x)], int(random.uniform(1, 5 * nbX))) for x in X]
L = [E[x] + int(random.uniform(20, 40)) for x in X]
E[source] = 0
Tmax = max(L) + max(D.values())
L[source] = Tmax
for x in X:
U.append((x, puits))
D[(x, puits)] = D[(source, x)]
X.append(puits)
E.append(E[source])
L.append(L[source])
# capacity
Q = 20
q = {
i: rnd.randint(1, 10) for i in X}
q[source]=0
q[puits]=0
# service time
service_time = {
i: rnd.randint(1, 5) for i in X}
service_time[source]=0
service_time[puits]=0
# optimization
from gurobipy import Model, GRB, quicksum
mdl
python+gurobi 带时间窗带容量限制的路径规划 cvrptw
于 2021-03-22 00:20:42 首次发布