Return-Path:
Adams-Bashforth methods (in fact due to Adams alone) are explicit - * multistep ODE solvers with fixed stepsize. The value of state vector + * multistep ODE solvers. This implementation is a variation of the classical + * one: it uses adaptive stepsize to implement error control, whereas + * classical implementations are fixed step size. The value of state vector * at step n+1 is a simple combination of the value at step n and of the * derivatives at steps n, n-1, n-2 ... Depending on the number k of previous * steps one wants to use for computing the next value, different formulas @@ -45,8 +47,7 @@ *
A k-steps Adams-Bashforth method is of order k. There is no theoretical limit to the - * value of k, but due to an implementation limitation k must be greater than 1.
+ *A k-steps Adams-Bashforth method is of order k.
* *The Nordsieck vector at step n+1 is computed from the Nordsieck vector at step n as follows: @@ -142,8 +143,7 @@ /** * Build an Adams-Bashforth with the given order and step size. - * @param order order of the method (must be greater than 1: due to - * an implementation limitation the order 1 method is not supported) + * @param nSteps number of steps of the method excluding the one being computed * @param minStep minimal step (must be positive even for backward * integration), the last step can be smaller than this * @param maxStep maximal step (must be positive even for backward @@ -152,19 +152,18 @@ * @param scalRelativeTolerance allowed relative error * @exception IllegalArgumentException if order is 1 or less */ - public AdamsBashforthIntegrator(final int order, + public AdamsBashforthIntegrator(final int nSteps, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) throws IllegalArgumentException { - super("Adams-Bashforth", order, order, minStep, maxStep, + super("Adams-Bashforth", nSteps, nSteps + 1, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } /** * Build an Adams-Bashforth with the given order and step size. - * @param order order of the method (must be greater than 1: due to - * an implementation limitation the order 1 method is not supported) + * @param nSteps number of steps of the method excluding the one being computed * @param minStep minimal step (must be positive even for backward * integration), the last step can be smaller than this * @param maxStep maximal step (must be positive even for backward @@ -173,12 +172,12 @@ * @param vecRelativeTolerance allowed relative error * @exception IllegalArgumentException if order is 1 or less */ - public AdamsBashforthIntegrator(final int order, + public AdamsBashforthIntegrator(final int nSteps, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) throws IllegalArgumentException { - super("Adams-Bashforth", order, order, minStep, maxStep, + super("Adams-Bashforth", nSteps, nSteps + 1, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java?rev=787050&r1=787049&r2=787050&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java Sun Jun 21 17:01:03 2009 @@ -36,10 +36,12 @@ * Differential Equations. * *
Adams-Moulton methods (in fact due to Adams alone) are implicit - * multistep ODE solvers with fixed stepsize. The value of state vector + * multistep ODE solvers. This implementation is a variation of the classical + * one: it uses adaptive stepsize to implement error control, whereas + * classical implementations are fixed step size. The value of state vector * at step n+1 is a simple combination of the value at step n and of the * derivatives at steps n+1, n, n-1 ... Since y'n+1 is needed to - * compute yn+1, another method must be used to compute a first + * compute yn+1,another method must be used to compute a first * estimate of yn+1, then compute y'n+1, then compute * a final estimate of yn+1 using the following formulas. Depending * on the number k of previous steps one wants to use for computing the next @@ -52,8 +54,7 @@ *
A k-steps Adams-Moulton method is of order k+1. There is no theoretical limit to the - * value of k, but due to an implementation limitation k must be greater than 1.
+ *A k-steps Adams-Moulton method is of order k+1.
* *The predicted Nordsieck vector at step n+1 is computed from the Nordsieck vector at step @@ -158,9 +159,8 @@ public class AdamsMoultonIntegrator extends MultistepIntegrator { /** - * Build an Adams-Moulton integrator with the given order and step size. - * @param order order of the method (must be greater than 1: due to - * an implementation limitation the order 1 method is not supported) + * Build an Adams-Moulton integrator with the given order and error control parameters. + * @param nSteps number of steps of the method excluding the one being computed * @param minStep minimal step (must be positive even for backward * integration), the last step can be smaller than this * @param maxStep maximal step (must be positive even for backward @@ -169,19 +169,18 @@ * @param scalRelativeTolerance allowed relative error * @exception IllegalArgumentException if order is 1 or less */ - public AdamsMoultonIntegrator(final int order, + public AdamsMoultonIntegrator(final int nSteps, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) throws IllegalArgumentException { - super("Adams-Moulton", order, order, minStep, maxStep, + super("Adams-Moulton", nSteps, nSteps + 1, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); } /** * Build an Adams-Moulton integrator with the given order and step size. - * @param order order of the method (must be greater than 1: due to - * an implementation limitation the order 1 method is not supported) + * @param nSteps number of steps of the method excluding the one being computed * @param minStep minimal step (must be positive even for backward * integration), the last step can be smaller than this * @param maxStep maximal step (must be positive even for backward @@ -190,12 +189,12 @@ * @param vecRelativeTolerance allowed relative error * @exception IllegalArgumentException if order is 1 or less */ - public AdamsMoultonIntegrator(final int order, + public AdamsMoultonIntegrator(final int nSteps, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) throws IllegalArgumentException { - super("Adams-Moulton", order, order, minStep, maxStep, + super("Adams-Moulton", nSteps, nSteps + 1, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); } Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java?rev=787050&r1=787049&r2=787050&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java Sun Jun 21 17:01:03 2009 @@ -31,7 +31,7 @@ public void dimensionCheck() throws DerivativeException, IntegratorException { TestProblem1 pb = new TestProblem1(); FirstOrderIntegrator integ = - new AdamsBashforthIntegrator(3, 0.0, 1.0, 1.0e-10, 1.0e-10); + new AdamsBashforthIntegrator(2, 0.0, 1.0, 1.0e-10, 1.0e-10); integ.integrate(pb, 0.0, new double[pb.getDimension()+10], 1.0, new double[pb.getDimension()+10]); @@ -46,7 +46,7 @@ double[] vecAbsoluteTolerance = { 1.0e-15, 1.0e-16 }; double[] vecRelativeTolerance = { 1.0e-15, 1.0e-16 }; - FirstOrderIntegrator integ = new AdamsBashforthIntegrator(5, minStep, maxStep, + FirstOrderIntegrator integ = new AdamsBashforthIntegrator(4, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); TestProblemHandler handler = new TestProblemHandler(pb, integ); @@ -69,7 +69,7 @@ double scalAbsoluteTolerance = Math.pow(10.0, i); double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance; - FirstOrderIntegrator integ = new AdamsBashforthIntegrator(5, minStep, maxStep, + FirstOrderIntegrator integ = new AdamsBashforthIntegrator(4, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); TestProblemHandler handler = new TestProblemHandler(pb, integ); @@ -100,7 +100,7 @@ TestProblem1 pb = new TestProblem1(); double range = pb.getFinalTime() - pb.getInitialTime(); - AdamsBashforthIntegrator integ = new AdamsBashforthIntegrator(3, 0, range, 1.0e-12, 1.0e-12); + AdamsBashforthIntegrator integ = new AdamsBashforthIntegrator(2, 0, range, 1.0e-12, 1.0e-12); TestProblemHandler handler = new TestProblemHandler(pb, integ); integ.addStepHandler(handler); integ.setMaxEvaluations(650); @@ -116,7 +116,7 @@ TestProblem5 pb = new TestProblem5(); double range = Math.abs(pb.getFinalTime() - pb.getInitialTime()); - FirstOrderIntegrator integ = new AdamsBashforthIntegrator(5, 0, range, 1.0e-12, 1.0e-12); + FirstOrderIntegrator integ = new AdamsBashforthIntegrator(4, 0, range, 1.0e-12, 1.0e-12); TestProblemHandler handler = new TestProblemHandler(pb, integ); integ.addStepHandler(handler); integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(), @@ -133,14 +133,14 @@ TestProblem6 pb = new TestProblem6(); double range = Math.abs(pb.getFinalTime() - pb.getInitialTime()); - for (int order = 2; order < 9; ++order) { + for (int nSteps = 1; nSteps < 8; ++nSteps) { AdamsBashforthIntegrator integ = - new AdamsBashforthIntegrator(order, 1.0e-6 * range, 0.1 * range, 1.0e-10, 1.0e-10); + new AdamsBashforthIntegrator(nSteps, 1.0e-6 * range, 0.1 * range, 1.0e-10, 1.0e-10); TestProblemHandler handler = new TestProblemHandler(pb, integ); integ.addStepHandler(handler); integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(), pb.getFinalTime(), new double[pb.getDimension()]); - if (order < 5) { + if (nSteps < 4) { assertTrue(integ.getEvaluations() > 160); } else { assertTrue(integ.getEvaluations() < 70); Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java?rev=787050&r1=787049&r2=787050&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java Sun Jun 21 17:01:03 2009 @@ -31,7 +31,7 @@ public void dimensionCheck() throws DerivativeException, IntegratorException { TestProblem1 pb = new TestProblem1(); FirstOrderIntegrator integ = - new AdamsMoultonIntegrator(3, 0.0, 1.0, 1.0e-10, 1.0e-10); + new AdamsMoultonIntegrator(2, 0.0, 1.0, 1.0e-10, 1.0e-10); integ.integrate(pb, 0.0, new double[pb.getDimension()+10], 1.0, new double[pb.getDimension()+10]); @@ -46,9 +46,9 @@ double[] vecAbsoluteTolerance = { 1.0e-15, 1.0e-16 }; double[] vecRelativeTolerance = { 1.0e-15, 1.0e-16 }; - FirstOrderIntegrator integ = new AdamsMoultonIntegrator(5, minStep, maxStep, - vecAbsoluteTolerance, - vecRelativeTolerance); + FirstOrderIntegrator integ = new AdamsMoultonIntegrator(4, minStep, maxStep, + vecAbsoluteTolerance, + vecRelativeTolerance); TestProblemHandler handler = new TestProblemHandler(pb, integ); integ.addStepHandler(handler); integ.integrate(pb, @@ -69,9 +69,9 @@ double scalAbsoluteTolerance = Math.pow(10.0, i); double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance; - FirstOrderIntegrator integ = new AdamsMoultonIntegrator(5, minStep, maxStep, - scalAbsoluteTolerance, - scalRelativeTolerance); + FirstOrderIntegrator integ = new AdamsMoultonIntegrator(4, minStep, maxStep, + scalAbsoluteTolerance, + scalRelativeTolerance); TestProblemHandler handler = new TestProblemHandler(pb, integ); integ.addStepHandler(handler); integ.integrate(pb, @@ -100,7 +100,7 @@ TestProblem1 pb = new TestProblem1(); double range = pb.getFinalTime() - pb.getInitialTime(); - AdamsMoultonIntegrator integ = new AdamsMoultonIntegrator(3, 0, range, 1.0e-12, 1.0e-12); + AdamsMoultonIntegrator integ = new AdamsMoultonIntegrator(2, 0, range, 1.0e-12, 1.0e-12); TestProblemHandler handler = new TestProblemHandler(pb, integ); integ.addStepHandler(handler); integ.setMaxEvaluations(650); @@ -116,7 +116,7 @@ TestProblem5 pb = new TestProblem5(); double range = Math.abs(pb.getFinalTime() - pb.getInitialTime()); - FirstOrderIntegrator integ = new AdamsMoultonIntegrator(5, 0, range, 1.0e-12, 1.0e-12); + FirstOrderIntegrator integ = new AdamsMoultonIntegrator(4, 0, range, 1.0e-12, 1.0e-12); TestProblemHandler handler = new TestProblemHandler(pb, integ); integ.addStepHandler(handler); integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(), @@ -133,14 +133,14 @@ TestProblem6 pb = new TestProblem6(); double range = Math.abs(pb.getFinalTime() - pb.getInitialTime()); - for (int order = 2; order < 8; ++order) { + for (int nSteps = 1; nSteps < 7; ++nSteps) { AdamsMoultonIntegrator integ = - new AdamsMoultonIntegrator(order, 1.0e-6 * range, 0.1 * range, 1.0e-9, 1.0e-9); + new AdamsMoultonIntegrator(nSteps, 1.0e-6 * range, 0.1 * range, 1.0e-9, 1.0e-9); TestProblemHandler handler = new TestProblemHandler(pb, integ); integ.addStepHandler(handler); integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(), pb.getFinalTime(), new double[pb.getDimension()]); - if (order < 5) { + if (nSteps < 4) { assertTrue(integ.getEvaluations() > 150); } else { assertTrue(integ.getEvaluations() < 90);