/** * Prediction is low accuracy but the function decreased in value */ @Test public void considerUpdate() { // Everything goes well. considerUpdate(1,1.1,0.1,0.1, false,true); // Score improved by a very small amount relative to distance traveled considerUpdate(1,1.1,0.1,1e10, false,true); // poor prediction causes noise considerUpdate(1,1.1,0.001,0.1, false,true); // the model predicted a much larger gain than there was considerUpdate(1,1.1,2.1,0.1, false,true); // cost increased considerUpdate(1.0001,1,0.1,0.1, false,false); }
@Test public void initialize() { MockTrustRegionBase_F64 alg = createFixedCost(1,0.5); double x[] = new double[]{1,2}; alg.initialize(x,2,0); assertEquals(1,alg.fx, UtilEjml.TEST_F64); assertEquals(alg.regionRadius,alg.config.regionInitial, UtilEjml.TEST_F64); }
/** * sees if it's checking the region radius for problems */ @Test public void checkConvergenceFTest_radius() { MockTrustRegionBase_F64 alg = createFixedCost(1,0.5); alg.regionRadius = 0; try { alg.checkConvergenceFTest(-1,-1); fail("Should have thrown an exception"); } catch( OptimizationException ignore){} alg.regionRadius = Double.NaN; try { alg.checkConvergenceFTest(-1,-1); fail("Should have thrown an exception"); } catch( OptimizationException ignore){} }
@Test public void checkConvergenceFTest() { MockTrustRegionBase_F64 alg = createFixedCost(1,0.5); alg.regionRadius = 1; alg.config.ftol = 1e-4; assertTrue(alg.checkConvergenceFTest(2,2)); assertTrue(alg.checkConvergenceFTest(2,2*(1+1e-5))); assertFalse(alg.checkConvergenceFTest(2,2*(1+9e-3))); }