package edu.jhu.hlt.optimize;

public class NaturalNewton extends    Optimizer<DifferentiableFunction>
                           implements Maximizer<DifferentiableFunction>, 
                                      Minimizer<DifferentiableFunction> {

	public NaturalNewton(DifferentiableFunction f, double lambda) {
		super(f);
	}
	
	public NaturalNewton(DifferentiableFunction f) {
		super(f);
		// TODO Auto-generated constructor stub
	}

	@Override
	public boolean minimize(DifferentiableFunction function, double[] initial) {
		this.f = function;
		f.setPoint(initial);
		return this.minimize();
	}

	@Override
	public boolean minimize() {
		// TODO
		return true;
	}

	@Override
	public boolean maximize(DifferentiableFunction function, double[] point) {
		this.f = function;
		f.setPoint(point);
		return this.maximize();
	}

	@Override
	public boolean maximize() {
		// TODO
		return true;
	}
	

}

@@ -257,75 +257,535 @@
 lic 
-NaturalNewton(DifferentiableFunction f, double lambda) %7B%0A%09%09super(f)
+static class NaturalNewtonParam %7B%0A%09%09int skip  = 8;       // number of gradient updates between Hessian updates%0A%09%09int skipC = 8;       // number of Hessian updates between covariance updates%0A%09%09double gamma;        // discount factor for the moving covariance%0A%09%09int T = 100;         // total number of epochs%0A%09%09int t0 = 100;        // weight decay%0A%09%09double lambda = 1.0; // weight decay%0A%09%7D%0A%09%0A%09NaturalNewtonParam param;%0A%09%0A%09public NaturalNewton(DifferentiableFunction f, NaturalNewtonParam param) %7B%0A%09%09super(f);%0A%09%09this.param = param
 ;%0A%09%7D
@@ -853,50 +853,8 @@
 f);%0A
-%09%09// TODO Auto-generated constructor stub%0A
 %09%7D%0A%0A
@@ -1050,39 +1050,757 @@
  minimize() %7B%0A%09%09
-// TODO
+%0A%09%09int t = 0;%0A%09%09int count = param.skip;%0A%09%09int countC = param.skipC;%0A%09%09double gamma_0 = 0d;%0A%09%09double delta_0 = 0d;%0A%09%09double %5B%5D theta = new double %5Bf.getNumDimensions()%5D;%0A%09%09double %5B%5D g     = new double %5Bf.getNumDimensions()%5D;%0A%09%09double %5B%5D H     = new double %5Bf.getNumDimensions()%5D;%0A%09%09double %5B%5D D     = new double %5Bf.getNumDimensions()%5D;%0A%09%09double %5B%5D mu    = new double %5Bf.getNumDimensions()%5D;%0A%09%09double %5B%5D C     = new double %5Bf.getNumDimensions()%5D;%0A%09%09while(t!=param.T) %7B%0A%09%09%09%0A%09%09%09f.getGradient(g);%0A%09%09%09theta = f.getPoint();%0A%09%09%09for(int k=0; k%3Cf.getNumDimensions(); k++) %7B%0A%09%09%09%09theta%5Bk%5D = theta%5Bk%5D - 1d/(double)(t+param.t0)*D%5Bk%5D*g%5Bk%5D;%0A%09%09%09%7D%0A%09%09%09f.setPoint(theta);%0A%09%09%09%0A%09%09%09if(count==0) %7B%0A%09%09%09%09count = param.skip;%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09SGDQN%0A%09%09%09%0A%09%09%7D%0A%09%09
 %0A%09%09return true;%0A

Work in progress