Hello all!
I've been experimenting with building Genetic Algorithms using Perl, but could do with a few tips on optimization. For anyone new to the subject - they are great things, very easy to build and fun to play around with. I'm very new to the subject and all the new lingo was rather intimidating, but I'm really starting to enjoy programming them... anyhow enough evangelizing. I'm building a simple exam timetabling GA. I've used natural encoding, which is basically an array of arrays of arrays @Rooms->@Days->@Hours. To perform a crossover I'm having to loop through this structure like so
for (@room) {
for (@days) {
for(@hours) {
do stuff here;
if (crossover_loc <= current_location) { use parent1;
+}
else { use parent2; }
}
}
}
I think that is correct - it's single point crossover, and everything seems to work properly... however I'm wondering if any monk could tell me how I might speed that up. I realize speed isn't something I should really concern myself with - but I'm sure there are some creative ways to loop through those arrays and perform the actions, but I my Perl certainly isn't up to it. Would I be barking up the wrong tree?
many thanks for any insight you may be able to provide.
Si.
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.