Examples of LocalSearchStepScope


Examples of org.drools.planner.core.localsearch.LocalSearchStepScope

        return bruteForceStepScope;
    }

    private LocalSearchStepScope createNextStepScope(LocalSearchSolverScope localSearchSolverScope, LocalSearchStepScope completedLocalSearchStepScope) {
        if (completedLocalSearchStepScope == null) {
            completedLocalSearchStepScope = new LocalSearchStepScope(localSearchSolverScope);
            completedLocalSearchStepScope.setScore(localSearchSolverScope.getStartingScore());
            completedLocalSearchStepScope.setStepIndex(-1);
            completedLocalSearchStepScope.setTimeGradient(0.0);
        }
        localSearchSolverScope.setLastCompletedLocalSearchStepScope(completedLocalSearchStepScope);
        LocalSearchStepScope localSearchStepScope = new LocalSearchStepScope(localSearchSolverScope);
        localSearchStepScope.setStepIndex(completedLocalSearchStepScope.getStepIndex() + 1);
        return localSearchStepScope;
    }
View Full Code Here

Examples of org.drools.planner.core.localsearch.LocalSearchStepScope

        // Setup
        Forager forager = new AcceptedForager(PickEarlyType.NEVER, Integer.MAX_VALUE);
        ((AcceptedForager) forager).setDeciderScoreComparatorFactory(new NaturalDeciderScoreComparatorFactory()); // TODO
        LocalSearchSolverPhaseScope localSearchSolverPhaseScope = createLocalSearchSolverPhaseScope();
        forager.phaseStarted(localSearchSolverPhaseScope);
        LocalSearchStepScope localSearchStepScope = createStepScope(localSearchSolverPhaseScope);
        forager.beforeDeciding(localSearchStepScope);
        // Pre conditions
        MoveScope a = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-20), true);
        MoveScope b = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-1), true);
        MoveScope c = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-20), false);
View Full Code Here

Examples of org.drools.planner.core.localsearch.LocalSearchStepScope

        // Setup
        Forager forager = new AcceptedForager(PickEarlyType.FIRST_BEST_SCORE_IMPROVING, Integer.MAX_VALUE);
        ((AcceptedForager) forager).setDeciderScoreComparatorFactory(new NaturalDeciderScoreComparatorFactory()); // TODO
        LocalSearchSolverPhaseScope localSearchSolverPhaseScope = createLocalSearchSolverPhaseScope();
        forager.phaseStarted(localSearchSolverPhaseScope);
        LocalSearchStepScope localSearchStepScope = createStepScope(localSearchSolverPhaseScope);
        forager.beforeDeciding(localSearchStepScope);
        // Pre conditions
        MoveScope a = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-1), false);
        MoveScope b = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-20), true);
        MoveScope c = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-300), true);
View Full Code Here

Examples of org.drools.planner.core.localsearch.LocalSearchStepScope

        // Setup
        Forager forager = new AcceptedForager(PickEarlyType.FIRST_LAST_STEP_SCORE_IMPROVING, Integer.MAX_VALUE);
        ((AcceptedForager) forager).setDeciderScoreComparatorFactory(new NaturalDeciderScoreComparatorFactory()); // TODO
        LocalSearchSolverPhaseScope localSearchSolverPhaseScope = createLocalSearchSolverPhaseScope();
        forager.phaseStarted(localSearchSolverPhaseScope);
        LocalSearchStepScope localSearchStepScope = createStepScope(localSearchSolverPhaseScope);
        forager.beforeDeciding(localSearchStepScope);
        // Pre conditions
        MoveScope a = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-1), false);
        MoveScope b = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-300), true);
        MoveScope c = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-4000), true);
View Full Code Here

Examples of org.drools.planner.core.localsearch.LocalSearchStepScope

        // Setup
        Forager forager = new AcceptedForager(PickEarlyType.NEVER, 1);
        ((AcceptedForager) forager).setDeciderScoreComparatorFactory(new NaturalDeciderScoreComparatorFactory()); // TODO
        LocalSearchSolverPhaseScope localSearchSolverPhaseScope = createLocalSearchSolverPhaseScope();
        forager.phaseStarted(localSearchSolverPhaseScope);
        LocalSearchStepScope localSearchStepScope = createStepScope(localSearchSolverPhaseScope);
        forager.beforeDeciding(localSearchStepScope);
        // Pre conditions
        MoveScope a = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-20), false);
        MoveScope b = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-1), true);
        MoveScope c = createMoveScope(localSearchStepScope, DefaultSimpleScore.valueOf(-1), false);
View Full Code Here

Examples of org.drools.planner.core.localsearch.LocalSearchStepScope

            public double nextDouble() {
                return 0.2;
            }
        });
        solverScope.setBestScore(DefaultSimpleScore.valueOf(-10));
        LocalSearchStepScope lastLocalSearchStepScope = new LocalSearchStepScope(localSearchSolverPhaseScope);
        lastLocalSearchStepScope.setScore(DefaultSimpleScore.valueOf(-100));
        localSearchSolverPhaseScope.setLastCompletedLocalSearchStepScope(lastLocalSearchStepScope);
        return localSearchSolverPhaseScope;
    }
View Full Code Here

Examples of org.drools.planner.core.localsearch.LocalSearchStepScope

        localSearchSolverPhaseScope.setLastCompletedLocalSearchStepScope(lastLocalSearchStepScope);
        return localSearchSolverPhaseScope;
    }

    private LocalSearchStepScope createStepScope(LocalSearchSolverPhaseScope localSearchSolverPhaseScope) {
        LocalSearchStepScope localSearchStepScope = new LocalSearchStepScope(localSearchSolverPhaseScope);
        return localSearchStepScope;
    }
View Full Code Here

Examples of org.drools.planner.core.localsearch.LocalSearchStepScope

        DefaultSolverScope solverScope = new DefaultSolverScope();
        solverScope.setBestScore(new DefaultSimpleScore(0));
        LocalSearchSolverPhaseScope solverPhaseScope = new LocalSearchSolverPhaseScope(solverScope);
        tabuAcceptor.phaseStarted(solverPhaseScope);

        LocalSearchStepScope stepScope0 = new LocalSearchStepScope(solverPhaseScope);
        stepScope0.setStepIndex(0);
        MoveScope moveScope1 = buildMoveScope(stepScope0, e1);
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e0)));
        assertEquals(true, tabuAcceptor.isAccepted(moveScope1));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e2)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e3)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e4)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e2))); // repeated call
        stepScope0.setStep(moveScope1.getMove());
        tabuAcceptor.stepTaken(stepScope0);
       
        LocalSearchStepScope stepScope1 = new LocalSearchStepScope(solverPhaseScope);
        stepScope1.setStepIndex(1);
        MoveScope moveScope2 = buildMoveScope(stepScope1, e2);
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e0)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e1)));
        assertEquals(true, tabuAcceptor.isAccepted(moveScope2));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e3)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e4)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e2))); // repeated call
        stepScope1.setStep(moveScope2.getMove());
        tabuAcceptor.stepTaken(stepScope1);

        LocalSearchStepScope stepScope2 = new LocalSearchStepScope(solverPhaseScope);
        stepScope2.setStepIndex(2);
        MoveScope moveScope4 = buildMoveScope(stepScope1, e4);
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e0)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e1)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e2)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e3)));
        assertEquals(true, tabuAcceptor.isAccepted(moveScope4));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e2))); // repeated call
        stepScope2.setStep(moveScope4.getMove());
        tabuAcceptor.stepTaken(stepScope2);

        LocalSearchStepScope stepScope3 = new LocalSearchStepScope(solverPhaseScope);
        stepScope3.setStepIndex(3);
        MoveScope moveScope3 = buildMoveScope(stepScope1, e3);
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e0)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e1)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e2)));
        assertEquals(true, tabuAcceptor.isAccepted(moveScope3));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e4)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e2))); // repeated call
        stepScope3.setStep(moveScope3.getMove());
        tabuAcceptor.stepTaken(stepScope3);

        LocalSearchStepScope stepScope4 = new LocalSearchStepScope(solverPhaseScope);
        stepScope4.setStepIndex(4);
        MoveScope moveScope1Again = buildMoveScope(stepScope1, e1);
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope4, e0)));
        assertEquals(true, tabuAcceptor.isAccepted(moveScope1Again));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope4, e2)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope4, e3)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope4, e4)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope4, e2))); // repeated call
        stepScope4.setStep(moveScope1Again.getMove());
        tabuAcceptor.stepTaken(stepScope4);
       
        tabuAcceptor.phaseEnded(solverPhaseScope);
    }
View Full Code Here

Examples of org.drools.planner.core.localsearch.LocalSearchStepScope

        DefaultSolverScope solverScope = new DefaultSolverScope();
        solverScope.setBestScore(new DefaultSimpleScore(0));
        LocalSearchSolverPhaseScope solverPhaseScope = new LocalSearchSolverPhaseScope(solverScope);
        tabuAcceptor.phaseStarted(solverPhaseScope);

        LocalSearchStepScope stepScope0 = new LocalSearchStepScope(solverPhaseScope);
        stepScope0.setStepIndex(0);
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e0)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e1)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e2)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e3)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e4)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e0, e1)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e0, e2)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e0, e3)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e0, e4)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e1, e2)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e1, e3)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e1, e4)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e2, e3)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e2, e4)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope0, e3, e4)));
        stepScope0.setStep(buildMoveScope(stepScope0, e0, e2).getMove());
        tabuAcceptor.stepTaken(stepScope0);

        LocalSearchStepScope stepScope1 = new LocalSearchStepScope(solverPhaseScope);
        stepScope1.setStepIndex(1);
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e0)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e1)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e2)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e3)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e4)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e0, e1)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e0, e2)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e0, e3)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e0, e4)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e1, e2)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e1, e3)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e1, e4)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e2, e3)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e2, e4)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, e3, e4)));
        stepScope1.setStep(buildMoveScope(stepScope1, e1).getMove());
        tabuAcceptor.stepTaken(stepScope1);

        LocalSearchStepScope stepScope2 = new LocalSearchStepScope(solverPhaseScope);
        stepScope2.setStepIndex(2);
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e0)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e1)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e2)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e3)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e4)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e0, e1)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e0, e2)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e0, e3)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e0, e4)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e1, e2)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e1, e3)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e1, e4)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e2, e3)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e2, e4)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope2, e3, e4)));
        stepScope2.setStep(buildMoveScope(stepScope2, e3, e4).getMove());
        tabuAcceptor.stepTaken(stepScope2);

        LocalSearchStepScope stepScope3 = new LocalSearchStepScope(solverPhaseScope);
        stepScope3.setStepIndex(3);
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e0)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e1)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e2)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e3)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e4)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e0, e1)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e0, e2)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e0, e3)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e0, e4)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e1, e2)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e1, e3)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e1, e4)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e2, e3)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e2, e4)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope3, e3, e4)));
        stepScope3.setStep(buildMoveScope(stepScope3, e0).getMove());
        tabuAcceptor.stepTaken(stepScope3);

        tabuAcceptor.phaseEnded(solverPhaseScope);
    }
View Full Code Here

Examples of org.drools.planner.core.localsearch.LocalSearchStepScope

        DefaultSolverScope solverScope = new DefaultSolverScope();
        solverScope.setBestScore(new DefaultSimpleScore(-100));
        LocalSearchSolverPhaseScope solverPhaseScope = new LocalSearchSolverPhaseScope(solverScope);
        tabuAcceptor.phaseStarted(solverPhaseScope);

        LocalSearchStepScope stepScope0 = new LocalSearchStepScope(solverPhaseScope);
        stepScope0.setStepIndex(0);
        stepScope0.setStep(buildMoveScope(stepScope0, e1).getMove());
        tabuAcceptor.stepTaken(stepScope0);

        LocalSearchStepScope stepScope1 = new LocalSearchStepScope(solverPhaseScope);
        stepScope1.setStepIndex(1);
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, -120, e0)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, -20, e0)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, -120, e1)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, -20, e1)));
        assertEquals(false, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, -120, e0, e1)));
        assertEquals(true, tabuAcceptor.isAccepted(buildMoveScope(stepScope1, -20, e0, e1)));
        stepScope1.setStep(buildMoveScope(stepScope1, -20, e1).getMove());
        tabuAcceptor.stepTaken(stepScope1);

        tabuAcceptor.phaseEnded(solverPhaseScope);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.