[rules-users] How to even out n buckets in Drools Planner?
Geoffrey De Smet
ge0ffrey.spam at gmail.com
Fri Feb 3 10:54:09 EST 2012
write a score rule that does an insertLogical of a class of the bucket
with the least size
when
$b : Bucket($s : size)
not Bucket($s > size)
then
insertLogical(Minimum($s))
Then write a score rule that punishes the difference squared for each bucket
when
Minimum($m : size)
$b : Bucket(size > $m, $s : size)
then
insertConstraintOccurrence(...,
($s - $m) * ($s - $m), // score punish
$b); // cause
Op 03-02-12 15:28, aitchnyu schreef:
> I have n buckets and mn entities. Each bucket must have m entities. Each
> entity carries a weight. My objective is to even out the total weight per
> bucket, make them close to the average.
>
> For example, a solution like this is skewed, see their sums.
> bucket 1: 1,2,4,5=12
> bucket 2: 6,8,9,6=29
> bucket 3: 7,7,4,7=25
>
> The same entities may be placed into buckets like this. This is more
> desirable as the sums are closer to the mean (and each other); one does not
> dominate the others.
> bucket 1: 1,8,7,4=20
> bucket 2: 6,2,9,6=23
> bucket 3: 7,7,5,4=23
>
> *Question:*How do I write a rule for this:
> for each bucket, penalize (with soft scores) a bucket whose total
> entity.weight differs from the average total entity.weight of the buckets.
>
> Will I get the same results when I penalize each bucket for differing with
> *each other*?
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/How-to-even-out-n-buckets-in-Drools-Planner-tp3713200p3713200.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
--
With kind regards,
Geoffrey De Smet
More information about the rules-users
mailing list