A node that just seems to beg for attention on this is the one on
Genetic Algorithms.
If best fit of all files is you grail, rather than speed, GAs are looking like a good candidate for this.
As an initial thought on applying the GA:
Each section of the gene string represents a file number, the length of each allele (effectively the section of a gene that equates to a rule) is determined by the number of directories you have, and is, in essence a binary encoding of a directory 'number'.
Thus if you had 50 files to put in 10 directories you'd have an allele size of 4 bits (minimum binary length to encode 10 directories), and total length of gene of 4*50 (one allele for each file).
A test of fitness would be
must be under 10MB (if you absolutely need it under 10Meg), so a BIG penalty needs to be applied for each directory going over 10meg.
The reason for a big penalty rather than complete invalidation is that much of the gene may be useful, but it should never be in the final solution. High scoring ones with one bum directory should still be candidates for crossover.
Then work out a scoring system for deviation from the 10MB mark that achieves the best fit you're looking for (some solutions will pack some directories to 10MB, and leave one or two with a lot of space, some rules will lead to most directories being near packed, take your pick)..
Populate the gene pool, and let it rip. :)
Leave it running for as long as you feel necessary (keep an eye on the total fitness of the system, and get it to stop when you think it's good enough, or you're tired of watching it run); a few thousand generations should be good..
That should give you a pretty decent solution to your problem
For more info, check out:
geneticprogramming.com.
Hope this helps some,
Malk
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.