예제 #1
0
        public void TestCoeffVariationTerminationCriteria()
        {
            double threshold   = 2.5e-2;
            var    termination = new ShuffledComplexEvolution <TestHyperCube> .CoefficientOfVariationTerminationCondition(threshold : threshold);

            IObjectiveScores[] population = createSample(converged: false);
            double             cv         = termination.GetMaxParameterCoeffVar(population);

            Assert.AreEqual(0.1104401, cv, 1e-6);
            Assert.IsFalse(termination.IsBelowCvThreshold(population));

            population = createSample(converged: true);
            cv         = termination.GetMaxParameterCoeffVar(population);
            Assert.AreEqual(0.01741291, cv, 1e-6);
            Assert.IsTrue(termination.IsBelowCvThreshold(population));


            termination = new ShuffledComplexEvolution <TestHyperCube> .CoefficientOfVariationTerminationCondition(threshold : threshold, maxHours : 0.1);

            var rng       = new BasicRngFactory(0);
            var evaluator = new ObjEvalTestHyperCube(new ParaboloidObjEval <TestHyperCube>(bestParam: 2));
            var engine    = createSce(termination, rng, evaluator);
            var results   = engine.Evolve();

            //Console.WriteLine("Current shuffle: {0}", engine.CurrentShuffle);
            Assert.IsFalse(termination.HasReachedMaxTime());
        }
예제 #2
0
        private static ShuffledComplexEvolution <TestHyperCube> createSce(double cvThreshold, double maxHours, double objCalcPauseSec, TestObjEval <TestHyperCube> innerObjCalc = null, int maxShuffle = 15)
        {
            var termination = new ShuffledComplexEvolution <TestHyperCube> .CoefficientOfVariationTerminationCondition(threshold : cvThreshold, maxHours : maxHours);

            var rng = new BasicRngFactory(0);

            if (innerObjCalc == null)
            {
                innerObjCalc = new ParaboloidObjEval <TestHyperCube>(bestParam: 2);
            }
            var evaluator = new ObjEvalTestHyperCube(innerObjCalc, pauseSeconds: objCalcPauseSec);
            var engine    = createSce(termination, rng, evaluator, maxShuffle: maxShuffle);

            return(engine);
        }
예제 #3
0
        private static ShuffledComplexEvolution <TestHyperCube> createSce(ShuffledComplexEvolution <TestHyperCube> .CoefficientOfVariationTerminationCondition termination, BasicRngFactory rng, ObjEvalTestHyperCube evaluator, int maxShuffle = 15)
        {
            var engine = new ShuffledComplexEvolution <TestHyperCube>(
                evaluator,
                new UniformRandomSamplingFactory <TestHyperCube>(rng.CreateFactory(), new TestHyperCube(2, 0, -10, 10)),
                termination,
                5, 20, 10, 3, 20, maxShuffle,
                rng,
                new DefaultFitnessAssignment());

            return(engine);
        }