SmugX has asked for the wisdom of the Perl Monks concerning the following question:
If I have many people (sales reps, say), and many geographical locations, both represented by grid references (i.e. with a little bit of Pythagoras I can figure out the distance between any two), does anyone know a good way of figuring out the most efficient way of assigning them, resulting in the least overall movement of people?
This sounds to me like an AI-type problem, but my AI skills are veeeeeery limited. However, the pseudo-code that's popped into my head is something like:
- Assign people at random.
- Calculate overall distance moved.
- Swap two people at random.
- Recalculate overall distance moved.
- If it's improved, keep the change, and repeat swap again. If it's worse, discard the change, and swap again.
- After some vaguely-defined period, decide I can't improve on things and stop.
However, it occurs to me that this sounds like a common problem, and therefore there might be a name for this kind of thing, maybe a much better method than the one I've listed above, and, moreover, hopefully a CPAN module to do the actual work for me. :-)
I've had a quick look through CPAN, but it seems I'm a bit stymied if I don't know any real AI theory (which I don't), and I don't know the name of the algorithm I'm searching for (which I certainly don't!)
Any advice will be much appreciated.
Many thanks,
SmugX