Thanks Geoffrey and Wolfgang, I will try what you suggested tomorrow morning.. (UTC + 11)
Cheers Megan Woods Sent from my iPad On Jan 9, 2013, at 20:06, "Geoffrey De Smet" <[email protected]> wrote: > > Op 09-01-13 01:00, megwoods schreef: >> Hi, >> >> I have been at this a couple of days now but I am getting score corruption >> from a rule that does the following: >> >> rule "to bigger gap" >> when >> $res: ResourceInstance() >> $resList : ArrayList(size > 1) >> from collect( TripAtTimeWithResource(resource == $res) ) >> then >> -- Sort the list using custom comparator. >> -- Measure a series of deltas between elements in the list. >> -- If the delta is larger than a threshold add a soft constraint. > 1) Ideally, this logic would be in the "when" part. > Not that that explains score corruption, but it should be faster > performance wise because it does better "incremental score calculation" > (see manual about that concept). > > I would also expect that there is no "from collect", but a "from > accumulate" to detect the max or sum of the delta. > > // quick pseudo code > when > $res: ResourceInstance() > (intValue > deltaTreshold )from accumulate( > TripAtTimeWithResource(resource == $res, $a : timeslot) > and TripAtTimeWithResource(resource == $res, timeslot > $a, $b : > timeslot) > and not TripAtTimeWithResource(resource == $res, timeslot > $a, > timeslot < $b), > max(... delta of $a and $b ...) > ) > then > > > Addendum: If needed (because of performance reasons how from's currently > work), > you might want split it up into 2 rules, similar as nurse rostering's > drl does regularly (with the Start and End logicalInserts), although > it's unlikely. >> insertLogical(new IntConstraintOccurrence("to bigger gap", >> ConstraintType.NEGATIVE_SOFT,delta * 10, ttrL)); > 2) What's that cause ttrL? I would have expected $res as a cause? >> >> end >> >> The TripAtTimeWithResource is the planning entity. >> >> I have checked the cloning and been through and checked that all equals and >> hashcode methods and they are correct. >> >> If I take this rule out the implementation functions as correctly. >> >> Interestingly though I first prototyped this using a simple score and with >> the same 'when' and 'then' clause (inserting a different fact) and no score >> corruption was observed. >> >> If anyone has any suggestions I would really like to hear from you. >> >> Cheers Megan Woods >> >> Extract from exception: >> The workingMemory has 3 ConstraintOccurrence(s) in excess: >> to bigger gap/NEGATIVE_SOFT:[TripAtTimeWithResource >> [trip=a.c.t.p.p.m.TripInstance@43b, resource=All(17), startTime=TimeUnit >> [minute=285]]]=750 >> to bigger gap/NEGATIVE_SOFT:[TripAtTimeWithResource >> [trip=a.c.t.p.p.m.TripInstance@46c, resource=All(17), startTime=TimeUnit >> [minute=75]]]=1700 >> to bigger gap/NEGATIVE_SOFT:[TripAtTimeWithResource >> [trip=a.c.t.p.p.m.TripInstance@421, resource=All(17), startTime=TimeUnit >> [minute=75]]]=960 >> The workingMemory has 4 ConstraintOccurrence(s) lacking: >> overlapping trips with same >> resource/NEGATIVE_HARD:[TripAtTimeWithResource >> [trip=a.c.t.p.p.m.TripInstance@43b, resource=All(17), startTime=TimeUnit >> [minute=285]]]=100 >> to bigger gap/NEGATIVE_SOFT:[TripAtTimeWithResource >> [trip=a.c.t.p.p.m.TripInstance@421, resource=All(17), startTime=TimeUnit >> [minute=75]]]=1710 >> to bigger gap/NEGATIVE_SOFT:[TripAtTimeWithResource >> [trip=a.c.t.p.p.m.TripInstance@43b, resource=All(17), startTime=TimeUnit >> [minute=285]]]=1650 >> to bigger gap/NEGATIVE_SOFT:[TripAtTimeWithResource >> [trip=a.c.t.p.p.m.TripInstance@46c, resource=All(17), startTime=TimeUnit >> [minute=75]]]=950 >> >> >> >> -- >> View this message in context: >> http://drools.46999.n3.nabble.com/Difficulty-determining-why-I-have-score-corruption-tp4021412.html >> Sent from the Drools: User forum mailing list archive at Nabble.com. >> _______________________________________________ >> rules-users mailing list >> [email protected] >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
