简体   繁体   中英

PuLP Optimization Transportation with time series

I´m trying to optimize the transportation of a single product over several periods of time with PuLP in Python. I face a problem forming the objective function with it:

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')

Objective fn:

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 is a dictionary of tuple:integer couples like {(period1,origin1): price1, (period2,origin1): price2 etc.}.

Do You have an idea how to solve it?

If price is a dictionary with tuples as keys you should write your objective as:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM