Add code to generate supernecklaces and -bracelets#14
Add code to generate supernecklaces and -bracelets#14pozorvlak wants to merge 5 commits intosuperpermutators:masterfrom
Conversation
A necklace is an equivalence class of strings under rotation; a bracelet is an equivalence class of strings under rotation and reflection. Restricting our attention further to necklaces/bracelets without repetitions, we can search for "supernecklaces" and "superbracelets", which are strings that contain some representative of each non-repeating necklace/bracelet as a substring (equivalently, strings which, for every permutation p, contain a substring that may be rotated and/or reflected to obtain p). This is not a classic TSP, but it can be framed as an Equality-Generalised Travelling Salesman Problem, which can then be converted into an ATSP and solved by the GLKH solver, http://webhotel4.ruc.dk/~keld/research/GLKH/. This work was inspired by Matthew Clarke's questions on the forum: https://groups.google.com/forum/?#!msg/superpermutators/H1_jrq_EO1c/unrp4Gl_GQAJ
|
More seriously, it's not finding the shortest supernecklace for n = 3: I'm getting and here's the output file: and here's the Am I doing something obviously wrong? I couldn't immediately find a spec for the |
|
I also wrote some much more naive code for this problem in the constraint-solving language MiniZinc: it's vastly slower than this, but does at least get the right answer for the n = 3 supernecklace. Would it be welcome in this repository? |
Input files that specify `TYPE: GTSP` are assumed to be symmetric by
GLKH. Input files for asymmetric GTSPs must have `TYPE: AGTSP`. This
change makes GLKH produce optimal supernecklaces for n = 3 and 4, and
substantially improves the lengths of the supernecklaces and -bracelets
found for n \in {5, 6, 7}.
|
I won’t lie: the most exciting thing about this for me is that I have learnt about GitHub’s new “draft pull request” feature! :-) |
|
@pozorvlak The MiniZinc code would be very welcome, yes! We are language-agnostic here. :-) |
|
I fixed the problem with finding overlong supernecklaces, by the way: GLKH was interpreting my input files as containing undirected graphs. The two-character fix is in d9de7cc. |
A necklace is an equivalence class of strings under rotation; a bracelet is an equivalence class of strings under rotation and reflection. Restricting our attention further to necklaces/bracelets without
repetitions, we can search for "supernecklaces" and "superbracelets", which are strings that contain some representative of each non-repeating necklace/bracelet as a substring (equivalently, strings
which, for every permutation p, contain a substring that may be rotated and/or reflected to obtain p).
This is not a classic TSP, but it can be framed as an Equality-Generalised Travelling Salesman Problem, which can then be converted into an ATSP and solved by the GLKH solver, http://webhotel4.ruc.dk/~keld/research/GLKH/.
This work was inspired by Matthew Clarke's questions on the forum: https://groups.google.com/forum/?#!msg/superpermutators/H1_jrq_EO1c/unrp4Gl_GQAJ
I don't think this is quite ready to be merged: I'd like to make it a bit easier to actually run the solver first (I had to hack up the supplied
runGLKHscript).