public void initialize(double initial[] , int numberOfParameters ) { x.reshape(numberOfParameters,1); x_next.reshape(numberOfParameters,1); p.reshape(numberOfParameters,1); gradient.reshape(numberOfParameters,1); // initialize scaling to 1, which is no scaling hessianScaling.reshape(numberOfParameters,1); Arrays.fill(hessianScaling.data,0,numberOfParameters,1); hessian.init(numberOfParameters); System.arraycopy(initial,0,x.data,0,numberOfParameters); sameStateAsCost = true; totalFullSteps = 0; totalSelectSteps = 0; }
@Test public void solve() { DMatrixRMaj M = RandomMatrices_DDRM.symmetricPosDef(10,rand); DMatrixRMaj v = RandomMatrices_DDRM.rectangle(10,1,rand); DMatrixRMaj origv = v.copy(); DMatrixRMaj expected = v.createLike(); CommonOps_DDRM.solve(M,v,expected); DMatrixRMaj found = v.createLike(); alg.init(M.numCols); setHessian(alg,M); assertTrue(alg.initializeSolver()); assertTrue(alg.solve(v,found)); // make sure it didn't modify the input assertTrue(MatrixFeatures_DDRM.isIdentical(origv,origv,UtilEjml.TEST_F64)); // check the solution assertTrue(MatrixFeatures_DDRM.isIdentical(expected,found,UtilEjml.TEST_F64)); // run it again, if nothing was modified it should produce the same solution assertTrue(alg.initializeSolver()); assertTrue(alg.solve(v,found)); assertTrue(MatrixFeatures_DDRM.isIdentical(expected,found,UtilEjml.TEST_F64)); }
public void initialize(double initial[] , int numberOfParameters ) { x.reshape(numberOfParameters,1); x_next.reshape(numberOfParameters,1); p.reshape(numberOfParameters,1); gradient.reshape(numberOfParameters,1); // initialize scaling to 1, which is no scaling hessianScaling.reshape(numberOfParameters,1); Arrays.fill(hessianScaling.data,0,numberOfParameters,1); hessian.init(numberOfParameters); System.arraycopy(initial,0,x.data,0,numberOfParameters); sameStateAsCost = true; totalFullSteps = 0; totalSelectSteps = 0; }
@Test public void initialize() { alg.init(8); HessianBFGS_DDRM a = (HessianBFGS_DDRM)alg; assertTrue(MatrixFeatures_DDRM.isIdentity(a.hessian,UtilEjml.TEST_F64)); assertTrue(MatrixFeatures_DDRM.isIdentity(a.hessianInverse,UtilEjml.TEST_F64)); }