Examples of shouldTerminate()


Examples of de.mh4j.solver.termination.TerminationCondition.shouldTerminate()

        when(solver.getNumberOfSteps()).thenReturn(100);
        assert terminator.shouldTerminate() == true;

        when(solver.getNumberOfSteps()).thenReturn(1000);
        assert terminator.shouldTerminate() == true;
    }

}
View Full Code Here

Examples of de.mh4j.solver.termination.TerminationCondition.shouldTerminate()

    @Test
    public void testSolverRun() {
        AbstractSolver<Object> solver = spy(new AbstractSolverMock());

        TerminationCondition terminationCondition = mock(TerminationCondition.class);
        when(terminationCondition.shouldTerminate()).thenReturn(true);
        solver.addTerminationCondition(terminationCondition);

        @SuppressWarnings("unchecked")
        SolverStateListener<Object> stateListener = mock(SolverStateListener.class);
        solver.addStateListener(stateListener);
View Full Code Here

Examples of de.mh4j.solver.termination.TerminationCondition.shouldTerminate()

        int maxNrOfStagnatingSteps = 50;
        Solver solver = mock(Solver.class);
        when(solver.getCurrentSolution()).thenReturn(mock(Solution.class));
        TerminationCondition terminator = new StagnationTermination(solver, maxNrOfStagnatingSteps);

        assert terminator.shouldTerminate() == false;

        for (int i = 0; i < maxNrOfStagnatingSteps - 1; i++) {
            assert terminator.shouldTerminate() == false;
        }
View Full Code Here

Examples of de.mh4j.solver.termination.TerminationCondition.shouldTerminate()

        TerminationCondition terminator = new StagnationTermination(solver, maxNrOfStagnatingSteps);

        assert terminator.shouldTerminate() == false;

        for (int i = 0; i < maxNrOfStagnatingSteps - 1; i++) {
            assert terminator.shouldTerminate() == false;
        }

        assert terminator.shouldTerminate() == true : "Terminator should terminate now because we asked it "
                + maxNrOfStagnatingSteps
                + " if we should terminate without any improvement in the associated solver";
View Full Code Here

Examples of de.mh4j.solver.termination.TerminationCondition.shouldTerminate()

        for (int i = 0; i < maxNrOfStagnatingSteps - 1; i++) {
            assert terminator.shouldTerminate() == false;
        }

        assert terminator.shouldTerminate() == true : "Terminator should terminate now because we asked it "
                + maxNrOfStagnatingSteps
                + " if we should terminate without any improvement in the associated solver";
    }

}
View Full Code Here

Examples of org.uncommons.watchmaker.framework.TerminationCondition.shouldTerminate()

    @Test
    public void testFittestCandidateStagnation()
    {
        TerminationCondition stagnation = new Stagnation(2, true);
        PopulationData<Object> data = new PopulationData<Object>(new Object(), 2, 1, 0.1, true, 10, 0, 0, 1);
        assert !stagnation.shouldTerminate(data) : "Stagnation should not be triggered for at least 2 more generations.";
        // Best doesn't improve even though mean does.
        data = new PopulationData<Object>(new Object(), 1.8, 1.2, 0.1, true, 10, 0, 1, 2);
        assert !stagnation.shouldTerminate(data) : "Stagnation should not be triggered for at least 1 more generation.";
        // Best doesn't improve even though mean does.
        data = new PopulationData<Object>(new Object(), 2, 1.5, 0.1, true, 10, 0, 2, 3);
View Full Code Here

Examples of org.uncommons.watchmaker.framework.TerminationCondition.shouldTerminate()

        TerminationCondition stagnation = new Stagnation(2, true);
        PopulationData<Object> data = new PopulationData<Object>(new Object(), 2, 1, 0.1, true, 10, 0, 0, 1);
        assert !stagnation.shouldTerminate(data) : "Stagnation should not be triggered for at least 2 more generations.";
        // Best doesn't improve even though mean does.
        data = new PopulationData<Object>(new Object(), 1.8, 1.2, 0.1, true, 10, 0, 1, 2);
        assert !stagnation.shouldTerminate(data) : "Stagnation should not be triggered for at least 1 more generation.";
        // Best doesn't improve even though mean does.
        data = new PopulationData<Object>(new Object(), 2, 1.5, 0.1, true, 10, 0, 2, 3);
        assert stagnation.shouldTerminate(data) : "Stagnation should be triggered after 2 generations without improvement.";
    }
View Full Code Here

Examples of org.uncommons.watchmaker.framework.TerminationCondition.shouldTerminate()

        // Best doesn't improve even though mean does.
        data = new PopulationData<Object>(new Object(), 1.8, 1.2, 0.1, true, 10, 0, 1, 2);
        assert !stagnation.shouldTerminate(data) : "Stagnation should not be triggered for at least 1 more generation.";
        // Best doesn't improve even though mean does.
        data = new PopulationData<Object>(new Object(), 2, 1.5, 0.1, true, 10, 0, 2, 3);
        assert stagnation.shouldTerminate(data) : "Stagnation should be triggered after 2 generations without improvement.";
    }

    @Test
    public void testFittestCandidateStagnationNonNatural()
    {
View Full Code Here

Examples of org.uncommons.watchmaker.framework.TerminationCondition.shouldTerminate()

    @Test
    public void testFittestCandidateStagnationNonNatural()
    {
        TerminationCondition stagnation = new Stagnation(2, false);
        PopulationData<Object> data = new PopulationData<Object>(new Object(), 2, 1.5, 0.1, true, 10, 0, 0, 1);
        assert !stagnation.shouldTerminate(data) : "Stagnation should not be triggered for at least 2 more generations.";
        // Best doesn't improve even though mean does.
        data = new PopulationData<Object>(new Object(), 2.2, 1.2, 0.1, true, 10, 0, 1, 2);
        assert !stagnation.shouldTerminate(data) : "Stagnation should not be triggered for at least 1 more generation.";
        // Best doesn't improve even though mean does.
        data = new PopulationData<Object>(new Object(), 2, 1, 0.1, true, 10, 0, 2, 3);
View Full Code Here

Examples of org.uncommons.watchmaker.framework.TerminationCondition.shouldTerminate()

        TerminationCondition stagnation = new Stagnation(2, false);
        PopulationData<Object> data = new PopulationData<Object>(new Object(), 2, 1.5, 0.1, true, 10, 0, 0, 1);
        assert !stagnation.shouldTerminate(data) : "Stagnation should not be triggered for at least 2 more generations.";
        // Best doesn't improve even though mean does.
        data = new PopulationData<Object>(new Object(), 2.2, 1.2, 0.1, true, 10, 0, 1, 2);
        assert !stagnation.shouldTerminate(data) : "Stagnation should not be triggered for at least 1 more generation.";
        // Best doesn't improve even though mean does.
        data = new PopulationData<Object>(new Object(), 2, 1, 0.1, true, 10, 0, 2, 3);
        assert stagnation.shouldTerminate(data) : "Stagnation should be triggered after 2 generations without improvement.";
    }
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.