I want to partition a US state into 20 parts of approximately equal population. I can do this using, say, tracts, ZIP codes or another smaller geography. I'm looking for an algorithm to do the partitioning. It can be in any language or software (ArcGIS, QGIS, python, PostGIS, R, node).
For grouping or clustering algorithms I've looked at like k-means, ArcGIS Grouping Analysis, etc. These do not seem to do what's needed, since they group based on the similarity of a variable don't partition into equal size based on a variable. My quick look at ESRI's districting tool suggests that this might be a possibility.
Any other suggestions?