[rules-users] Re: drools 5.0.0-SNAPSHOT Maven repository broken?
Geoffrey De Smet
ge0ffrey.spam at gmail.com
Mon Oct 13 12:10:27 EDT 2008
tim tim schreef:
> where i got stuck for quite some time was this:
>
> http://www.nabble.com/Questions-about-logically-justified-objects-ts14788904.html#a14790335
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
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 :)
>
> and i could not find how you solved this problem in the end.
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.
>
> 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
More information about the rules-users
mailing list