Search code examples
optaplanner

OptaPlanner repeat last move indefinitely


I implemented an algorithm similar to CloudBalancing using OptaPlanner 7.56.

Actually i'm using a ChangeMoveSelector that i filtered with some conditions and it work greats. When no move are available it stop and return the best solution.

<localSearch>
    <changeMoveSelector>
        <selectionOrder>ORIGINAL</selectionOrder>
        <filterClass>...</filterClass>
    </changeMoveSelector>

    <acceptor>
        <acceptorType>HILL_CLIMBING</acceptorType>
    </acceptor>
    <forager>
        <pickEarlyType>NEVER</pickEarlyType>
        <acceptedCountLimit>1000</acceptedCountLimit>
    </forager>
</localSearch>

But i tried to add a PillarChangeMove with similar filter and after checking all possible moves, it repeat the last move indefinitely and after some times i get the following warning Bailing out of neverEnding selector.

<unionMoveSelector>
    <changeMoveSelector>
        <selectionOrder>ORIGINAL</selectionOrder>
        <filterClass>...</filterClass>
    </changeMoveSelector>
        
    <pillarChangeMoveSelector>
        <filterClass>...</filterClass>
        <subPillarType>NONE</subPillarType>
    </pillarChangeMoveSelector>
</unionMoveSelector>

Solution

  • I remember that i had the same issue when i implemented ChangeMoveSelector. I fixed by adding <selectionOrder>ORIGINAL</selectionOrder>

    <unionMoveSelector>
        <changeMoveSelector>
            <selectionOrder>ORIGINAL</selectionOrder>
            <filterClass>...</filterClass>
        </changeMoveSelector>
    
        <pillarChangeMoveSelector>
            <selectionOrder>ORIGINAL</selectionOrder>
            <filterClass>...</filterClass>
            <subPillarType>NONE</subPillarType>
        </pillarChangeMoveSelector>
    </unionMoveSelector>