[rules-users] Planner/solver - POSITIVE scoring...

Geoffrey De Smet ge0ffrey.spam at gmail.com
Thu Jan 7 15:35:59 EST 2010


> it seems odd - I want to use POSITIVE but I am using it to reduce the soft constraints broken?

You got a good point.
I already tried fixing that situation when refactoring from a double to 
the Score interface.
I wanted to remove the ScoreCalculator and just do:

global Score score;

with a single rule that has 2 accumulates: one for the hard and one for 
the soft constraints. It then updates the score field.


But because I ran into these issues:
   https://jira.jboss.org/jira/browse/JBRULES-2238
   https://jira.jboss.org/jira/browse/JBRULES-2239
the performance was divided by 3.
So I had to keep using a ScoreCalculator (where I didn't fix that 
oddness yet), for now.

Mark's true modify work will probably resolve those issues (especially 
in the Drools Planner use cases) and allow me to do the global Score 
score the way it needs to be done without loosing huge performance. So 
go Mark, go :)


Actually, the rule you wrote:

>     when
>         $softTotal : Number() from accumulate(
>             IntConstraintOccurrence(constraintType ==
> ConstraintType.NEGATIVE_SOFT, $weight : weight),
>             sum($weight) // Vote for
> http://jira.jboss.com/jira/browse/JBRULES-1075
>         );
>        $positiveTotal: Number() from accumulate(
>             IntConstraintOccurrence(constraintType ==
> ConstraintType.POSITIVE, $weight : weight),
>             sum($weight) // Vote for
> http://jira.jboss.com/jira/browse/JBRULES-1075
>         );

will get killed in performance because of those issues.
For now, just hack it by only making POSITIVE IntConstraintOccurrence's 
and use negative weights for NEGATIVE_SOFT's.

Currently, the ConstraintOccurrence aren't used outside the DRL (nothing 
specific in the drools planner core) but that might change once I 
implement the option to do conflict based statistics (or guided local 
search).

With kind regards,
Geoffrey De Smet


Greg Barton schreef:
> So, basically what you're saying is, "The impact of a given negative soft constraint is reduced by the occurrence of another positive constraint."
> 
> If that's the case, the rule makes sense to me: total up the occurrences of the negative constraint, total up the occurrences of the positive constraint, and then combine them in a way that describes their relationship.
> 
> In this case, what the positive constraint "favors" is the reduction or elimination of the negative constraint, so subtracting the positive constraint makes sense. (A classic "interference pattern" situation.)
> 
> --- On Thu, 1/7/10, Michael Neale <michael.neale at gmail.com> wrote:
> 
>> From: Michael Neale <michael.neale at gmail.com>
>> Subject: [rules-users] Planner/solver - POSITIVE scoring...
>> To: "Rules Users List" <rules-users at lists.jboss.org>, "Geoffrey" <ge0ffrey.spam at gmail.com>
>> Date: Thursday, January 7, 2010, 12:23 AM
>> Hi All - FYI I have been conversing
>> with Geoffrey on basic
>> solver/planner usage questions, but we are bring the
>> discussion here
>> in case others can benefit.
>>
>> So I am looking at using IntConstraintOccurrence, for
>> scoring with
>> weights, and HardAndSoftConstraintScoreCalculator. So I can
>> see how
>> NEGATIVE_HARD and NEGATIVE_SOFT scores would work, with
>> appropriate
>> accumulator rules doing that etc.
>>
>> What I am not sure about is ConstraintType.POSITIVE - so I
>> want to use
>> that to "favour" certain aspects of a solution. So would
>> the correct
>> way to use that to be to have rules that use a positive
>> IntConstrainOccurrence, and then do something like:
>>
>>     when
>>         $softTotal : Number() from
>> accumulate(
>>            
>> IntConstraintOccurrence(constraintType ==
>> ConstraintType.NEGATIVE_SOFT, $weight : weight),
>>             sum($weight) //
>> Vote for
>> http://jira.jboss.com/jira/browse/JBRULES-1075
>>         );
>>        $positiveTotal: Number()
>> from accumulate(
>>            
>> IntConstraintOccurrence(constraintType ==
>> ConstraintType.POSITIVE, $weight : weight),
>>             sum($weight) //
>> Vote for
>> http://jira.jboss.com/jira/browse/JBRULES-1075
>>         );
>>
>>     then
>>        
>> scoreCalculator.setSoftConstraintsBroken($softTotal.intValue()
>> - $positiveTotal.intValue());
>>
>>
>>
>> ?? it seems odd - I want to use POSITIVE but I am using it
>> to reduce
>> the soft constraints broken? The the higher the positive
>> score, the
>> less softConstraintsBroken property of the score calculator
>> is set -
>> that seems odd... or should I not use HardAndSoft if I am
>> using
>> POSITIVE and NEGATIVE scoring?
>>
>>
>> -- 
>> Michael D Neale
>> home: www.michaelneale.net
>> blog: michaelneale.blogspot.com
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> 
> 
>       
> 
> _______________________________________________
> 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