[rules-users] How to even out n buckets in Drools Planner?

aitchnyu jesvinj at technovia.co.in
Sat Feb 4 04:54:38 EST 2012


I got the basic idea of throwing broken constraints based on the square of
the difference. 

However, the total weight is not a property of the bucket, but the *sum of
weights of entities* who happen to be inside that bucket. It is not a
property *of the bucket* as such.

This is a form of what I have in mind:

when
   $smallest_bucket=Bucket(bucket for which min sum of entity.weight )
   $other_bucket_sum=Number(min sum of entity.weight for each bucket !=
$smallest_bucket)
then 
    $insertLogical(constraint(negative soft points for difference,
responsible_object))

Could you help with formulating a rule like this?

BTW, what is the Minimum class? I saw no documentation for that, only the
min() from the 'Multi-function Accumulates'.

#########
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
#########


--
View this message in context: http://drools.46999.n3.nabble.com/How-to-even-out-n-buckets-in-Drools-Planner-tp3713200p3715243.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list