The ODE integrators now support several step handlers at once, instead of just one.

This is more consistent with event handlers management.
The setStepHandler method has therefore been replaced by addStephandler, the
getStepHandler method has been replaced by getStepHandlers which returns a Collection
and a clearStepHandlers method has been added.


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@674814 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2008-07-08 13:26:59 +00:00
parent c52ab55875
commit 08dae2254b
27 changed files with 202 additions and 131 deletions

View File

@ -17,11 +17,12 @@
package org.apache.commons.math.ode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.apache.commons.math.ode.events.CombinedEventsManager;
import org.apache.commons.math.ode.events.EventHandler;
import org.apache.commons.math.ode.sampling.DummyStepHandler;
import org.apache.commons.math.ode.sampling.StepHandler;
/**
@ -35,7 +36,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
private final String name;
/** Step handler. */
protected StepHandler handler;
protected Collection<StepHandler> stepHandlers;
/** Current step start time. */
protected double stepStart;
@ -51,7 +52,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
*/
public AbstractIntegrator(final String name) {
this.name = name;
handler = DummyStepHandler.getInstance();
stepHandlers = new ArrayList<StepHandler>();
stepStart = Double.NaN;
stepSize = Double.NaN;
eventsHandlersManager = new CombinedEventsManager();
@ -63,13 +64,18 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
}
/** {@inheritDoc} */
public void setStepHandler(final StepHandler handler) {
this.handler = handler;
public void addStepHandler(final StepHandler handler) {
stepHandlers.add(handler);
}
/** {@inheritDoc} */
public StepHandler getStepHandler() {
return handler;
public Collection<StepHandler> getStepHandlers() {
return Collections.unmodifiableCollection(stepHandlers);
}
/** {@inheritDoc} */
public void clearStepHandlers() {
stepHandlers.clear();
}
/** {@inheritDoc} */
@ -82,15 +88,27 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
}
/** {@inheritDoc} */
public Collection<EventHandler> getEventsHandlers() {
public Collection<EventHandler> getEventHandlers() {
return eventsHandlersManager.getEventsHandlers();
}
/** {@inheritDoc} */
public void clearEventsHandlers() {
public void clearEventHandlers() {
eventsHandlersManager.clearEventsHandlers();
}
/** Check if one of the step handlers requires dense output.
* @return true if one of the step handlers requires dense output
*/
protected boolean requiresDenseOutput() {
for (StepHandler handler : stepHandlers) {
if (handler.requiresDenseOutput()) {
return true;
}
}
return false;
}
/** {@inheritDoc} */
public double getCurrentStepStart() {
return stepStart;

View File

@ -45,17 +45,30 @@ public interface FirstOrderIntegrator extends Serializable {
*/
public String getName();
/** Set the step handler for this integrator.
* The handler will be called by the integrator for each accepted
* step.
/** Add a step handler to this integrator.
* <p>The handler will be called by the integrator for each accepted
* step.</p>
* @param handler handler for the accepted steps
* @see #getStepHandlers()
* @see #clearStepHandlers()
* @since 2.0
*/
public void setStepHandler (StepHandler handler);
public void addStepHandler (StepHandler handler);
/** Get the step handler for this integrator.
* @return the step handler for this integrator
/** Get all the step handlers that have been added to the integrator.
* @return an unmodifiable collection of the added events handlers
* @see #addStepHandler(StepHandler)
* @see #clearStepHandlers()
* @since 2.0
*/
public StepHandler getStepHandler();
public Collection<StepHandler> getStepHandlers();
/** Remove all the step handlers that have been added to the integrator.
* @see #addStepHandler(StepHandler)
* @see #getStepHandlers()
* @since 2.0
*/
public void clearStepHandlers();
/** Add an event handler to the integrator.
* @param handler event handler
@ -65,24 +78,24 @@ public interface FirstOrderIntegrator extends Serializable {
* @param convergence convergence threshold in the event time search
* @param maxIterationCount upper limit of the iteration count in
* the event time search
* @see #getEventsHandlers()
* @see #clearEventsHandlers()
* @see #getEventHandlers()
* @see #clearEventHandlers()
*/
public void addEventHandler(EventHandler handler, double maxCheckInterval,
double convergence, int maxIterationCount);
/** Get all the events handlers that have been added to the integrator.
/** Get all the event handlers that have been added to the integrator.
* @return an unmodifiable collection of the added events handlers
* @see #addEventHandler(EventHandler, double, double, int)
* @see #clearEventsHandlers()
* @see #clearEventHandlers()
*/
public Collection<EventHandler> getEventsHandlers();
public Collection<EventHandler> getEventHandlers();
/** Remove all the events handlers that have been added to the integrator.
/** Remove all the event handlers that have been added to the integrator.
* @see #addEventHandler(EventHandler, double, double, int)
* @see #getEventsHandlers()
* @see #getEventHandlers()
*/
public void clearEventsHandlers();
public void clearEventHandlers();
/** Integrate the differential equations up to the given time.
* <p>This method solves an Initial Value Problem (IVP).</p>

View File

@ -22,6 +22,7 @@ import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
import org.apache.commons.math.ode.IntegratorException;
import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
import org.apache.commons.math.ode.sampling.StepHandler;
/**
* This class implements the common part of all embedded Runge-Kutta
@ -180,7 +181,7 @@ public abstract class EmbeddedRungeKuttaIntegrator
// set up an interpolator sharing the integrator arrays
AbstractStepInterpolator interpolator;
if (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty())) {
if (requiresDenseOutput() || (! eventsHandlersManager.isEmpty())) {
final RungeKuttaStepInterpolator rki = (RungeKuttaStepInterpolator) prototype.copy();
rki.reinitialize(equations, yTmp, yDotK, forward);
interpolator = rki;
@ -193,7 +194,9 @@ public abstract class EmbeddedRungeKuttaIntegrator
double hNew = 0;
boolean firstTime = true;
boolean lastStep;
handler.reset();
for (StepHandler handler : stepHandlers) {
handler.reset();
}
do {
interpolator.shift();
@ -289,7 +292,9 @@ public abstract class EmbeddedRungeKuttaIntegrator
// provide the step data to the step handler
interpolator.storeTime(nextStep);
handler.handleStep(interpolator, lastStep);
for (StepHandler handler : stepHandlers) {
handler.handleStep(interpolator, lastStep);
}
stepStart = nextStep;
if (fsal) {

View File

@ -117,7 +117,7 @@ public class GraggBulirschStoerIntegrator
final double scalRelativeTolerance) {
super(METHOD_NAME, minStep, maxStep,
scalAbsoluteTolerance, scalRelativeTolerance);
denseOutput = (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty()));
denseOutput = requiresDenseOutput() || (! eventsHandlersManager.isEmpty());
setStabilityCheck(true, -1, -1, -1);
setStepsizeControl(-1, -1, -1, -1);
setOrderControl(-1, -1, -1);
@ -140,7 +140,7 @@ public class GraggBulirschStoerIntegrator
final double[] vecRelativeTolerance) {
super(METHOD_NAME, minStep, maxStep,
vecAbsoluteTolerance, vecRelativeTolerance);
denseOutput = (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty()));
denseOutput = requiresDenseOutput() || (! eventsHandlersManager.isEmpty());
setStabilityCheck(true, -1, -1, -1);
setStepsizeControl(-1, -1, -1, -1);
setOrderControl(-1, -1, -1);
@ -281,15 +281,11 @@ public class GraggBulirschStoerIntegrator
}
/** Set the step handler for this integrator.
* The handler will be called by the integrator for each accepted
* step.
* @param handler handler for the accepted steps
*/
public void setStepHandler (final StepHandler handler) {
/** {@inheritDoc} */
public void addStepHandler (final StepHandler handler) {
super.setStepHandler(handler);
denseOutput = (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty()));
super.addStepHandler(handler);
denseOutput = requiresDenseOutput() || (! eventsHandlersManager.isEmpty());
// reinitialize the arrays
initializeArrays();
@ -302,7 +298,7 @@ public class GraggBulirschStoerIntegrator
final double convergence,
final int maxIterationCount) {
super.addEventHandler(function, maxCheckInterval, convergence, maxIterationCount);
denseOutput = (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty()));
denseOutput = requiresDenseOutput() || (! eventsHandlersManager.isEmpty());
// reinitialize the arrays
initializeArrays();
@ -585,7 +581,9 @@ public class GraggBulirschStoerIntegrator
boolean newStep = true;
boolean lastStep = false;
boolean firstStepAlreadyComputed = false;
handler.reset();
for (StepHandler handler : stepHandlers) {
handler.reset();
}
costPerTimeUnit[0] = 0;
while (! lastStep) {
@ -858,7 +856,9 @@ public class GraggBulirschStoerIntegrator
// provide the step data to the step handler
interpolator.storeTime(nextStep);
handler.handleStep(interpolator, lastStep);
for (StepHandler handler : stepHandlers) {
handler.handleStep(interpolator, lastStep);
}
stepStart = nextStep;
if (eventsHandlersManager.reset(stepStart, y) && ! lastStep) {

View File

@ -24,6 +24,7 @@ import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
import org.apache.commons.math.ode.IntegratorException;
import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
import org.apache.commons.math.ode.sampling.StepHandler;
/**
* This class implements the common part of all fixed step Runge-Kutta
@ -96,7 +97,7 @@ public abstract class RungeKuttaIntegrator extends AbstractIntegrator {
// set up an interpolator sharing the integrator arrays
AbstractStepInterpolator interpolator;
if (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty())) {
if (requiresDenseOutput() || (! eventsHandlersManager.isEmpty())) {
final RungeKuttaStepInterpolator rki = (RungeKuttaStepInterpolator) prototype.copy();
rki.reinitialize(equations, yTmp, yDotK, forward);
interpolator = rki;
@ -110,7 +111,9 @@ public abstract class RungeKuttaIntegrator extends AbstractIntegrator {
boolean lastStep = false;
stepStart = t0;
stepSize = (t - t0) / nbStep;
handler.reset();
for (StepHandler handler : stepHandlers) {
handler.reset();
}
for (long i = 0; ! lastStep; ++i) {
interpolator.shift();
@ -168,7 +171,9 @@ public abstract class RungeKuttaIntegrator extends AbstractIntegrator {
// provide the step data to the step handler
interpolator.storeTime(nextStep);
handler.handleStep(interpolator, lastStep);
for (StepHandler handler : stepHandlers) {
handler.handleStep(interpolator, lastStep);
}
stepStart = nextStep;
if (eventsHandlersManager.reset(stepStart, y) && ! lastStep) {

View File

@ -39,6 +39,13 @@ The <action> type attribute can be add,update,fix,remove.
</properties>
<body>
<release version="2.0" date="TBD" description="TBD">
<action dev="luc" type="update">
The ODE integrators now support several step handlers at once, instead of just one.
This is more consistent with event handlers management.
The setStepHandler method has therefore been replaced by addStephandler, the
getStepHandler method has been replaced by getStepHandlers which returns a Collection
and a clearStepHandlers method has been added.
</action>
<action dev="luc" type="add">
All step interpolators for ODE integrators now provide interpolation for
both the state and its time derivatives. The interpolated derivatives are

View File

@ -41,11 +41,11 @@ public class ContinuousOutputModelTest
public void testBoundaries()
throws DerivativeException, IntegratorException {
integ.setStepHandler(new ContinuousOutputModel());
integ.addStepHandler(new ContinuousOutputModel());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
ContinuousOutputModel cm = (ContinuousOutputModel) integ.getStepHandler();
ContinuousOutputModel cm = (ContinuousOutputModel) integ.getStepHandlers().iterator().next();
cm.setInterpolatedTime(2.0 * pb.getInitialTime() - pb.getFinalTime());
cm.setInterpolatedTime(2.0 * pb.getFinalTime() - pb.getInitialTime());
cm.setInterpolatedTime(0.5 * (pb.getFinalTime() + pb.getInitialTime()));
@ -55,7 +55,7 @@ public class ContinuousOutputModelTest
throws DerivativeException, IntegratorException {
ContinuousOutputModel cm = new ContinuousOutputModel();
integ.setStepHandler(cm);
integ.addStepHandler(cm);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -101,7 +101,7 @@ public class ContinuousOutputModelTest
ContinuousOutputModel cm1 = new ContinuousOutputModel();
FirstOrderIntegrator integ1 =
new DormandPrince853Integrator(0, 1.0, 1.0e-8, 1.0e-8);
integ1.setStepHandler(cm1);
integ1.addStepHandler(cm1);
integ1.integrate(problem, Math.PI, new double[] { -1.0, 0.0 },
0, new double[2]);
@ -109,7 +109,7 @@ public class ContinuousOutputModelTest
ContinuousOutputModel cm2 = new ContinuousOutputModel();
FirstOrderIntegrator integ2 =
new DormandPrince853Integrator(0, 0.1, 1.0e-12, 1.0e-12);
integ2.setStepHandler(cm2);
integ2.addStepHandler(cm2);
integ2.integrate(problem, 2.0 * Math.PI, new double[] { 1.0, 0.0 },
Math.PI, new double[2]);

View File

@ -81,13 +81,13 @@ public class ClassicalRungeKuttaIntegratorTest
FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
EventHandler[] functions = pb.getEventsHandlers();
for (int l = 0; l < functions.length; ++l) {
integ.addEventHandler(functions[l],
Double.POSITIVE_INFINITY, 1.0e-6 * step, 1000);
}
assertEquals(functions.length, integ.getEventsHandlers().size());
assertEquals(functions.length, integ.getEventHandlers().size());
double stopTime = integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
if (functions.length == 0) {
@ -100,8 +100,8 @@ public class ClassicalRungeKuttaIntegratorTest
}
previousError = error;
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
integ.clearEventsHandlers();
assertEquals(0, integ.getEventsHandlers().size());
integ.clearEventHandlers();
assertEquals(0, integ.getEventHandlers().size());
}
}
@ -116,7 +116,7 @@ public class ClassicalRungeKuttaIntegratorTest
FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -134,7 +134,7 @@ public class ClassicalRungeKuttaIntegratorTest
FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -151,7 +151,7 @@ public class ClassicalRungeKuttaIntegratorTest
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
integ.setStepHandler(new KeplerHandler(pb));
integ.addStepHandler(new KeplerHandler(pb));
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);

View File

@ -30,6 +30,7 @@ import junit.framework.TestSuite;
import org.apache.commons.math.ode.ContinuousOutputModel;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.IntegratorException;
import org.apache.commons.math.ode.sampling.StepHandler;
public class ClassicalRungeKuttaStepInterpolatorTest
extends StepInterpolatorAbstractTest {
@ -53,14 +54,16 @@ public class ClassicalRungeKuttaStepInterpolatorTest
TestProblem3 pb = new TestProblem3(0.9);
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
ClassicalRungeKuttaIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
integ.setStepHandler(new ContinuousOutputModel());
integ.addStepHandler(new ContinuousOutputModel());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(integ.getStepHandler());
for (StepHandler handler : integ.getStepHandlers()) {
oos.writeObject(handler);
}
assertTrue(bos.size () > 700000);
assertTrue(bos.size () < 701000);

View File

@ -64,7 +64,7 @@ public class DormandPrince54IntegratorTest
vecAbsoluteTolerance,
vecRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -91,7 +91,7 @@ public class DormandPrince54IntegratorTest
scalRelativeTolerance);
DP54SmallLastHandler handler = new DP54SmallLastHandler(minStep);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.setInitialStepSize(1.7);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
@ -152,7 +152,7 @@ public class DormandPrince54IntegratorTest
integ.setSafety(0.8);
integ.setMaxGrowth(5.0);
integ.setMinReduction(0.3);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -187,13 +187,13 @@ public class DormandPrince54IntegratorTest
scalAbsoluteTolerance,
scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
EventHandler[] functions = pb.getEventsHandlers();
for (int l = 0; l < functions.length; ++l) {
integ.addEventHandler(functions[l],
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
}
assertEquals(functions.length, integ.getEventsHandlers().size());
assertEquals(functions.length, integ.getEventHandlers().size());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -201,8 +201,8 @@ public class DormandPrince54IntegratorTest
assertTrue(handler.getMaximalValueError() < 5.0e-6);
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
integ.clearEventsHandlers();
assertEquals(0, integ.getEventsHandlers().size());
integ.clearEventHandlers();
assertEquals(0, integ.getEventHandlers().size());
}
@ -218,7 +218,7 @@ public class DormandPrince54IntegratorTest
FirstOrderIntegrator integ = new DormandPrince54Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(new KeplerHandler(pb));
integ.addStepHandler(new KeplerHandler(pb));
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -239,7 +239,7 @@ public class DormandPrince54IntegratorTest
FirstOrderIntegrator integ = new DormandPrince54Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(new VariableHandler());
integ.addStepHandler(new VariableHandler());
double stopTime = integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
assertEquals(pb.getFinalTime(), stopTime, 1.0e-10);

View File

@ -64,14 +64,16 @@ public class DormandPrince54StepInterpolatorTest
DormandPrince54Integrator integ = new DormandPrince54Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(new ContinuousOutputModel());
integ.addStepHandler(new ContinuousOutputModel());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(integ.getStepHandler());
for (StepHandler handler : integ.getStepHandlers()) {
oos.writeObject(handler);
}
assertTrue(bos.size () > 119500);
assertTrue(bos.size () < 120500);
@ -110,7 +112,7 @@ public class DormandPrince54StepInterpolatorTest
DormandPrince54Integrator integ = new DormandPrince54Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(new StepHandler() {
integ.addStepHandler(new StepHandler() {
private static final long serialVersionUID = -6768136169276197L;
public void handleStep(StepInterpolator interpolator, boolean isLast)
throws DerivativeException {

View File

@ -79,7 +79,7 @@ public class DormandPrince853IntegratorTest
vecAbsoluteTolerance,
vecRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -106,7 +106,7 @@ public class DormandPrince853IntegratorTest
scalAbsoluteTolerance,
scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -138,13 +138,13 @@ public class DormandPrince853IntegratorTest
scalAbsoluteTolerance,
scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
EventHandler[] functions = pb.getEventsHandlers();
for (int l = 0; l < functions.length; ++l) {
integ.addEventHandler(functions[l],
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
}
assertEquals(functions.length, integ.getEventsHandlers().size());
assertEquals(functions.length, integ.getEventHandlers().size());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -152,8 +152,8 @@ public class DormandPrince853IntegratorTest
assertTrue(handler.getMaximalValueError() < 5.0e-8);
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
integ.clearEventsHandlers();
assertEquals(0, integ.getEventsHandlers().size());
integ.clearEventHandlers();
assertEquals(0, integ.getEventHandlers().size());
}
@ -169,7 +169,7 @@ public class DormandPrince853IntegratorTest
FirstOrderIntegrator integ = new DormandPrince853Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(new KeplerHandler(pb));
integ.addStepHandler(new KeplerHandler(pb));
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -190,7 +190,7 @@ public class DormandPrince853IntegratorTest
FirstOrderIntegrator integ = new DormandPrince853Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(new VariableHandler());
integ.addStepHandler(new VariableHandler());
double stopTime = integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -210,13 +210,13 @@ public class DormandPrince853IntegratorTest
FirstOrderIntegrator integ = new DormandPrince853Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(DummyStepHandler.getInstance());
integ.addStepHandler(DummyStepHandler.getInstance());
integ.integrate(pb1,
pb1.getInitialTime(), pb1.getInitialState(),
pb1.getFinalTime(), new double[pb1.getDimension()]);
int callsWithoutDenseOutput = pb1.getCalls();
integ.setStepHandler(new InterpolatingStepHandler());
integ.addStepHandler(new InterpolatingStepHandler());
integ.integrate(pb2,
pb2.getInitialTime(), pb2.getInitialState(),
pb2.getFinalTime(), new double[pb2.getDimension()]);

View File

@ -64,14 +64,16 @@ public class DormandPrince853StepInterpolatorTest
DormandPrince853Integrator integ = new DormandPrince853Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(new ContinuousOutputModel());
integ.addStepHandler(new ContinuousOutputModel());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(integ.getStepHandler());
for (StepHandler handler : integ.getStepHandlers()) {
oos.writeObject(handler);
}
assertTrue(bos.size () > 86000);
assertTrue(bos.size () < 87000);
@ -110,7 +112,7 @@ public class DormandPrince853StepInterpolatorTest
DormandPrince853Integrator integ = new DormandPrince853Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(new StepHandler() {
integ.addStepHandler(new StepHandler() {
private static final long serialVersionUID = 2209212559670665268L;
public void handleStep(StepInterpolator interpolator, boolean isLast)
throws DerivativeException {

View File

@ -60,7 +60,7 @@ public class EulerIntegratorTest
FirstOrderIntegrator integ = new EulerIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
EventHandler[] functions = pb.getEventsHandlers();
for (int l = 0; l < functions.length; ++l) {
integ.addEventHandler(functions[l],
@ -93,7 +93,7 @@ public class EulerIntegratorTest
FirstOrderIntegrator integ = new EulerIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -113,7 +113,7 @@ public class EulerIntegratorTest
FirstOrderIntegrator integ = new EulerIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);

View File

@ -31,6 +31,7 @@ import org.apache.commons.math.ode.ContinuousOutputModel;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
import org.apache.commons.math.ode.IntegratorException;
import org.apache.commons.math.ode.sampling.StepHandler;
public class EulerStepInterpolatorTest
extends StepInterpolatorAbstractTest {
@ -132,14 +133,16 @@ public class EulerStepInterpolatorTest
TestProblem1 pb = new TestProblem1();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
EulerIntegrator integ = new EulerIntegrator(step);
integ.setStepHandler(new ContinuousOutputModel());
integ.addStepHandler(new ContinuousOutputModel());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(integ.getStepHandler());
for (StepHandler handler : integ.getStepHandlers()) {
oos.writeObject(handler);
}
assertTrue(bos.size () > 82000);
assertTrue(bos.size () < 83000);

View File

@ -62,7 +62,7 @@ public class GillIntegratorTest
FirstOrderIntegrator integ = new GillIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
EventHandler[] functions = pb.getEventsHandlers();
for (int l = 0; l < functions.length; ++l) {
integ.addEventHandler(functions[l],
@ -95,7 +95,7 @@ public class GillIntegratorTest
FirstOrderIntegrator integ = new GillIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -114,7 +114,7 @@ public class GillIntegratorTest
FirstOrderIntegrator integ = new GillIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -131,7 +131,7 @@ public class GillIntegratorTest
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
FirstOrderIntegrator integ = new GillIntegrator(step);
integ.setStepHandler(new KeplerStepHandler(pb));
integ.addStepHandler(new KeplerStepHandler(pb));
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);

View File

@ -29,6 +29,7 @@ import org.apache.commons.math.ode.ContinuousOutputModel;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.IntegratorException;
import org.apache.commons.math.ode.nonstiff.GillIntegrator;
import org.apache.commons.math.ode.sampling.StepHandler;
public class GillStepInterpolatorTest
extends StepInterpolatorAbstractTest {
@ -52,14 +53,16 @@ public class GillStepInterpolatorTest
TestProblem3 pb = new TestProblem3(0.9);
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
GillIntegrator integ = new GillIntegrator(step);
integ.setStepHandler(new ContinuousOutputModel());
integ.addStepHandler(new ContinuousOutputModel());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(integ.getStepHandler());
for (StepHandler handler : integ.getStepHandlers()) {
oos.writeObject(handler);
}
assertTrue(bos.size () > 700000);
assertTrue(bos.size () < 701000);

View File

@ -78,7 +78,7 @@ public class GraggBulirschStoerIntegratorTest
new GraggBulirschStoerIntegrator(minStep, maxStep,
vecAbsoluteTolerance, vecRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -105,7 +105,7 @@ public class GraggBulirschStoerIntegratorTest
new GraggBulirschStoerIntegrator(minStep, maxStep,
absTolerance, relTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -158,7 +158,7 @@ public class GraggBulirschStoerIntegratorTest
private double getMaxError(FirstOrderIntegrator integrator, TestProblemAbstract pb)
throws DerivativeException, IntegratorException {
TestProblemHandler handler = new TestProblemHandler(pb, integrator);
integrator.setStepHandler(handler);
integrator.addStepHandler(handler);
integrator.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -178,13 +178,13 @@ public class GraggBulirschStoerIntegratorTest
scalAbsoluteTolerance,
scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
EventHandler[] functions = pb.getEventsHandlers();
for (int l = 0; l < functions.length; ++l) {
integ.addEventHandler(functions[l],
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
}
assertEquals(functions.length, integ.getEventsHandlers().size());
assertEquals(functions.length, integ.getEventHandlers().size());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -192,8 +192,8 @@ public class GraggBulirschStoerIntegratorTest
assertTrue(handler.getMaximalValueError() < 5.0e-8);
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
integ.clearEventsHandlers();
assertEquals(0, integ.getEventsHandlers().size());
integ.clearEventHandlers();
assertEquals(0, integ.getEventHandlers().size());
}
@ -209,7 +209,7 @@ public class GraggBulirschStoerIntegratorTest
FirstOrderIntegrator integ =
new GraggBulirschStoerIntegrator(minStep, maxStep,
absTolerance, relTolerance);
integ.setStepHandler(new KeplerStepHandler(pb));
integ.addStepHandler(new KeplerStepHandler(pb));
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -229,7 +229,7 @@ public class GraggBulirschStoerIntegratorTest
FirstOrderIntegrator integ =
new GraggBulirschStoerIntegrator(minStep, maxStep,
absTolerance, relTolerance);
integ.setStepHandler(new VariableStepHandler());
integ.addStepHandler(new VariableStepHandler());
double stopTime = integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);

View File

@ -66,14 +66,16 @@ public class GraggBulirschStoerStepInterpolatorTest
GraggBulirschStoerIntegrator integ =
new GraggBulirschStoerIntegrator(minStep, maxStep,
absTolerance, relTolerance);
integ.setStepHandler(new ContinuousOutputModel());
integ.addStepHandler(new ContinuousOutputModel());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(integ.getStepHandler());
for (StepHandler handler : integ.getStepHandlers()) {
oos.writeObject(handler);
}
assertTrue(bos.size () > 34000);
assertTrue(bos.size () < 35000);
@ -112,7 +114,7 @@ public class GraggBulirschStoerStepInterpolatorTest
GraggBulirschStoerIntegrator integ = new GraggBulirschStoerIntegrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(new StepHandler() {
integ.addStepHandler(new StepHandler() {
private static final long serialVersionUID = -5947183291381232297L;
public void handleStep(StepInterpolator interpolator, boolean isLast)
throws DerivativeException {

View File

@ -92,7 +92,7 @@ public class HighamHall54IntegratorTest
vecAbsoluteTolerance,
vecRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -119,7 +119,7 @@ public class HighamHall54IntegratorTest
scalAbsoluteTolerance,
scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -151,13 +151,13 @@ public class HighamHall54IntegratorTest
scalAbsoluteTolerance,
scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
EventHandler[] functions = pb.getEventsHandlers();
for (int l = 0; l < functions.length; ++l) {
integ.addEventHandler(functions[l],
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
}
assertEquals(functions.length, integ.getEventsHandlers().size());
assertEquals(functions.length, integ.getEventHandlers().size());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -165,8 +165,8 @@ public class HighamHall54IntegratorTest
assertTrue(handler.getMaximalValueError() < 1.0e-7);
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
integ.clearEventsHandlers();
assertEquals(0, integ.getEventsHandlers().size());
integ.clearEventHandlers();
assertEquals(0, integ.getEventHandlers().size());
}
@ -183,7 +183,7 @@ public class HighamHall54IntegratorTest
new HighamHall54Integrator(minStep, maxStep,
scalAbsoluteTolerance, scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.addEventHandler(new EventHandler() {
public int eventOccurred(double t, double[] y) {
@ -229,7 +229,7 @@ public class HighamHall54IntegratorTest
new HighamHall54Integrator(minStep, maxStep,
scalAbsoluteTolerance, scalRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.addEventHandler(new EventHandler() {
public int eventOccurred(double t, double[] y) {
@ -332,7 +332,7 @@ public class HighamHall54IntegratorTest
FirstOrderIntegrator integ = new HighamHall54Integrator(minStep, maxStep,
vecAbsoluteTolerance,
vecRelativeTolerance);
integ.setStepHandler(new KeplerHandler(pb));
integ.addStepHandler(new KeplerHandler(pb));
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);

View File

@ -64,14 +64,16 @@ public class HighamHall54StepInterpolatorTest
HighamHall54Integrator integ = new HighamHall54Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(new ContinuousOutputModel());
integ.addStepHandler(new ContinuousOutputModel());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(integ.getStepHandler());
for (StepHandler handler : integ.getStepHandlers()) {
oos.writeObject(handler);
}
assertTrue(bos.size () > 158000);
assertTrue(bos.size () < 159000);
@ -110,7 +112,7 @@ public class HighamHall54StepInterpolatorTest
HighamHall54Integrator integ = new HighamHall54Integrator(minStep, maxStep,
scalAbsoluteTolerance,
scalRelativeTolerance);
integ.setStepHandler(new StepHandler() {
integ.addStepHandler(new StepHandler() {
private static final long serialVersionUID = 9111679755950880352L;
public void handleStep(StepInterpolator interpolator, boolean isLast)
throws DerivativeException {

View File

@ -59,7 +59,7 @@ public class MidpointIntegratorTest
* Math.pow(2.0, -i);
FirstOrderIntegrator integ = new MidpointIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
EventHandler[] functions = pb.getEventsHandlers();
for (int l = 0; l < functions.length; ++l) {
integ.addEventHandler(functions[l],
@ -93,7 +93,7 @@ public class MidpointIntegratorTest
FirstOrderIntegrator integ = new MidpointIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -113,7 +113,7 @@ public class MidpointIntegratorTest
FirstOrderIntegrator integ = new MidpointIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);

View File

@ -30,6 +30,7 @@ import junit.framework.TestSuite;
import org.apache.commons.math.ode.ContinuousOutputModel;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.IntegratorException;
import org.apache.commons.math.ode.sampling.StepHandler;
public class MidpointStepInterpolatorTest
extends StepInterpolatorAbstractTest {
@ -53,14 +54,16 @@ public class MidpointStepInterpolatorTest
TestProblem1 pb = new TestProblem1();
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
MidpointIntegrator integ = new MidpointIntegrator(step);
integ.setStepHandler(new ContinuousOutputModel());
integ.addStepHandler(new ContinuousOutputModel());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(integ.getStepHandler());
for (StepHandler handler : integ.getStepHandlers()) {
oos.writeObject(handler);
}
assertTrue(bos.size () > 98000);
assertTrue(bos.size () < 99000);

View File

@ -34,7 +34,7 @@ public class StepInterpolatorAbstractTest extends TestCase {
final TestProblemAbstract problem,
final double threshold)
throws DerivativeException, IntegratorException {
integrator.setStepHandler(new StepHandler() {
integrator.addStepHandler(new StepHandler() {
private static final long serialVersionUID = 2462564234755682953L;

View File

@ -62,7 +62,7 @@ public class ThreeEighthesIntegratorTest
FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
EventHandler[] functions = pb.getEventsHandlers();
for (int l = 0; l < functions.length; ++l) {
integ.addEventHandler(functions[l],
@ -95,7 +95,7 @@ public class ThreeEighthesIntegratorTest
FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -114,7 +114,7 @@ public class ThreeEighthesIntegratorTest
FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.setStepHandler(handler);
integ.addStepHandler(handler);
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
@ -131,7 +131,7 @@ public class ThreeEighthesIntegratorTest
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
integ.setStepHandler(new KeplerHandler(pb));
integ.addStepHandler(new KeplerHandler(pb));
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);

View File

@ -30,6 +30,7 @@ import junit.framework.TestSuite;
import org.apache.commons.math.ode.ContinuousOutputModel;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.IntegratorException;
import org.apache.commons.math.ode.sampling.StepHandler;
public class ThreeEighthesStepInterpolatorTest
extends StepInterpolatorAbstractTest {
@ -53,14 +54,16 @@ public class ThreeEighthesStepInterpolatorTest
TestProblem3 pb = new TestProblem3(0.9);
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
ThreeEighthesIntegrator integ = new ThreeEighthesIntegrator(step);
integ.setStepHandler(new ContinuousOutputModel());
integ.addStepHandler(new ContinuousOutputModel());
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),
pb.getFinalTime(), new double[pb.getDimension()]);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(integ.getStepHandler());
for (StepHandler handler : integ.getStepHandlers()) {
oos.writeObject(handler);
}
assertTrue(bos.size () > 700000);
assertTrue(bos.size () < 701000);

View File

@ -40,7 +40,7 @@ public class StepNormalizerTest
throws DerivativeException, IntegratorException {
double range = pb.getFinalTime() - pb.getInitialTime();
setLastSeen(false);
integ.setStepHandler(new StepNormalizer(range / 10.0,
integ.addStepHandler(new StepNormalizer(range / 10.0,
new FixedStepHandler() {
private boolean firstCall = true;
public void handleStep(double t,
@ -67,7 +67,7 @@ public class StepNormalizerTest
throws DerivativeException, IntegratorException {
final double range = pb.getFinalTime() - pb.getInitialTime();
setLastSeen(false);
integ.setStepHandler(new StepNormalizer(range / 10.5,
integ.addStepHandler(new StepNormalizer(range / 10.5,
new FixedStepHandler() {
public void handleStep(double t,
double[] y,