}
@Test
public void testEventsNoConvergence() throws Exception {
final TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
double scalAbsoluteTolerance = 1.0e-8;
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderIntegrator integ =
new HighamHall54Integrator(minStep, maxStep,
scalAbsoluteTolerance, scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.addStepHandler(handler);
integ.addEventHandler(new EventHandler() {
public void init(double t0, double[] y0, double t) {
}
public Action eventOccurred(double t, double[] y, boolean increasing) {
return Action.CONTINUE;
}
public double g(double t, double[] y) {
double middle = (pb.getInitialTime() + pb.getFinalTime()) / 2;
double offset = t - middle;
return (offset > 0) ? (offset + 0.5) : (offset - 0.5);
}
public void resetState(double t, double[] y) {
}
}, Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 3);
try {
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
Assert.fail("an exception should have been thrown");
} catch (TooManyEvaluationsException tmee) {
// Expected.
}