Package de.mh4j.solver.termination

Examples of de.mh4j.solver.termination.StepCountTermination


    @Test
    @SuppressWarnings("unchecked")
    public void testShouldTerminate() {
        int maxStepCount = 100;
        Solver<Object> solver = mock(Solver.class);
        TerminationCondition terminator = new StepCountTermination(solver, maxStepCount);

        when(solver.getNumberOfSteps()).thenReturn(0);
        assert terminator.shouldTerminate() == false;

        when(solver.getNumberOfSteps()).thenReturn(99);
        assert terminator.shouldTerminate() == false;

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

        when(solver.getNumberOfSteps()).thenReturn(1000);
        assert terminator.shouldTerminate() == true;
    }
View Full Code Here


    public SimulatedAnnealingKnapsackSolver(int knapsackCapacity, List<Item> availableItems) {
        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.StepCountTermination

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.