[rules-users] Re: drools solver move factory crash

Geoffrey De Smet ge0ffrey.spam at gmail.com
Mon Oct 13 11:52:38 EDT 2008


Thanks for the feedback, I 've just committed a fix for it that should 
solve it:


if (relativeSelection != null) {
             int selectionSize = (int) Math.ceil(relativeSelection * 
moveList.size());
             if (selectionSize == 0 && !moveList.isEmpty()) {
                 selectionSize = 1;
             }
             moveList = moveList.subList(0, selectionSize);
         }


Feel free to make me jira issues and assign them to me, because I might 
overlook or forget issues in e-mail (especially big fix issues).


With kind regards,
Geoffrey De Smet


tim tim schreef:
> hello
> 
> the new version of the drools-solver supports multiple move factories.
> 
> i happily split my move factory to take advantage of the
> relativeSelection parameter.
> 
> now the problem is that not all move factories can produce moves for
> every possible
> current solution. and the
> 
> org.drools.solver.core.localsearch.decider.selector.MoveFactorySelector
> 
> crashes, when a move factory does not return a single move.
> 
> public final List<Move> selectMoveList(StepScope stepScope) {
>         List<Move> moveList =
> moveFactory.createMoveList(stepScope.getWorkingSolution());
>         if (shuffle) {
>             Collections.shuffle(moveList, stepScope.getWorkingRandom());
>         }
>         if (relativeSelection != null) {
>             int selectionSize = (int) Math.ceil(relativeSelection *
> moveList.size());
>             if (selectionSize == 0) {
>                 selectionSize = 1;
>             }
>             moveList = moveList.subList(0, selectionSize);  // <--
> CRASH, if moveList is empty
>         }
>         return moveList;
> }
> 
> currently i solve it by always returning at least a "null-move".
> 
> but a better solution would be to change the
> MoveFactorySelector.selectMoveList(), so that it tests for an
> empty list.
> 
> best, tim
> _______________________________________________
> 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