Esempio 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;
		}
 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;
 }
Esempio 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);
		}
Esempio 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);
 }   
Esempio 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);
 }   
 public SecantLineSearch(CostFunction costfunction, EndCriteria endcriteria) 
   : this(costfunction, endcriteria, 1) {}
Esempio n. 7
0
		public NelderMead(ICostFunction costfunction, EndCriteria endcriteria)
		{
			this.costFunction_ = costfunction;
			this.endCriteria_ = endcriteria;
		}
 ///<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;
 }
 ///<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;
 }
Esempio n. 11
0
 public SecantLineSearch(CostFunction costfunction, EndCriteria endcriteria, double sigma_0)
     : this(costfunction, endcriteria, sigma_0, 50, 1e-8)
 {
 }
Esempio n. 12
0
 ///<param name="endcriteria">User specified ending criteria.</param>
 public ConjugateGradient(CostFunction costfunction, EndCriteria endcriteria)
     : this(costfunction, endcriteria, new SecantLineSearch(costfunction, endcriteria))
 {
 }
Esempio 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);
 }   
Esempio 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;
 }
Esempio n. 15
0
		public NewtonRaphsonLineSearch(CostFunction costfunction, EndCriteria endcriteria)
			: this(costfunction, new EndCriteria(), 50, 1e-8) { }
Esempio n. 16
0
 public NewtonRaphsonLineSearch(CostFunction costfunction, EndCriteria endcriteria)
     : this(costfunction, new EndCriteria(), 50, 1e-8)
 {
 }
Esempio n. 17
0
 public NelderMead(ICostFunction costfunction, EndCriteria endcriteria)
 {
     costFunction_ = costfunction;
     endCriteria_  = endcriteria;
 }
Esempio n. 18
0
 public SecantLineSearch(CostFunction costfunction, EndCriteria endcriteria, double sigma_0)
   : this(costfunction, endcriteria, sigma_0, 50, 1e-8) {}
Esempio 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);
 } 
Esempio n. 20
0
 public SecantLineSearch(CostFunction costfunction, EndCriteria endcriteria)
     : this(costfunction, endcriteria, 1)
 {
 }