質問

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:...
役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top