Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSPLIbImporter support row-tours and fix distance function for EDGE_WEIGHT_TYPE GEO #1080

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

HannesWell
Copy link

This PR provides a fix for issue #1064 and adds supports for TSPLIB files that contain a tour whose node list is a row. Until know only tours with a node list as column were supported. The latter is one task of the umbrella issue #1067.

Additionally the corresponding tests are adjusted and extended.


Add test cases to cover a tour defined in a row.
…1064)

The conversion function from sexagesimal/base60 value to radian decimal
values in TSPLIBImporter computeRadiansAngle() had a bug when splitting
the sexagesimal/base60 value into its degree and minute part.

The integer degree part must be computed by truncating the decimal part
of the double value (by casting it to an int) instead of rounding it to
the next integer value. In case the value was rounded upwards (in case
of a negative value rounded downwards) the minute part (which is then
subtracted) becomes bigger than it should be.
This is caused by the non-steadiness of the conversion from decimal
degrees to sexagesimal/base60 degree values.

Updated and extended the test-cases accordingly.
double deg = (int) x; // integer degree part
double min = x - deg; // decimal part represents the minutes of arc
if (0.60 < Math.abs(min)) {
throw new IllegalArgumentException(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This let the import of ali535.tsp fail because it contains the following three lines:

187  33.56  45.80
429  48.31 -24.80
501  40.62  13.11

In each line one coordinate has a decimal part greater 0.6. But since the decimal part represents the minutes of arc of the degree value it must not be greater 0.6. So from my perspective the TSP-instance is malformed.

Alternatively only a corresponding message could be printed or it could configurable if the algorithm should only print an error or should throw an exception. That's not nice but at least the import of ali535 would work.
Another way would be to contact the Uni Heidelberg ask them to fix this instance.

@jsichi jsichi requested a review from jkinable April 28, 2021 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant