Package org.optaplanner.core.impl.heuristic.move

Examples of org.optaplanner.core.impl.heuristic.move.Move


            this.childMoveIterator = childMoveIterator;
        }

        @Override
        protected Move createUpcomingSelection() {
            Move next;
            long attemptsBeforeBailOut = bailOutEnabled ? determineBailOutSize() : 0L;
            do {
                if (!childMoveIterator.hasNext()) {
                    return noUpcomingSelection();
                }
View Full Code Here


                moveList[startingIndex] = moveIteratorList.get(startingIndex).next(); // Increment the 4 in 004999
            }
            for (int i = startingIndex + 1; i < childSize; i++) { // Increment the 9's in 004999
                Iterator<Move> moveIterator = childMoveSelectorList.get(i).iterator();
                moveIteratorList.set(i, moveIterator);
                Move next;
                if (!moveIterator.hasNext()) { // in case a moveIterator is empty
                    if (ignoreEmptyChildIterators) {
                        next = EMPTY_MARK;
                    } else {
                        return noUpcomingSelection();
View Full Code Here

                private Move nextReversingSelection = null;

                @Override
                protected Move createUpcomingSelection() {
                    if (selectReversingMoveToo && nextReversingSelection != null) {
                        Move upcomingSelection = nextReversingSelection;
                        nextReversingSelection = null;
                        return upcomingSelection;
                    }
                    return super.createUpcomingSelection();
                }
View Full Code Here

        stepScope.setSelectedMoveCount((long) moveIndex);
    }

    private void doMove(ExhaustiveSearchStepScope stepScope, ExhaustiveSearchNode moveNode) {
        ScoreDirector scoreDirector = stepScope.getScoreDirector();
        Move move = moveNode.getMove();
        Move undoMove = move.createUndoMove(scoreDirector);
        moveNode.setUndoMove(undoMove);
        move.doMove(scoreDirector);
        processMove(stepScope, moveNode);
        undoMove.doMove(scoreDirector);
        if (assertExpectedUndoMoveScore) {
            ExhaustiveSearchPhaseScope phaseScope = stepScope.getPhaseScope();
            phaseScope.assertExpectedUndoMoveScore(move, undoMove);
        }
        logger.trace("        Move treeId ({}), score ({}), expandable ({}), move ({}).",
View Full Code Here

            valueIterator = Iterators.emptyIterator();
        }

        protected Move createUpcomingSelection() {
            if (selectReversingMoveToo && nextReversingSelection != null) {
                Move upcomingSelection = nextReversingSelection;
                nextReversingSelection = null;
                return upcomingSelection;
            }

            if (!valueIterator.hasNext()) {
                if (!subChainIterator.hasNext()) {
                    return noUpcomingSelection();
                }
                upcomingSubChain = subChainIterator.next();
                valueIterator = valueSelector.iterator();
                if (!valueIterator.hasNext()) {
                    // valueSelector is completely empty
                    return noUpcomingSelection();
                }
            }
            Object toValue = valueIterator.next();

            Move upcomingSelection = new SubChainChangeMove(
                    upcomingSubChain, valueSelector.getVariableDescriptor(), toValue);
            if (selectReversingMoveToo) {
                nextReversingSelection = new SubChainReversingChangeMove(
                        upcomingSubChain, valueSelector.getVariableDescriptor(), toValue);
            }
View Full Code Here

public abstract class AbstractAcceptorTest {

    protected LocalSearchMoveScope buildMoveScope(LocalSearchStepScope stepScope, int score) {
        LocalSearchMoveScope moveScope = new LocalSearchMoveScope(stepScope);
        Move move = mock(Move.class);
        moveScope.setMove(move);
        moveScope.setScore(SimpleScore.valueOf(score));
        return moveScope;
    }
View Full Code Here

        SelectorTestUtils.mockMethodGetTrailingEntity(scoreDirector, variableDescriptor,
                new TestdataChainedEntity[]{a1, a2, a3, b1});

        ChainedChangeMove move = new ChainedChangeMove(a3, variableDescriptor, b1);
        Move undoMove = move.createUndoMove(scoreDirector);
        move.doMove(scoreDirector);

        SelectorTestUtils.assertChain(a0, a1, a2);
        SelectorTestUtils.assertChain(b0, b1, a3);

        verify(scoreDirector).beforeVariableChanged(variableDescriptor, a3);
        verify(scoreDirector).afterVariableChanged(variableDescriptor, a3);

        undoMove.doMove(scoreDirector);
        SelectorTestUtils.assertChain(a0, a1, a2, a3);
        SelectorTestUtils.assertChain(b0, b1);
    }
View Full Code Here

        SelectorTestUtils.mockMethodGetTrailingEntity(scoreDirector, variableDescriptor,
                new TestdataChainedEntity[]{a1, a2, a3, b1});

        ChainedChangeMove move = new ChainedChangeMove(a2, variableDescriptor, b0);
        Move undoMove = move.createUndoMove(scoreDirector);
        move.doMove(scoreDirector);

        SelectorTestUtils.assertChain(a0, a1, a3);
        SelectorTestUtils.assertChain(b0, a2, b1);

        verify(scoreDirector).beforeVariableChanged(variableDescriptor, a2);
        verify(scoreDirector).afterVariableChanged(variableDescriptor, a2);
        verify(scoreDirector).beforeVariableChanged(variableDescriptor, a3);
        verify(scoreDirector).afterVariableChanged(variableDescriptor, a3);
        verify(scoreDirector).beforeVariableChanged(variableDescriptor, b1);
        verify(scoreDirector).afterVariableChanged(variableDescriptor, b1);

        undoMove.doMove(scoreDirector);
        SelectorTestUtils.assertChain(a0, a1, a2, a3);
        SelectorTestUtils.assertChain(b0, b1);
    }
View Full Code Here

        return buildMoveScope(stepScope, 0, entities);
    }

    private LocalSearchMoveScope buildMoveScope(LocalSearchStepScope stepScope, int score, TestdataEntity... entities) {
        LocalSearchMoveScope moveScope = new LocalSearchMoveScope(stepScope);
        Move move = mock(Move.class);
        when(move.getPlanningEntities()).thenReturn((Collection) Arrays.asList(entities));
        moveScope.setMove(move);
        moveScope.setScore(SimpleScore.valueOf(score));
        return moveScope;
    }
View Full Code Here

                new TestdataChainedEntity[]{a1, a2, a3, a4, a5, b1, b2, b3});

        SubChainReversingSwapMove move = new SubChainReversingSwapMove(variableDescriptor,
                new SubChain(Arrays.<Object>asList(a3, a4, a5)),
                new SubChain(Arrays.<Object>asList(b2, b3)));
        Move undoMove = move.createUndoMove(scoreDirector);
        move.doMove(scoreDirector);

        SelectorTestUtils.assertChain(a0, a1, a2, b3, b2);
        SelectorTestUtils.assertChain(b0, b1, a5, a4, a3);

        verify(scoreDirector).beforeVariableChanged(variableDescriptor, a3);
        verify(scoreDirector).afterVariableChanged(variableDescriptor, a3);
        verify(scoreDirector).beforeVariableChanged(variableDescriptor, a4);
        verify(scoreDirector).afterVariableChanged(variableDescriptor, a4);
        verify(scoreDirector).beforeVariableChanged(variableDescriptor, a5);
        verify(scoreDirector).afterVariableChanged(variableDescriptor, a5);
        verify(scoreDirector, atLeastOnce()).beforeVariableChanged(variableDescriptor, b2);
        verify(scoreDirector, atLeastOnce()).afterVariableChanged(variableDescriptor, b2);
        verify(scoreDirector).beforeVariableChanged(variableDescriptor, b3);
        verify(scoreDirector).afterVariableChanged(variableDescriptor, b3);

        undoMove.doMove(scoreDirector);
        SelectorTestUtils.assertChain(a0, a1, a2, a3, a4, a5);
        SelectorTestUtils.assertChain(b0, b1, b2, b3);
    }
View Full Code Here

TOP

Related Classes of org.optaplanner.core.impl.heuristic.move.Move

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.