I have developed a fittness function but I need help with code for crossover and mating functions. My timetable is of data structure
struct {
int period[5][12][25]; //5 days, 12 Periods, 25 Solts per period
int dayfittneess[5]; //Fittness assigned to each day
int fittness; //Total fittness for timetable
}
How do I apply genetics algorithm to a c++ program to optimize Timetable Creation.?
It would be easier if for that part you treated the whole thing as an array of integers. If you declare like this:
union Timetable {
struct structData {
int period[5][12][25]; //5 days, 12 Periods, 25 Slots per period
int dayfitneess[5]; //Fitness assigned to each day
int fitness; //Total fittness for timetable
}
int longArray[1506]; // 5*12*25 + 5 + 1 = 1506
}
(or something like that, my unions are a little rusty...)
Then you can access the structure _either_ as a nicely organised struct, _or_ as one big array of integers. This should make the crossover much easier - just pick a random point in the array and take the data from one parent up to that point and the data from another parent from that point on as the child.
Hope this is of some help - I'm a GA obsessive so please feel free to get back to me if it isn't :P
Rawlyn.
Reply:Hey no problem - I would be happy to get my thinking cap on again if you send me an email. I went to send you one but you seem to have disabled that option... Report It
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment