Beispiel #1
0
        public void TestHessianEpsilon()
        {
            double      functionepsilon = 1e-8;
            EndCriteria ec = new EndCriteria(100, functionepsilon, 100, 100);

            Assert.AreEqual(ec.minHessianEpsilon, functionepsilon);

            Assert.IsTrue(!ec.CheckHessianEpsilon(functionepsilon * 2));
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);

            Assert.IsTrue(ec.CheckHessianEpsilon(functionepsilon / 2));
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.HessianEpsilon);

            ec.Reset();
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);
        }
Beispiel #2
0
        public void TestGradientEpsilon()
        {
            double functionepsilon = 1e-8;
            var    ec = new EndCriteria(100, functionepsilon, 100, 100);

            Assert.AreEqual(ec.minGradientEpsilon, functionepsilon);

            Assert.IsTrue(!ec.CheckGradientEpsilon(functionepsilon * 2));
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);

            Assert.IsTrue(ec.CheckGradientEpsilon(functionepsilon / 2));
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.GradientEpsilon);

            ec.Reset();
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);
        }
Beispiel #3
0
        public void TestStationaryHessianCounter()
        {
            int         maxstationarypoint = 1;
            EndCriteria ec = new EndCriteria(100, 1e-8, 100, maxstationarypoint);

            Assert.AreEqual(ec.maxStationaryHessianIterations, maxstationarypoint);

            Assert.IsTrue(!ec.CheckStationaryHessian(1.0, 1.0));
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);

            Assert.IsTrue(ec.CheckStationaryHessian(1.0, 1.0));
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.StationaryHessian);

            ec.Reset();
            Assert.AreEqual(ec.stationaryHessianIterationsCounter, 0);
            Assert.IsTrue(!ec.CheckStationaryHessian(1.0, 1.0));
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);
        }
Beispiel #4
0
        public void TestGradientEvaluationCounter()
        {
            int         maxeval = 2;
            EndCriteria ec      = new EndCriteria(100, 1e-8, maxeval, 100);

            Assert.AreEqual(ec.maxGradientEvaluation, maxeval);

            ec.gradientEvaluationCounter++;

            Assert.IsTrue(!ec.CheckGradientEvaluations());
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);

            ec.gradientEvaluationCounter++;

            Assert.IsTrue(ec.CheckGradientEvaluations());
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.MaximumGradientEvaluation);

            ec.Reset();
            Assert.AreEqual(ec.gradientEvaluationCounter, 0);
            Assert.IsTrue(!ec.CheckGradientEvaluations());
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);
        }
Beispiel #5
0
        public void TestIterationCounter()
        {
            int         maxiter = 2;
            EndCriteria ec      = new EndCriteria(maxiter, 1e-8, 100, 100);

            Assert.AreEqual(ec.maxIteration, maxiter);

            ec.iterationCounter++;

            Assert.IsTrue(!ec.CheckIterations());
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);

            ec.iterationCounter++;

            Assert.IsTrue(ec.CheckIterations());
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.MaximumIteration);

            ec.Reset();
            Assert.AreEqual(ec.iterationCounter, 0);
            Assert.IsTrue(!ec.CheckIterations());
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);
        }
Beispiel #6
0
        public void TestFunctionEvaluationCounter()
        {
            int maxeval = 2;
            var ec      = new EndCriteria(100, 1e-8, maxeval, 100);

            Assert.AreEqual(ec.maxFunctionEvaluation, maxeval);

            ec.functionEvaluationCounter++;

            Assert.IsTrue(!ec.CheckFunctionEvaluations());
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);

            ec.functionEvaluationCounter++;

            Assert.IsTrue(ec.CheckFunctionEvaluations());
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.MaximumFunctionEvaluation);

            ec.Reset();
            Assert.AreEqual(ec.functionEvaluationCounter, 0);
            Assert.IsTrue(!ec.CheckFunctionEvaluations());
            Assert.AreEqual(ec.Criteria, EndCriteria.CriteriaType.None);
        }