0

I have to implement a symmetrical TSP. When I go to add the variables: x = m.addVars (Costs.Keys (), vtype = GRB.BINARY, obj = Costs, name = 'x') It gives me the error: 'list' object has no attribute 'Key '. I have the data saved in a list, is there a way to add the variable or do I necessarily have to save the data in a dictionary?

lori
  • 1
  • 2

1 Answers1

0

Seems like Costs is a list. Typically, use a dictionary of distances, indexed by the edge pairs i,j. See the Gurobi tsp.py example code for an illustration.

Greg Glockner
  • 5,433
  • 2
  • 20
  • 23