Gecode / gecode

Generic Constraint Development Environment
https://www.gecode.org
Other
283 stars 76 forks source link

Wrong optimal solution in Travelling Salesman example #151

Open iPapatsoris opened 2 years ago

iPapatsoris commented 2 years ago

Describe the bug

Running tsp.cpp in the examples directory, the third hardcoded problem instance (br17 from TSPLIB) returns a solution of supposed optimal cost of 87, while the optimal solution reported by TSPLIB is 39. By copy and pasting the hardcoded input into a custom model that uses the cost-less version of the circuit constraint, I was able to get the 39, suggesting that it isn't a typo between the hardcoded data inside tsp.cpp and the one posted by TSPLIB.

To Reproduce

Compile /examples/tsp.cpp and run with argument 2.

Gecode and Platform Configuration

Gecode version commit bbefcea214fec798a0f5acc442581984555acd21 Ubuntu 18.04.1 LTS g++ 7.5.0

zayenz commented 2 years ago

Looking closer, this seems to be beacuse the TSP example is written with the assumption that 0 represents an invalid part, while br17 has 0-cost segments that are valid. This should be fixed, but requires checking all the examples to make sure that they are all as they should be.