I don't have an explicit solution, but two ideas that spring to mind are: (a) Partition problem (similar to knapsack) https://en.wikipedia.org/wiki/Partition_problem If you are trying to minimize the difference in sizes, then consider the set S of integers representing your file sizes and first try to partition into 2 equally sized subsets. If you scroll down the wikipedia link to "Greedy algorithm", there is a heuristic approach to do this. Then you can partition each subset until you get subsets of the desired size. Downside is you can only partition into power of two subsets. e.g. if you want to partition your photos into 3 subsets, this approach wont work as-is.
(b) Use a genetic algorithm. If you fix the number of subsets, say 100. Then your goal is to minimize the difference in sizes between each subset, so a cost function is, for example, the difference in size between largest and smallest subsets. I haven't tried to express this as a GA problem, certainly not in J, but it seems doable. Jon -------------------------------------------- On Fri, 5/20/16, Devon McCormick <[email protected]> wrote: Subject: [Jprogramming] Even partitions To: "J-programming forum" <[email protected]> Date: Friday, May 20, 2016, 11:11 PM I have a few thousand photos I want to put into a small number of groups as equally-sized as possible. It looks like a knapsack problem but I only need to get within some tolerant equality. Has anyone done something like this? Thanks, Devon ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
