public void testIncreasingTolerance()
throws DerivativeException, IntegratorException {
int previousCalls = Integer.MAX_VALUE;
for (int i = -12; i < -2; ++i) {
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
double scalAbsoluteTolerance = Math.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
EmbeddedRungeKuttaIntegrator integ =
new DormandPrince54Integrator(minStep, maxStep,
scalAbsoluteTolerance, scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setSafety(0.8);
integ.setMaxGrowth(5.0);
integ.setMinReduction(0.3);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
assertEquals(0.8, integ.getSafety(), 1.0e-12);
assertEquals(5.0, integ.getMaxGrowth(), 1.0e-12);
assertEquals(0.3, integ.getMinReduction(), 1.0e-12);
// the 0.7 factor is only valid for this test
// and has been obtained from trial and error
// there is no general relation between local and global errors
assertTrue(handler.getMaximalValueError() < (0.7 * scalAbsoluteTolerance));
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
int calls = pb.getCalls();
assertEquals(integ.getEvaluations(), calls);
assertTrue(calls <= previousCalls);
previousCalls = calls;
}