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;
FirstOrderIntegrator integ = new AdamsMoultonIntegrator(4, minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
// the 0.15 and 3.0 factors are 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.15 * scalAbsoluteTolerance));
assertTrue(handler.getMaximalValueError() < (3.0 * scalAbsoluteTolerance));
assertEquals(0, handler.getMaximalTimeError(), 1.0e-16);
int calls = pb.getCalls();
assertEquals(integ.getEvaluations(), calls);
assertTrue(calls <= previousCalls);
previousCalls = calls;
}