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

Fix for loading tours #28

Closed
wants to merge 3 commits into from
Closed

Conversation

supersimple33
Copy link

Currently the following code will throw an error

import tsplib95
a = tsplib95.load("berlin52.opt.tour")
# do some stuff (or nothing)
a.save("x.tour")
tsplib95.load("x.tour") # this fails

This is because tsplib95 will miss the EOF in its regex if the user does not follow it by a blank space. This does not just affect tour loading but if you put extra info in a comment field which comes last then the EOF would be loaded in with the comment which is weird. I have fixed this by adding a new non-capturing group to the regex which will catch the EOF if it is at the very end. This match does have the consequence that the last keyword may then be None and so I have also addressed that.

Also, a small nit is that in the original TSP_LIB files, they do not add an extra -1 when there is just one tour.

@supersimple33
Copy link
Author

First part is duplicate of #27 didn't realize that addressed the same thing closing

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.

1 participant