This is a problem I\'ve had on my mind for a long time. Being the son of a teacher and a programmer, it occurred to me early on... but I still haven\'t found a solution for it.<
This reminds me of this blog post about scheduling a conference, with a video explanation here.
How I would do it:
Have the population include two things:
This way we can't have conflicts (a teacher in 2 places, or a class having two subjects at the same time).
The fitness function would include:
Maybe take the standard deviation for all of them since they should be balanced.