Example from Optaplanner documentation on cartesianProductMoveSelector throws an exception:

Viewed 14

What is the proper way to do the cartesian move of two changeMoveSelectors for two planning variables?

I took the cartesianProductMoveSelector example From the documentation for Optaplanner version 8.25. The following configuration:

<?xml version="1.0" encoding="UTF-8"?>

<solver>
    <solutionClass>com.company.MySolution</solutionClass>
    <entityClass>com.company.Standstill</entityClass>
    <entityClass>com.company.PlanningVisit</entityClass>

    <environmentMode>REPRODUCIBLE</environmentMode>
    <randomSeed>50</randomSeed>
    <environmentMode>FULL_ASSERT</environmentMode>

    <scoreDirectorFactory>
        <constraintProviderClass>com.company.MyConstraintProvider
        </constraintProviderClass>
        <initializingScoreTrend>ONLY_DOWN</initializingScoreTrend>
    </scoreDirectorFactory>
    <termination>
        <minutesSpentLimit>1800</minutesSpentLimit>
    </termination>

    <customPhase>
        <customPhaseCommandClass>com.company.phase.MySolutionInit</customPhaseCommandClass>
    </customPhase>
    <constructionHeuristic>
        <changeMoveSelector>
        </changeMoveSelector>
        <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
    </constructionHeuristic>

    <localSearch>
        <termination>
            <minutesSpentLimit>300</minutesSpentLimit>
        </termination>
        
        <unionMoveSelector>
            <moveListFactory>
                <variableName>previousStandstill</variableName>
                <moveListFactoryClass>com.company.moves.RideChangeMoveFactory</moveListFactoryClass>
            </moveListFactory>
            
            <cartesianProductMoveSelector>
                <changeMoveSelector>
                    <entitySelector id="cartesianProductEntitySelector"/>
                    <valueSelector>
                        <variableName>previousStandstill</variableName>
                    </valueSelector>
                </changeMoveSelector>
                <changeMoveSelector>
                    <entitySelector mimicSelectorRef="cartesianProductEntitySelector"/>
                    <valueSelector>
                        <variableName>startModifier</variableName>
                    </valueSelector>
                </changeMoveSelector>
            </cartesianProductMoveSelector>
            <swapMoveSelector>
                <variableName>previousStandstill</variableName>
            </swapMoveSelector>
            <subChainChangeMoveSelector>
                <subChainSelector>
                    <valueSelector variableName="previousStandstill">
                    </valueSelector>
                </subChainSelector>
                <valueSelector variableName="previousStandstill">
                </valueSelector>
                <selectReversingMoveToo>true</selectReversingMoveToo>
            </subChainChangeMoveSelector>

            <subChainSwapMoveSelector>
                <subChainSelector>
                    <valueSelector variableName="previousStandstill">
                    </valueSelector>
                </subChainSelector>
                <secondarySubChainSelector>
                    <valueSelector variableName="previousStandstill">
                    </valueSelector>
                </secondarySubChainSelector>
                <selectReversingMoveToo>true</selectReversingMoveToo>
            </subChainSwapMoveSelector>

            <tailChainSwapMoveSelector>
                <valueSelector variableName="previousStandstill">
                </valueSelector>
            </tailChainSwapMoveSelector>
        </unionMoveSelector>
        <acceptor>
            <entityTabuSize>12</entityTabuSize>
        </acceptor>
        <forager>
            <acceptedCountLimit>3000</acceptedCountLimit>
        </forager>
    </localSearch>
</solver>

Throws an

Multiple EntityMimicRecorders (usually EntitySelectors) have the same id (cartesianProductEntitySelector).
0 Answers
Related