A while ago I crunched this technique together using some work with genetic algorithms while in the game industry (Maxis and SimCity days). At that time we were looking at building out some AI modules from GA or Classifier systems. This didn't really get off the ground as it turns out that GA cost functions are tricky to design (not to mention slow as well).
Anyways, the whole concept was revisited several years later when I was able to nail down a concise optimization criteria for better redistricting (where they really need it: Hello Texas). You can read the dr. dobbs article here (or this link) but in a nutshell the concept is simple--if you keep the population as close together as possible (assuming that a spatially close population shares common values), and each district is the same size then you'll get better results (than what the politicians would come up that is).
It was a fun C++ project and nice to see it work out--particularly the population plot at the end that actually looks like Texas! Since then there have been a few inquiries and references to it--the library was designed to be reusable.
Here's the distribution image:
Just as a note--it nice to see this end up as a reference in a technical paper:
Genetic Algorithm: A Versatile Optimization Tool