Re: Who Needs to Find the Permutations of a List?
by jlongino (Parson) on Oct 07, 2001 at 04:01 UTC
|
Reading your post I happen to remember replying to the node
Sorting characters within a string. Apparently
geneticists do alot of this stuff. I seem to remember
another post in Meditations along a similar line, although
I couldn't find it as readily.
"Make everything as simple as possible, but not simpler." -- Albert Einstein | [reply] |
|
|
| [reply] |
|
|
| [reply] |
Re: Who Needs to Find the Permutations of a List?
by Masem (Monsignor) on Oct 07, 2001 at 04:59 UTC
|
How about for generating quizzes, where you want to select M (<= N) distinct questions from a set of N questions, mixing the order to prevent 'cheating' or similar. Permutating the list beforehand simply allows one to pop or shift off new questions instead of continuing to do a loop on a random number until you reach one that hasn't been done.
Also, not just only for genetic simulations, but for other cases where order may or may not matter (say, travelling salesmen approach with genetic algorithsm), permutations are easier to start with then trying to build up a 'random' list .
-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
It's not what you know, but knowing how to find it if you don't know that's important
| [reply] |
Re: Who Needs to Find the Permutations of a List?
by Dr. Mu (Hermit) on Oct 07, 2001 at 07:31 UTC
|
If you're using a genetic algorithm, say, to solve a travelling salesman problem, you need to be able to enumerate the permutations of a list of destinations, representing each as a unique string. These strings are the "chromosomes" which undergo reproduction and selection, the goal being to find the trajectory that minimizes the overall distance travelled in visiting all the destinations. | [reply] |
Re: Who Needs to Find the Permutations of a List?
by tommyw (Hermit) on Oct 07, 2001 at 04:59 UTC
|
I've had to write code which generates programmes of study for students (although I did it in C, not perl), and it relates to power sets, not permuations. But they're similar problems. (Power sets, if you aren't aware, are all the possible subsets of a set. So there are n! permutations of a list, but 2n power sets.)
Since I was working for a modular course, the students frequently had to take 2 out of <these 3 modules>, and 2 out of <these other 4 modules> etc, etc.
The brute force and ignorance method (and oh boy, was there ever a lot of ignorance. Unfortunately, the force wasn't quite as brute as the algorithm demanded...) was to generate the power set of the target list, merge it with the student's existing program and then delete those results which didn't meet requirements (or were more complicated than necessary).
| [reply] |
(jeffa) Re: Who Needs to Find the Permutations of a List?
by jeffa (Bishop) on Oct 07, 2001 at 22:49 UTC
|
The problem that brought me to PerlMonks in the first
place was to provide a list of possible corrected
sentances from
a sentance that contained zero or more misspellings
(user input to a search script).
I thought drop down boxes would suffice, but others thought,
well, otherwise . . . they wanted a list of sentances
that could be clicked to resubmit the form (they also
wanted drag and drop shopping carts in a virtual 3-d
world - but that's another story).
Turned out, permutations was the trick . . . here is the
original question (asked by proxy - eduardo):
permutations?
jeffa | [reply] |
Re: Who Needs to Find the Permutations of a List?
by buckaduck (Chaplain) on Oct 09, 2001 at 16:08 UTC
|
A scientific problem we worked on here recently:
For a given mass (as detected via mass spectrometry), determine the combinations of atomic weights that could possibly combine into a fragment of that mass.
One way to solve this problem is by permuting large lists of atomic weights, for those atoms which are considered likely candidates under the circumstances.
buckaduck | [reply] |