public void TestFunctionEvaluationCounter()
 {
   int maxeval = 2;
   EndCriteria 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);
 }   
 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);
 }   
 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);
 } 
 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);
 }