Exemplo n.º 1
0
		public NewtonRaphsonLineSearch(CostFunction costfunction, EndCriteria endcriteria,
			int maxiteration, double tolerance)
		{
			this.costFunction_ = costfunction;
			this.endCriteria_ = endcriteria;
			this.maxIteration = maxiteration;
			this.tolerance = tolerance;
		}
Exemplo n.º 2
0
 public SecantLineSearch(CostFunction costfunction, EndCriteria endcriteria, double sigma_0, 
   int maxiteration, double tolerance) 
 {
   this.costFunction_=costfunction;
   this.endCriteria_=endcriteria;
   this.sigma_0 = sigma_0;
   this.maxIteration=maxiteration;
   this.tolerance=tolerance;
 }
Exemplo n.º 3
0
		public void TestRosenbrock()
		{
			Rosenbrock cf = new Rosenbrock();
			EndCriteria ec = new EndCriteria();
			ConjugateGradient optim = new ConjugateGradient(cf, ec);
			//  new SecantLineSearch(cf,ec));

			DoubleVector x0 = new DoubleVector(new double[5] { 1.3, 0.7, 0.8, 1.9, 1.2 });

			optim.Minimize(x0);

			Assert.AreEqual(optim.SolutionValue, 0.0, 0.1);
			Assert.AreEqual(optim.SolutionVector[0], 1.0, 0.1);
			Assert.AreEqual(optim.SolutionVector[1], 1.0, 0.1);
			Assert.AreEqual(optim.SolutionVector[2], 1.0, 0.1);
			Assert.AreEqual(optim.SolutionVector[3], 1.0, 0.2);
			Assert.AreEqual(optim.SolutionVector[4], 1.0, 0.4);
		}
Exemplo n.º 4
0
 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);
 }   
Exemplo n.º 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);
 }   
Exemplo n.º 6
0
 public SecantLineSearch(CostFunction costfunction, EndCriteria endcriteria) 
   : this(costfunction, endcriteria, 1) {}
Exemplo n.º 7
0
		public NelderMead(ICostFunction costfunction, EndCriteria endcriteria)
		{
			this.costFunction_ = costfunction;
			this.endCriteria_ = endcriteria;
		}
Exemplo n.º 8
0
 ///<param name="lsm">User specified line search method, defaults to Secant line search method</param>
 public ConjugateGradient(CostFunction costfunction, EndCriteria endcriteria, LineSearchMethod lsm) 
 {
   this.costFunction_=costfunction;
   this.endCriteria_=endcriteria;
   this.lineSearchMethod_=lsm;
 }
Exemplo n.º 9
0
 ///<param name="endcriteria">User specified ending criteria.</param>
 public ConjugateGradient(CostFunction costfunction, EndCriteria endcriteria)
   : this(costfunction, endcriteria, new SecantLineSearch(costfunction, endcriteria)) {}
 public MoreThuenteLineSearch(CostFunction costfunction, EndCriteria endcriteria)
 {
   this.costFunction_=costfunction;
   this.endCriteria_=endcriteria;
 }
Exemplo n.º 11
0
 public SecantLineSearch(CostFunction costfunction, EndCriteria endcriteria, double sigma_0)
     : this(costfunction, endcriteria, sigma_0, 50, 1e-8)
 {
 }
Exemplo n.º 12
0
 ///<param name="endcriteria">User specified ending criteria.</param>
 public ConjugateGradient(CostFunction costfunction, EndCriteria endcriteria)
     : this(costfunction, endcriteria, new SecantLineSearch(costfunction, endcriteria))
 {
 }
Exemplo n.º 13
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);
 }   
Exemplo n.º 14
0
 ///<param name="lsm">User specified line search method, defaults to Secant line search method</param>
 public ConjugateGradient(CostFunction costfunction, EndCriteria endcriteria, LineSearchMethod lsm)
 {
     this.costFunction_     = costfunction;
     this.endCriteria_      = endcriteria;
     this.lineSearchMethod_ = lsm;
 }
Exemplo n.º 15
0
		public NewtonRaphsonLineSearch(CostFunction costfunction, EndCriteria endcriteria)
			: this(costfunction, new EndCriteria(), 50, 1e-8) { }
Exemplo n.º 16
0
 public NewtonRaphsonLineSearch(CostFunction costfunction, EndCriteria endcriteria)
     : this(costfunction, new EndCriteria(), 50, 1e-8)
 {
 }
Exemplo n.º 17
0
 public NelderMead(ICostFunction costfunction, EndCriteria endcriteria)
 {
     costFunction_ = costfunction;
     endCriteria_  = endcriteria;
 }
Exemplo n.º 18
0
 public SecantLineSearch(CostFunction costfunction, EndCriteria endcriteria, double sigma_0)
   : this(costfunction, endcriteria, sigma_0, 50, 1e-8) {}
Exemplo n.º 19
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);
 } 
Exemplo n.º 20
0
 public SecantLineSearch(CostFunction costfunction, EndCriteria endcriteria)
     : this(costfunction, endcriteria, 1)
 {
 }