How to get all permutation of a large vector?

6 views (last 30 days)
How to get all permutation of a large vector? (50 elements) I need this to generate a Simulink simulation with each combination result. So the ideal is some generation in a loop.

Accepted Answer

Walter Roberson
Walter Roberson on 17 Nov 2016
If you were able to process the entries at a rate of 5 GHz (that is, you were able to process 5*10^9 complete entries per second), then it would take you 1.93 * 10^47 years to process all 30414093201713378043612608166064768844377641568960512000000000000 permutations.
But if you have a yotta-yotta year to spare,
  4 Comments
Walter Roberson
Walter Roberson on 17 Nov 2016
If you processed at the same rate that I described above, then a vector with 30 elements would take approximately 1.68 * 10^15 years.
This figure needs to be understood as a very very rough approximation. The rotation of the Earth is slowing down due to gravity interactions with the Moon, so the very meaning of "year" will change, even if only in terms of "days". On the other hand, apparently the Sun is likely to only last about another 2.2 * 10^9 years and if the Earth survives that, you can be sure that "year" will have a very different meaning.
If you were to compare age of the Universe itself to the age that the Universe would have at the end of the 1.68 * 10^15 years, it would be like the first 4.38 minutes out of a year.
You should probably rethink your strategy.
John D'Errico
John D'Errico on 17 Nov 2016
Edited: John D'Errico on 17 Nov 2016
Yes, but with Moore's law in operation, before 10^15 years have passed, computers will be fast enough to process this easily. In fact, we can even predict when computers will be capable of solving the larger problem, of computing all permutations of 50 elements. (In theory, assuming we are still alive by then, and Skynet has not managed to do nasty things to us.) The thing is, by the time we are actually capable of solving the desired problem, this question will have been replaced by someone wanting to generate all permutations of 100000 elements, or something as bad.
So, even with Moore's law on our side, we can't win. Lets just call it John's law:
No matter how big or powerful their computer may be, there will always be somebody wanting to solve a problem that is ridiculously large, far beyond the capabilities of that computer, or even any computer in the known universe.

Sign in to comment.

More Answers (0)

Categories

Find more on Marine and Underwater Vehicles in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!