Esempio n. 1
0
        public void IsMetThrowsForMissingCovarianceMatrix()
        {
            var terminationCriterion = new TolUpSigma();
            var data = TolUpSigmaTest.CreateCmaEsData(covariances: null, initialStepSize: 0.2, currentStepSize: 0.2);

            Assert.Throws <ArgumentOutOfRangeException>(() => terminationCriterion.IsMet(data));
        }
Esempio n. 2
0
        public void IsMetReturnsFalseForFactorEqualToMaxConstant()
        {
            double greatestEigenvalue = 42.3;
            double initialStepSize    = 0.2;
            double currentStepSize    = TolUpSigma.MaxFactor * Math.Sqrt(greatestEigenvalue) * initialStepSize;
            var    covariances        = Matrix <double> .Build.DenseOfDiagonalArray(
                new[] { greatestEigenvalue, 0, 0 });

            var terminationCriterion = new TolUpSigma();

            Assert.False(
                terminationCriterion.IsMet(TolUpSigmaTest.CreateCmaEsData(covariances, initialStepSize, currentStepSize)),
                "Termination criterion should not have been met.");
        }
Esempio n. 3
0
        public void IsMetThrowsForMissingConfiguration()
        {
            var covariances = Matrix <double> .Build.DenseOfDiagonalArray(
                new[] { 42.3, 0, 0 });

            var data = new CmaEsElements(
                configuration: null,
                generation: 5,
                distributionMean: Vector <double> .Build.Dense(3),
                stepSize: 0.2,
                covariances: covariances,
                covariancesDecomposition: covariances.Evd(),
                evolutionPath: Vector <double> .Build.Dense(3),
                conjugateEvolutionPath: Vector <double> .Build.Dense(3));

            var terminationCriterion = new TolUpSigma();

            Assert.Throws <ArgumentOutOfRangeException>(() => terminationCriterion.IsMet(data));
        }
Esempio n. 4
0
        public void IsMetThrowsForMissingCmaEsData()
        {
            var terminationCriterion = new TolUpSigma();

            Assert.Throws <ArgumentNullException>(() => terminationCriterion.IsMet(data: null));
        }