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.