I am trying to produce programmically the logic to split a set of data
to fit with a set of parameters.
The parameters are thus:
Maximum number of members to a group M.
Maximum weight allowed in group W.
Maximum number of groups G.
Each member of the group has a weight w.
Each member is unique and can only belong to 1 group.
So what I want to do is develop the logic in which I can distribute
the weight as evenly as possible up to the maximum with in the
different groups. I also want to use (if possible) the maximum number
of groups.
So as an example I have a maximum number of groups is 3 : G1, G2, G3
My members and weight (m,w) are: (a,200)(b,50)(c,100)(d,50)(e,150)(f,
300)(g,100)(h,50)(i,250)(j,100)(k,50)
The maximum weight is 450.
So one possible solution would be:
G1:(a,200)(b,50)(c,100)(h,50)(k,50)
G2:(d,50)(e,150)(j,250)
G3:(f,300)(g,100)
This is a solution without the maximum members...what if the maximum
members was set to M=4.
What is the logic to find the best fit solution. Not for this
specific case but just in general.
Can anyone point me in the right direction?
Regards
Tim
I'm not fluent enough to give you a quick top-of-the-head example,
but have you looked into logic programming with any of the Prolog
variants, or constraint logic programming with ECLiPSe? They're
made for this sort of thing.
Hope this is what you were asking.
> Maximum number of members to a group M.
>Maximum weight allowed in group W.
>Maximum number of groups G.
WGM in M
WG in M, G=3, W=450=[0,1) G>1 else W=[0,1]
Remove G, such that G<=M
So one possible solution would be:
G1:(a,200)(b,50)(c,100)(h,50)(k,50)
V=W(1),W(2), e.g. f(a,b,c)
>members and weight (m,w)
m~g(x), w~f(x)
g(x,f(x,y,z)) <=M
-Doug
Thought more on your topic, the idea is to run g(f()) for each set in
M
Keep it simple, kernel functions as weight densities.
I run them fast and think few careful observations, to much thinking,
small time for computation.
-Doug