Okay, so I've been at this problem for a couple weeks now and I seem to have hit a snag.
The idea is this to take a group of 250 x and y coordinates and cluster them into different groups, but each group can only have a maximum of 15 points with a tolerance of +- 2.
I've tried using a few variations of Kmeans, but unfortunately it doesn't quite do the trick since kmeans can't take into account a limit to points in a group.
here are the initial points (axes removes for security of information):
and here is an attempt where I used multiple iterations of kmeans to divide the data:
You can see that it is pretty close, but there are some groups that have too few points.
Attached you'll find 2 files. The Optimization Test file is the one where i generated those figures using multiple iterations of kmeans, and the kmeansModified is a piece of code I wrote (sorry for all of the comments, its a work in progress) which tries to solve the number of elements per group problem, but I don't think I did a good job at it:
Anyone have any ideas on this? I understand that this is a pretty complex problem, and from what I have researched, there isn't a good way of trying to solve this problem, but I'd still like to see what your opinions are!