Skip to content

Enumerates the permutations on a set of size n in ascending lexicographic order; inspired by the TSP.

License

Notifications You must be signed in to change notification settings

clarity20/permutations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Permutations

This small utility generates the complete list of permutations on S_n = {1, 2, ..., n} in ascending lexicographical order. Under the hood there is a re-implementation of the STL's next_permutation() algorithm which we call n!-1 times.

This exercise was inspired by the traveling salesman problem. My overall idea is to decompose large instances of the TSP into a series of subproblems, solve those using standard techniques, and reintegrate the solutions into the original problem to give us a nice roadmap to a good overall solution. What's different about this approach is the technique by which we identify promising subproblems. We hope that in the near future we will have the opportunity to pursue this idea at length.

Todo list:

  • Redesign in a more object-oriented fashion
    • Create a permutation generator class. Construct and run it once in main().
    • Move global data into object state and make helper functions private.
    • Cleanly separate the next_permutation() functionality from its invocation.
  • Make nextPermutation() and generateAllPermutations() public.
  • Explain factoriadic numbers in brief. Give a link to the details.

About

Enumerates the permutations on a set of size n in ascending lexicographic order; inspired by the TSP.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages