Package org.drools.planner.core.move

Examples of org.drools.planner.core.move.Move


    public void decideNextStep(LocalSearchStepScope localSearchStepScope) {
        WorkingMemory workingMemory = localSearchStepScope.getWorkingMemory();
        Iterator<Move> moveIterator = selector.moveIterator(localSearchStepScope);
        while (moveIterator.hasNext()) {
            Move move = moveIterator.next();
            MoveScope moveScope = new MoveScope(localSearchStepScope);
            moveScope.setMove(move);
            // Filter out not doable moves
            if (move.isMoveDoable(workingMemory)) {
                doMove(moveScope);
                if (forager.isQuitEarly()) {
                    break;
                }
            } else {
                logger.trace("        Ignoring not doable move ({}).", move);
            }
        }
        MoveScope pickedMoveScope = forager.pickMove(localSearchStepScope);
        if (pickedMoveScope != null) {
            Move step = pickedMoveScope.getMove();
            localSearchStepScope.setStep(step);
            if (logger.isDebugEnabled()) {
                localSearchStepScope.setStepString(step.toString());
            }
            localSearchStepScope.setUndoStep(step.createUndoMove(workingMemory));
            localSearchStepScope.setScore(pickedMoveScope.getScore());
        }
    }
View Full Code Here


        }
    }

    private void doMove(MoveScope moveScope) {
        WorkingMemory workingMemory = moveScope.getWorkingMemory();
        Move move = moveScope.getMove();
        Move undoMove = move.createUndoMove(workingMemory);
        moveScope.setUndoMove(undoMove);
        move.doMove(workingMemory);
        processMove(moveScope);
        undoMove.doMove(workingMemory);
        if (assertUndoMoveIsUncorrupted) {
            Score undoScore = moveScope.getLocalSearchStepScope().getLocalSearchSolverPhaseScope().calculateScoreFromWorkingMemory();
            Score lastCompletedStepScore = moveScope.getLocalSearchStepScope().getLocalSearchSolverPhaseScope()
                    .getLastCompletedLocalSearchStepScope().getScore();
            if (!undoScore.equals(lastCompletedStepScore)) {
View Full Code Here

        }

        public Move next() {
            int moveIteratorIndex = workingRandom.nextInt(moveIteratorList.size());
            Iterator<Move> moveIterator = moveIteratorList.get(moveIteratorIndex);
            Move next = moveIterator.next();
            if (!moveIterator.hasNext()) {
                moveIteratorList.remove(moveIteratorIndex);
            }
            return next;
        }
View Full Code Here

        LocalSearchStepScope localSearchStepScope = createNextStepScope(localSearchSolverPhaseScope, null);
        while (!termination.isPhaseTerminated(localSearchSolverPhaseScope)) {
            localSearchStepScope.setTimeGradient(termination.calculatePhaseTimeGradient(localSearchSolverPhaseScope));
            beforeDeciding(localSearchStepScope);
            decider.decideNextStep(localSearchStepScope);
            Move nextStep = localSearchStepScope.getStep();
            if (nextStep == null) {
                // TODO JBRULES-2213 do not terminate, but warn and try again
                logger.warn("No move accepted for step index ({}) out of {} accepted moves. Terminating by exception.",
                        localSearchStepScope.getStepIndex(), decider.getForager().getAcceptedMovesSize());
                break;
            }
            stepDecided(localSearchStepScope);
            nextStep.doMove(localSearchStepScope.getWorkingMemory());
            // there is no need to recalculate the score, but we still need to set it
            localSearchSolverPhaseScope.getWorkingSolution().setScore(localSearchStepScope.getScore());
            if (assertStepScoreIsUncorrupted) {
                localSearchSolverPhaseScope.assertWorkingScore(localSearchStepScope.getScore());
            }
View Full Code Here

            int result = JOptionPane.showConfirmDialog(NQueensPanel.this.getRootPane(), messagePanel,
                    "Queen in column " + queen.getColumn().getIndex(),
                    JOptionPane.OK_CANCEL_OPTION);
            if (result == JOptionPane.OK_OPTION) {
                Row toRow = (Row) rowListField.getSelectedItem();
                Move move = new RowChangeMove(queen, toRow);
                solutionBusiness.doMove(move);
                solverAndPersistenceFrame.resetScreen();
            }
        }
View Full Code Here

                        // assert(rotateList.size() % 2 == 0);

                        // if size is 2 then addCachedHomeAwaySwapMoves will have done it
                        if (rotateList.size() > 2) {
                            List<Match> emptyList = Collections.emptyList();
                            Move rotateMove = new MultipleMatchListRotateMove(rotateList, emptyList);
                            moveList.add(rotateMove);
                        }
                    }
                }
            }
View Full Code Here

        private void addTeamRotateMove(List<Move> moveList, List<Match> firstRotateList, List<Match> secondRotateList) {
            assert (firstRotateList.size() == secondRotateList.size());
            // if size is 1 then addCachedHomeAwaySwapMoves will have done it
            // if size is 2 then addDayRotation will have done it by 1 list of size 4
            if (firstRotateList.size() > 2) {
                Move rotateMove = new MultipleMatchListRotateMove(firstRotateList, secondRotateList);
                moveList.add(rotateMove);
            }
        }
View Full Code Here

            dayListField.setSelectedItem(match.getDay());
            int result = JOptionPane.showConfirmDialog(TravelingTournamentPanel.this.getRootPane(), dayListField,
                    "Select day", JOptionPane.OK_CANCEL_OPTION);
            if (result == JOptionPane.OK_OPTION) {
                Day toDay = (Day) dayListField.getSelectedItem();
                Move move = new DayChangeMove(match, toDay);
                solutionBusiness.doMove(move);
                solverAndPersistenceFrame.resetScreen();
            }
        }
View Full Code Here

TOP

Related Classes of org.drools.planner.core.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.