An algorithmic approach to legislative apportionment bases and redistricting. (October 2022)