[rules-users] Re: drools 5.0.0-SNAPSHOT Maven repository broken?

tim tim timbaermannextra at googlemail.com
Mon Oct 13 12:53:11 EDT 2008


> I am convinced that:
>  2) Penalty's equals/hashcode uses both "cause" and "weight"?
>  then 3) happens: Keep Penalty(10), add Penalty(5)
> is an issue in drools core and instead 2) should happen:
>  Remove Penalty(10), add Penalty(5)
> because Penalty(10) is no longer true

exactly!
that is the behavior i was expecting. it took me quite some time
to find out why my program did not find a solution.

> I am going to make a testcase to isolate the problem and make it more
> transparent that it is indeed an issue. And then try to convince Mark and
> Edson that it's an issue :)

maybe there could be a switch, to tell drools which mode
is prefered? then they could keep the strange behavior in the engine ;-)


> which the HACK indeed that you quothed below:
>  the hack causes the rule to no longer apply (retracting the
> ConstraintOccurrence), after which it then refires.

argh, you are right! i didnt see that it gets retracted. i still have
to get used
to the drools way..


best, tim

>
>>
>> i solved the problem of improving constraints for the same causes that
>> differ in hashCode by retracting the old fact before inserting the new
>> one.
>> but it takes quite some overhead to be able to do so. i could post my
>> code if anyone is interested.
>>
>> unfortunately i could not find in your samples how you handle such a
>> scenario.
>>
>> does the "HACK" part of this rule have something to do with it?
>>
>> from curriculumCourseScoreRules.drl
>>
>> // MinimumWorkingDays: The lectures of each course must be spread into
>> a minimum number of days.
>> // Each day below the minimum counts as 5 points of penalty.
>> rule "minimumWorkingDays"
>>    when
>>        $course : Course($minWorkingDaySize : minWorkingDaySize);
>>        $dayCount : Number(intValue < $minWorkingDaySize) from accumulate(
>>            $day : Day()
>>            and exists Lecture(course == $course, day == $day),
>>            count($day)
>>        );
>>        // HACK to fix wierd truth maintance behavior in drools
>>        // because making weight part of the equals/hashcode doesn't cut it
>>        not IntConstraintOccurrence(
>>            ruleId == "minimumWorkingDays",
>>            constraintType == ConstraintType.NEGATIVE_SOFT,
>>            causes contains $course,
>>            eval(weight != (($minWorkingDaySize - $dayCount.intValue()) *
>> 5))
>>        );
>>        // An uninitialized schedule should have no constraints broken
>>        exists Lecture(course == $course);
>>    then
>>        insertLogical(new
>> IntConstraintOccurrence("minimumWorkingDays",
>> ConstraintType.NEGATIVE_SOFT,
>>                (($minWorkingDaySize - $dayCount.intValue()) * 5),
>>                $course));
>> end
>>
>> but the hack makes the rule not fire at all, when it had fired before.
>> even if the error has improved by now.
>>
>
> Feed back is always welcome :)
>
> With kind regards,
> Geoffrey De Smet
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



More information about the rules-users mailing list