0

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

Do You have an idea how to solve it?

Hellisa
  • 13
  • 3

1 Answers1

0

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)
abc
  • 11,579
  • 2
  • 26
  • 51