Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Looking for help with AI::Genetic and classroom scheduling

by salonmonk (Beadle)
on Feb 20, 2005 at 14:55 UTC ( #432869=note: print w/replies, xml ) Need Help??

in reply to Looking for help with AI::Genetic and classroom scheduling

Yeah I did my dissertation on this subject - using Perl. Without getting into all the intricate details, a really nice representation is to use a 3D array. $array[ROOM_NUMBER][WEEKDAY][TIMESLOT] = CLASS You are susceptable to the label replacement problem (i.e. classes can be booked more than once, or not at all), but that can be easily fixed by a genetic repair operator which just books them again in the next available slot. To give you an example - take the room capacity violation, it's a hard contraint, the pseudo code may look something like this:
Procedure room_capacity_violation For R in 0 .. totalRooms For D in 0 .. totalDays For H in 0 .. totalHours If (chromosome[R][D][H] != 0) If (chromosome[R][D][H]->CLASS_SIZE > room[R]->CLASSROOM_SIZE) + count := count + 1 End If End If End For End For End For Return(count) End room_capacity_violation
So you return the count which represents how many times that hard constraint has been violated. This allows you to perform selection based on the best individuals (those who violate the contraints least) - or whatever selection method you use, because sometimes it's good to keep some traits in your population for the sakes of genetic diversity. One benefit that comes from this encoding method is that one contraint is alreadt assured; it is impossible to double book a room. I hope that is of some help (direct or otherwise).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://432869]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2018-03-17 10:37 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (223 votes). Check out past polls.