Package de.mh4j.solver.termination

Examples of de.mh4j.solver.termination.StagnationTermination


    @SuppressWarnings({ "rawtypes", "unchecked" })
    public void testShouldTerminate() {
        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;
        }

        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


        super(new KnapsackCoolingScheme());
        this.knapsackCapacity = knapsackCapacity;
        this.availableItems = availableItems;

        addTerminationCondition(new StepCountTermination(this, 50));
        addTerminationCondition(new StagnationTermination(this, 5));
    }
View Full Code Here

TOP

Related Classes of de.mh4j.solver.termination.StagnationTermination

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.