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?
Asked
Active
Viewed 47 times
1 Answers
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