0

I have tried posting on the user forum for Drools, but haven't been getting any responses (I am sure they are just busy), so I am hoping to attract a wider audience here.

I am very confused by the results I am getting as they seem to not be providing me with the "best score". Here is some of the log output:

[construction steps] 
2013-03-13 08:00:08,305 [com....] INFO  Phase constructionHeuristic ended: step total (60), time spend (2222), best score (-200hard/-2780soft). 
[local search steps] 
2013-03-13 08:00:21,807 [com....] INFO  Phase localSearch ended: step total (42), time spend (15724), best score (0hard/-2495soft). 
2013-03-13 08:00:21,807 [com....] INFO  Solving ended: time spend (15724), best score (0hard/-2495soft), average calculate count per second (3748). 

However, the results it gives me back contains a broken hard constraint (even though the log clearly states "Solving ended: time spend (15724), best score (0hard/-2495soft)") - it is giving me a result with score -200hard/-2495soft (which appears to be the hard score of the construction phase and the soft score of the local search phase). Is this how it is supposed to be? Did I miss something in the manual (I have read it, but I haven't digested it completely)?

Here is most of my solver config (just the potentially relevant portion):

<termination>
        <terminationCompositionStyle>OR</terminationCompositionStyle>
        <maximumSecondsSpend>60</maximumSecondsSpend>
        <scoreAttained>0hard/0soft</scoreAttained>
</termination>

<constructionHeuristic>
        <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
    <constructionHeuristicPickEarlyType>FIRST_LAST_STEP_SCORE_EQUAL_OR_IMPROVING</constructionHeuristicPickEarlyType>  
</constructionHeuristic>

<localSearch>
        <termination>
                <terminationCompositionStyle>OR</terminationCompositionStyle>
                <maximumUnimprovedStepCount>20</maximumUnimprovedStepCount>
                <scoreAttained>0hard/0soft</scoreAttained>
        </termination>
        <unionMoveSelector>
            <changeMoveSelector>
              <entitySelector>
                <entityFilterClass>com.....RequiredTypeEntityFilter</entityFilterClass>
              </entitySelector>
            </changeMoveSelector>
            <swapMoveSelector>
              <entitySelector>
                <entityFilterClass>com.....RequiredTypeEntityFilter</entityFilterClass>
              </entitySelector>
            </swapMoveSelector>
        </unionMoveSelector>
        <acceptor>
              <solutionTabuSize>1000</solutionTabuSize>
              <planningEntityTabuSize>7</planningEntityTabuSize>
        </acceptor>
        <forager>
                <minimalAcceptedSelection>1000</minimalAcceptedSelection>
        </forager>
</localSearch>

Thanks in advance!

Edit: Here is a little more information that might be helpful... As stated above, it says my best (Hard) score is 0, but the solution it gives me contains a Hard constraint violation. I added some code to printout the constraints (using DroolsScoreDirector to get to the WorkingMemory and ultimately the ConstraintOccurrences)... this printout shows a hard constraint as well.

ConstraintType: NEGATIVE_HARD, RuleID: endLocationMustMatchStartLocation, Causes:...
PaulP1975
  • 528
  • 1
  • 5
  • 12
  • Here's the [related forum post](http://drools.46999.n3.nabble.com/Using-EntitySelector-EntityFilterClass-td4022770.html). Looks like it didn't come through on the mailing list, due the Nabble hoops. We 're looking to remove those hoops. – Geoffrey De Smet Mar 14 '13 at 08:54

1 Answers1

1

Most likely, your cloneSolution() method is corrupted (or the entity.clone() methods it calls). Double check those methods.

In Drools Planner 6.0, you won't need to implement that cloning method.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • Thanks Geoffrey, I will try fixing my clone methods and report back on the result. I have seen several blog posts about 6.0 and look forward to its release (I will try beta once it is out). – PaulP1975 Mar 14 '13 at 10:47
  • Geoffrey, I did find a minor issue with my equals/hashCode in my Solution and the solutionEquals/solutionHashCode - I fixed it, but that still didn't solve the issue. I could find nothing wrong with the clone on the planning entity nor the cloneSolution(). Can you think of anything else that might cause the issue? – PaulP1975 Mar 14 '13 at 12:48
  • Geoffrey, I added an edit above showing that the solution provided as the result contains a hard constraint violation... I am very confused why it doesn't seem to be giving me the "best" found solution based on the score. – PaulP1975 Mar 14 '13 at 13:14
  • @PaulP1975 It should give you the "best" solution found based on the score, so that's clearly an issue. I am pretty confident it's not in Planner (until proven otherwise). A few things to try: enable environmentMode FULL_ASSERT (see docs). If that doesn't crash it, turn it off again and debug BestSolutionRecaller. – Geoffrey De Smet Mar 14 '13 at 19:21
  • in 5.5.x FULL_ASSERT is still known as TRACE – Geoffrey De Smet Mar 14 '13 at 19:22
  • @Geoffrey... I agree, I doubt it is Planner... something is amiss, I am sure. I will try those suggestions and report back. – PaulP1975 Mar 15 '13 at 12:27
  • meanwhile, read up on "incremental score calculation", , the mailing lists mail with "score corruption" and especially the causes parameter in IntConstraintOccurrence()'s source and the method insertLogical() in the droolsexpert manual – Geoffrey De Smet Mar 15 '13 at 16:10
  • I still have an issue, but your direction has helped me isolate it to a specific rule. I am getting score corruption and it is related to the parameters I am passing to the IntConstraintOccurrence object. Thanks so much for your time. – PaulP1975 Mar 15 '13 at 16:19
  • after a LOT of thinking about my problem and looking at code/docs, I finally figured out the root cause of this issue. It is the nature of the rule and the incremental calculator. The problem is that when a move is incrementally calculated, it only looks at the event being planned, but this rule would require a recalculation of the next event this resource was planned to. In short, I need to implement my own IncrementalScoreCalc - I am looking into this now. – PaulP1975 Mar 18 '13 at 10:48
  • Geoffrey - looks like i might still need your help... here is the follow up issue with full explanation on the user forum: http://drools.46999.n3.nabble.com/Drools-Planner-Need-help-with-IncrementalScoreCalculation-for-a-specific-move-td4022857.html - hopefully with your experience, this is trivial. Thanks! – PaulP1975 Mar 18 '13 at 13:56
  • Needing to implement a custom IncrementalScoreCalculator shouldn't be needed (although that will solve your problem too of course). It could be a bug in drools 5.5.0.Final (you can use 5.5.1-SNAPSHOT to prove this) - soon 5.6.0.Final and 6.0.0.Beta1 will be released. It could be a bug in your causes parameter, due to the insertLogical complexity (which will be heavily reduced in 6.0.0.CR1 or 6.1) – Geoffrey De Smet Mar 19 '13 at 11:56
  • Geoffrey, I haven't had a chance to try 5.5.1 yet, but a quick question... do you think if i included the "next" event in the causes parameters, would it recalculate the score for that event as well? I guess the real question is, does the "causes" parameter have any affect on the incremental "move" calculation? – PaulP1975 Mar 20 '13 at 13:19