Examples of shouldTerminate()


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

        assert !stagnation.shouldTerminate(data) : "Stagnation should not be triggered for at least 2 more generations.";
        // Now we let the mean stagnate...and let the best candidate get fitter...
        data = new PopulationData<Object>(new Object(), 2.1, 1.6, 0.1, true, 10, 0, 3, 4);
        assert !stagnation.shouldTerminate(data) : "Stagnation should not be triggered for at least 1 more generation.";
        data = new PopulationData<Object>(new Object(), 2.2, 1.5, 0.1, true, 10, 0, 4, 4);
        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()

    public void testGenerationCounts()
    {
        TerminationCondition condition = new GenerationCount(5);
        PopulationData<Object> data = new PopulationData<Object>(new Object(), 0, 0, 0, true, 2, 0, 3, 100);
        // Generation number 3 is the 4th generation (generation numbers are zero-based).
        assert !condition.shouldTerminate(data) : "Should not terminate after 4th generation.";
        data = new PopulationData<Object>(new Object(), 0, 0, 0, true, 2, 0, 4, 100);
        // Generation number 4 is the 5th generation (generation numbers are zero-based).
        assert condition.shouldTerminate(data) : "Should terminate after 5th generation.";
    }
View Full Code Here

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

        PopulationData<Object> data = new PopulationData<Object>(new Object(), 0, 0, 0, true, 2, 0, 3, 100);
        // Generation number 3 is the 4th generation (generation numbers are zero-based).
        assert !condition.shouldTerminate(data) : "Should not terminate after 4th generation.";
        data = new PopulationData<Object>(new Object(), 0, 0, 0, true, 2, 0, 4, 100);
        // Generation number 4 is the 5th generation (generation numbers are zero-based).
        assert condition.shouldTerminate(data) : "Should terminate after 5th generation.";
    }


    /**
     * The generation count must be greater than zero to be useful.  This test
View Full Code Here

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

    @Test
    public void testNaturalFitness()
    {
        TerminationCondition condition = new TargetFitness(10.0d, true);
        PopulationData<Object> data = new PopulationData<Object>(new Object(), 5.0d, 4.0d, 0, true, 2, 0, 0, 100);
        assert !condition.shouldTerminate(data) : "Should not terminate before target fitness is reached.";
        data = new PopulationData<Object>(new Object(), 10.0d, 8.0d, 0, true, 2, 0, 0, 100);
        assert condition.shouldTerminate(data) : "Should terminate once target fitness is reached.";
    }

View Full Code Here

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

    {
        TerminationCondition condition = new TargetFitness(10.0d, true);
        PopulationData<Object> data = new PopulationData<Object>(new Object(), 5.0d, 4.0d, 0, true, 2, 0, 0, 100);
        assert !condition.shouldTerminate(data) : "Should not terminate before target fitness is reached.";
        data = new PopulationData<Object>(new Object(), 10.0d, 8.0d, 0, true, 2, 0, 0, 100);
        assert condition.shouldTerminate(data) : "Should terminate once target fitness is reached.";
    }


    @Test
    public void testNonNaturalFitness()
View Full Code Here

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

    @Test
    public void testNonNaturalFitness()
    {
        TerminationCondition condition = new TargetFitness(1.0d, false);
        PopulationData<Object> data = new PopulationData<Object>(new Object(), 5.0d, 4.0d, 0, true, 2, 0, 0, 100);
        assert !condition.shouldTerminate(data) : "Should not terminate before target fitness is reached.";
        data = new PopulationData<Object>(new Object(), 1.0d, 3.1d, 0, true, 2, 0, 0, 100);
        assert condition.shouldTerminate(data) : "Should terminate once target fitness is reached.";
    }
}
View Full Code Here

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

    {
        TerminationCondition condition = new TargetFitness(1.0d, false);
        PopulationData<Object> data = new PopulationData<Object>(new Object(), 5.0d, 4.0d, 0, true, 2, 0, 0, 100);
        assert !condition.shouldTerminate(data) : "Should not terminate before target fitness is reached.";
        data = new PopulationData<Object>(new Object(), 1.0d, 3.1d, 0, true, 2, 0, 0, 100);
        assert condition.shouldTerminate(data) : "Should terminate once target fitness is reached.";
    }
}
View Full Code Here

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

    @Test
    public void testElapsedTimes()
    {
        TerminationCondition condition = new ElapsedTime(1000);
        PopulationData<Object> data = new PopulationData<Object>(new Object(), 0, 0, 0, true, 2, 0, 0, 100);
        assert !condition.shouldTerminate(data) : "Should not terminate before timeout.";
        data = new PopulationData<Object>(new Object(), 0, 0, 0, true, 2, 0, 0, 1000);
        assert condition.shouldTerminate(data) : "Should terminate after timeout.";
    }

View Full Code Here

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

    {
        TerminationCondition condition = new ElapsedTime(1000);
        PopulationData<Object> data = new PopulationData<Object>(new Object(), 0, 0, 0, true, 2, 0, 0, 100);
        assert !condition.shouldTerminate(data) : "Should not terminate before timeout.";
        data = new PopulationData<Object>(new Object(), 0, 0, 0, true, 2, 0, 0, 1000);
        assert condition.shouldTerminate(data) : "Should terminate after timeout.";
    }


    /**
     * The duration must be greater than zero to be useful.  This test
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.