具有时间序列的PuLP优化运输

时间:2019-09-24 10:39:35

标签: python optimization time-series pulp vehicle-routing

我正在尝试使用Python中的PuLP在多个时间段内优化单个产品的运输。我在用它形成目标函数时遇到了问题:

routes =[(t,i,j) for t in TIME for i in ORIGIN for j in DESTINATION]
amount_var = LpVariable.dicts('Volume', (TIME, ORIGIN, DESTINATION), lowBound=0, cat='Integer')
route_usage = LpVariable.dicts('route_usage', routes, cat='Binary')

客观f-n:

model += LpProblem("Minimize costs", LpMinimize)
model+=lpSum(amount_[t][i][j]*price[t][i] for (t,i,j) in routes for t in TIME  for i in ORIGIN)

price 是元组的字典:整数对,例如{(period1,origin1):price1,(period2,origin1):price2等}。

您有解决方法的想法吗?

1 个答案:

答案 0 :(得分:0)

如果price是一个以元组为键的字典,则应将目标写为:

model = LpProblem("Minimize costs", LpMinimize)
model += lpSum(amount_var[t][i][j] * price[(t, i)] for (t, i, j) in routes)