Add partition dist calculation code.

Note that I also put glpk R package code in there to try to
keep it reproducible on into the future.