tonybenny2020 / or-tools

Automatically exported from code.google.com/p/or-tools
0 stars 0 forks source link

DuplicateFlagError when running Google or-tools TSP constraint solver on multiple collectsions #71

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
While attempting to solve the TSP for multiple sets of points (by looping over 
all the sets and calling the the constraint solver on each set), an error is 
thrown: gflags.DuplicateFlagError: The flag 'tsp_size' is defined twice.

This is because I have the following code re-defining the gflag tsp_size 
depending on the size of a particular problem (not all sets are the same size): 
`gflags.DEFINE_integer('tsp_size', len(points), 'Size of Traveling Salesman 
Problem instance.')`

Everything works fine on the first set; the error is thrown upon processing the 
second set

How can I make separate instances of the constraint solver within the same run 
of a program, considering I have multiple graphs to loop over?

Original issue reported on code.google.com by s.gonzal...@gmail.com on 28 Jun 2015 at 8:15

GoogleCodeExporter commented 9 years ago
Solved my problem:

for graph in graphs:
    import shp
    shp.run(graph)
    del sys.modules['shp']

Original comment by s.gonzal...@gmail.com on 29 Jun 2015 at 4:19