/** * Creates a sparse Schur Complement trust region optimization using dogleg steps. * * @see UnconLeastSqTrustRegionSchur_F64 * * @param config Trust region configuration * @return The new optimization routine */ public static UnconstrainedLeastSquaresSchur<DMatrixSparseCSC> doglegSchur( @Nullable ConfigTrustRegion config ) { if( config == null ) config = new ConfigTrustRegion(); HessianSchurComplement_DSCC hessian = new HessianSchurComplement_DSCC(); TrustRegionUpdateDogleg_F64<DMatrixSparseCSC> update = new TrustRegionUpdateDogleg_F64<>(); UnconLeastSqTrustRegionSchur_F64<DMatrixSparseCSC> alg = new UnconLeastSqTrustRegionSchur_F64<>(update,hessian); alg.configure(config); return alg; }
/** * Creates a sparse Schur Complement trust region optimization using dogleg steps. * * @see UnconLeastSqTrustRegionSchur_F64 * * @param config Trust region configuration * @return The new optimization routine */ public static UnconstrainedLeastSquaresSchur<DMatrixSparseCSC> doglegSchur( @Nullable ConfigTrustRegion config ) { if( config == null ) config = new ConfigTrustRegion(); HessianSchurComplement_DSCC hessian = new HessianSchurComplement_DSCC(); TrustRegionUpdateDogleg_F64<DMatrixSparseCSC> update = new TrustRegionUpdateDogleg_F64<>(); UnconLeastSqTrustRegionSchur_F64<DMatrixSparseCSC> alg = new UnconLeastSqTrustRegionSchur_F64<>(update,hessian); alg.configure(config); return alg; }
@Override protected UnconstrainedLeastSquaresSchur<DMatrixSparseCSC> createSearch(double minimumValue) { ConfigTrustRegion config = new ConfigTrustRegion(); // config.regionInitial = 1; config.hessianScaling = true; TrustRegionUpdateDogleg_F64<DMatrixSparseCSC> dogleg = new TrustRegionUpdateDogleg_F64<>(); HessianSchurComplement_DSCC hessian = new HessianSchurComplement_DSCC(); UnconLeastSqTrustRegionSchur_F64<DMatrixSparseCSC> tr = new UnconLeastSqTrustRegionSchur_F64<>(dogleg,hessian); tr.configure(config); // tr.setVerbose(true); return tr; } }
@Test public void cost() { double expected = 0.5*VectorVectorMult_DDRM.innerProd(residuals,residuals); TrustRegionUpdateDogleg_F64<DMatrixSparseCSC> dogleg = new TrustRegionUpdateDogleg_F64<>(); HessianSchurComplement_DSCC hessian = new HessianSchurComplement_DSCC(); UnconLeastSqTrustRegionSchur_F64<DMatrixSparseCSC> alg = new UnconLeastSqTrustRegionSchur_F64<>(dogleg,hessian); alg.setFunction(new MockFunction(),new MockJacobian()); alg.initialize(new double[N],1e-6,1e-8); double found = alg.cost(new DMatrixRMaj(N,1)); assertEquals(expected,found, UtilEjml.TEST_F64); }
@Test public void functionGradientHessian() { TrustRegionUpdateDogleg_F64<DMatrixSparseCSC> dogleg = new TrustRegionUpdateDogleg_F64<>(); HessianSchurComplement_DSCC hessian = new HessianSchurComplement_DSCC(); UnconLeastSqTrustRegionSchur_F64<DMatrixSparseCSC> alg = new UnconLeastSqTrustRegionSchur_F64<>(dogleg,hessian); alg.setFunction(new MockFunction(),new MockJacobian()); alg.initialize(new double[N],1e-6,1e-8); DMatrixRMaj x = new DMatrixRMaj(1,1); DMatrixRMaj g = new DMatrixRMaj(N,1); alg.functionGradientHessian(x,false,g,hessian); // Only the gradient is computed and returned. The hessian is saved internally DMatrixRMaj exp_g = new DMatrixRMaj(N,1); CommonOps_DSCC.multTransA(J,residuals,exp_g); assertTrue(MatrixFeatures_DDRM.isIdentical(exp_g,g,UtilEjml.TEST_F64)); }