You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2008/07/01 14:36:21 UTC
svn commit: r673069 - in /commons/proper/math/branches/MATH_2_0/src:
java/org/apache/commons/math/ode/ java/org/apache/commons/math/ode/nonstiff/
test/org/apache/commons/math/ode/nonstiff/
Author: luc
Date: Tue Jul 1 05:36:20 2008
New Revision: 673069
URL: http://svn.apache.org/viewvc?rev=673069&view=rev
Log:
added a top-level AbstractIntegrator class to manage events and step handlers
Added:
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractIntegrator.java (with props)
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java
- copied, changed from r673064, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java
Removed:
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java
Modified:
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerIntegrator.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.java
commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java
commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java
Added: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractIntegrator.java?rev=673069&view=auto
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractIntegrator.java (added)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractIntegrator.java Tue Jul 1 05:36:20 2008
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math.ode;
+
+import java.util.Collection;
+
+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;
+
+/**
+ * Base class managing common boilerplate for all integrators.
+ * @version $Revision$ $Date$
+ * @since 2.0
+ */
+public abstract class AbstractIntegrator implements FirstOrderIntegrator {
+
+ /** Name of the method. */
+ private final String name;
+
+ /** Step handler. */
+ protected StepHandler handler;
+
+ /** Current step start time. */
+ protected double stepStart;
+
+ /** Current stepsize. */
+ protected double stepSize;
+
+ /** Events handlers manager. */
+ protected CombinedEventsManager eventsHandlersManager;
+
+ /** Build an instance.
+ * @param name name of the method
+ */
+ public AbstractIntegrator(final String name) {
+ this.name = name;
+ handler = DummyStepHandler.getInstance();
+ stepStart = Double.NaN;
+ stepSize = Double.NaN;
+ eventsHandlersManager = new CombinedEventsManager();
+ }
+
+ /** {@inheritDoc} */
+ public String getName() {
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ public void setStepHandler(final StepHandler handler) {
+ this.handler = handler;
+ }
+
+ /** {@inheritDoc} */
+ public StepHandler getStepHandler() {
+ return handler;
+ }
+
+ /** {@inheritDoc} */
+ public void addEventHandler(final EventHandler function,
+ final double maxCheckInterval,
+ final double convergence,
+ final int maxIterationCount) {
+ eventsHandlersManager.addEventHandler(function, maxCheckInterval,
+ convergence, maxIterationCount);
+ }
+
+ /** {@inheritDoc} */
+ public Collection<EventHandler> getEventsHandlers() {
+ return eventsHandlersManager.getEventsHandlers();
+ }
+
+ /** {@inheritDoc} */
+ public void clearEventsHandlers() {
+ eventsHandlersManager.clearEventsHandlers();
+ }
+
+ /** {@inheritDoc} */
+ public double getCurrentStepStart() {
+ return stepStart;
+ }
+
+ /** {@inheritDoc} */
+ public double getCurrentSignedStepsize() {
+ return stepSize;
+ }
+
+}
\ No newline at end of file
Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractIntegrator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java Tue Jul 1 05:36:20 2008
@@ -21,6 +21,7 @@
import java.util.List;
import java.io.Serializable;
+import org.apache.commons.math.ode.nonstiff.AdaptiveStepsizeIntegrator;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java (from r673064, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java&r1=673064&r2=673069&rev=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java Tue Jul 1 05:36:20 2008
@@ -15,14 +15,12 @@
* limitations under the License.
*/
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
-import java.util.Collection;
-
-import org.apache.commons.math.ode.events.EventHandler;
-import org.apache.commons.math.ode.events.CombinedEventsManager;
-import org.apache.commons.math.ode.sampling.DummyStepHandler;
-import org.apache.commons.math.ode.sampling.StepHandler;
+import org.apache.commons.math.ode.AbstractIntegrator;
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
+import org.apache.commons.math.ode.IntegratorException;
/**
* This abstract class holds the common part of all adaptive
@@ -54,10 +52,11 @@
*/
public abstract class AdaptiveStepsizeIntegrator
- implements FirstOrderIntegrator {
+ extends AbstractIntegrator {
/** Build an integrator with the given stepsize bounds.
* The default step handler does nothing.
+ * @param name name of the method
* @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
@@ -65,10 +64,13 @@
* @param scalAbsoluteTolerance allowed absolute error
* @param scalRelativeTolerance allowed relative error
*/
- public AdaptiveStepsizeIntegrator(final double minStep, final double maxStep,
+ public AdaptiveStepsizeIntegrator(final String name,
+ final double minStep, final double maxStep,
final double scalAbsoluteTolerance,
final double scalRelativeTolerance) {
+ super(name);
+
this.minStep = minStep;
this.maxStep = maxStep;
this.initialStep = -1.0;
@@ -78,17 +80,13 @@
this.vecAbsoluteTolerance = null;
this.vecRelativeTolerance = null;
- // set the default step handler
- handler = DummyStepHandler.getInstance();
-
- eventsHandlersManager = new CombinedEventsManager();
-
resetInternalState();
}
/** Build an integrator with the given stepsize bounds.
* The default step handler does nothing.
+ * @param name name of the method
* @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
@@ -96,10 +94,13 @@
* @param vecAbsoluteTolerance allowed absolute error
* @param vecRelativeTolerance allowed relative error
*/
- public AdaptiveStepsizeIntegrator(final double minStep, final double maxStep,
+ public AdaptiveStepsizeIntegrator(final String name,
+ final double minStep, final double maxStep,
final double[] vecAbsoluteTolerance,
final double[] vecRelativeTolerance) {
+ super(name);
+
this.minStep = minStep;
this.maxStep = maxStep;
this.initialStep = -1.0;
@@ -109,11 +110,6 @@
this.vecAbsoluteTolerance = vecAbsoluteTolerance;
this.vecRelativeTolerance = vecRelativeTolerance;
- // set the default step handler
- handler = DummyStepHandler.getInstance();
-
- eventsHandlersManager = new CombinedEventsManager();
-
resetInternalState();
}
@@ -137,34 +133,6 @@
}
}
- /** {@inheritDoc} */
- public void setStepHandler (final StepHandler handler) {
- this.handler = handler;
- }
-
- /** {@inheritDoc} */
- public StepHandler getStepHandler() {
- return handler;
- }
-
- /** {@inheritDoc} */
- public void addEventHandler(final EventHandler function,
- final double maxCheckInterval,
- final double convergence,
- final int maxIterationCount) {
- eventsHandlersManager.addEventHandler(function, maxCheckInterval, convergence, maxIterationCount);
- }
-
- /** {@inheritDoc} */
- public Collection<EventHandler> getEventsHandlers() {
- return eventsHandlersManager.getEventsHandlers();
- }
-
- /** {@inheritDoc} */
- public void clearEventsHandlers() {
- eventsHandlersManager.clearEventsHandlers();
- }
-
/** Perform some sanity checks on the integration parameters.
* @param equations differential equations set
* @param t0 start time
@@ -340,11 +308,6 @@
return stepStart;
}
- /** {@inheritDoc} */
- public double getCurrentSignedStepsize() {
- return stepSize;
- }
-
/** Reset internal state to dummy values. */
protected void resetInternalState() {
stepStart = Double.NaN;
@@ -386,16 +349,4 @@
/** Allowed relative vectorial error. */
protected double[] vecRelativeTolerance;
- /** Step handler. */
- protected StepHandler handler;
-
- /** Events handlers manager. */
- protected CombinedEventsManager eventsHandlersManager;
-
- /** Current step start time. */
- protected double stepStart;
-
- /** Current stepsize. */
- protected double stepSize;
-
}
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.java Tue Jul 1 05:36:20 2008
@@ -46,10 +46,7 @@
extends RungeKuttaIntegrator {
/** Serializable version identifier. */
- private static final long serialVersionUID = -8987762131146169612L;
-
- /** Integrator method name. */
- private static final String methodName = "classical Runge-Kutta";
+ private static final long serialVersionUID = 3710070023793519840L;
/** Time steps Butcher array. */
private static final double[] c = {
@@ -74,12 +71,8 @@
* @param step integration step
*/
public ClassicalRungeKuttaIntegrator(final double step) {
- super(c, a, b, new ClassicalRungeKuttaStepInterpolator(), step);
- }
-
- /** {@inheritDoc} */
- public String getName() {
- return methodName;
+ super("classical Runge-Kutta", c, a, b,
+ new ClassicalRungeKuttaStepInterpolator(), step);
}
}
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java Tue Jul 1 05:36:20 2008
@@ -47,10 +47,10 @@
extends EmbeddedRungeKuttaIntegrator {
/** Serializable version identifier. */
- private static final long serialVersionUID = -5346655668732043826L;
+ private static final long serialVersionUID = -7932553613600031791L;
/** Integrator method name. */
- private static final String methodName = "Dormand-Prince 5(4)";
+ private static final String METHOD_NAME = "Dormand-Prince 5(4)";
/** Time steps Butcher array. */
private static final double[] staticC = {
@@ -104,7 +104,7 @@
public DormandPrince54Integrator(final double minStep, final double maxStep,
final double scalAbsoluteTolerance,
final double scalRelativeTolerance) {
- super(true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
+ super(METHOD_NAME, true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
}
@@ -120,16 +120,11 @@
public DormandPrince54Integrator(final double minStep, final double maxStep,
final double[] vecAbsoluteTolerance,
final double[] vecRelativeTolerance) {
- super(true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
+ super(METHOD_NAME, true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
}
/** {@inheritDoc} */
- public String getName() {
- return methodName;
- }
-
- /** {@inheritDoc} */
public int getOrder() {
return 5;
}
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java Tue Jul 1 05:36:20 2008
@@ -55,10 +55,10 @@
extends EmbeddedRungeKuttaIntegrator {
/** Serializable version identifier. */
- private static final long serialVersionUID = 6175337145090754336L;
+ private static final long serialVersionUID = -8627142100635188441L;
/** Integrator method name. */
- private static final String methodName = "Dormand-Prince 8 (5, 3)";
+ private static final String METHOD_NAME = "Dormand-Prince 8 (5, 3)";
/** Time steps Butcher array. */
private static final double[] staticC = {
@@ -216,7 +216,7 @@
public DormandPrince853Integrator(final double minStep, final double maxStep,
final double scalAbsoluteTolerance,
final double scalRelativeTolerance) {
- super(true, staticC, staticA, staticB,
+ super(METHOD_NAME, true, staticC, staticA, staticB,
new DormandPrince853StepInterpolator(),
minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
}
@@ -233,17 +233,12 @@
public DormandPrince853Integrator(final double minStep, final double maxStep,
final double[] vecAbsoluteTolerance,
final double[] vecRelativeTolerance) {
- super(true, staticC, staticA, staticB,
+ super(METHOD_NAME, true, staticC, staticA, staticB,
new DormandPrince853StepInterpolator(),
minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
}
/** {@inheritDoc} */
- public String getName() {
- return methodName;
- }
-
- /** {@inheritDoc} */
public int getOrder() {
return 8;
}
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java Tue Jul 1 05:36:20 2008
@@ -17,7 +17,6 @@
package org.apache.commons.math.ode.nonstiff;
-import org.apache.commons.math.ode.AdaptiveStepsizeIntegrator;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
import org.apache.commons.math.ode.IntegratorException;
@@ -65,6 +64,7 @@
extends AdaptiveStepsizeIntegrator {
/** Build a Runge-Kutta integrator with the given Butcher array.
+ * @param name name of the method
* @param fsal indicate that the method is an <i>fsal</i>
* @param c time steps from Butcher array (without the first zero)
* @param a internal weights from Butcher array (without the first empty row)
@@ -77,14 +77,14 @@
* @param scalAbsoluteTolerance allowed absolute error
* @param scalRelativeTolerance allowed relative error
*/
- protected EmbeddedRungeKuttaIntegrator(final boolean fsal,
+ protected EmbeddedRungeKuttaIntegrator(final String name, final boolean fsal,
final double[] c, final double[][] a, final double[] b,
final RungeKuttaStepInterpolator prototype,
final double minStep, final double maxStep,
final double scalAbsoluteTolerance,
final double scalRelativeTolerance) {
- super(minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
+ super(name, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
this.fsal = fsal;
this.c = c;
@@ -102,6 +102,7 @@
}
/** Build a Runge-Kutta integrator with the given Butcher array.
+ * @param name name of the method
* @param fsal indicate that the method is an <i>fsal</i>
* @param c time steps from Butcher array (without the first zero)
* @param a internal weights from Butcher array (without the first empty row)
@@ -114,14 +115,14 @@
* @param vecAbsoluteTolerance allowed absolute error
* @param vecRelativeTolerance allowed relative error
*/
- protected EmbeddedRungeKuttaIntegrator(final boolean fsal,
+ protected EmbeddedRungeKuttaIntegrator(final String name, final boolean fsal,
final double[] c, final double[][] a, final double[] b,
final RungeKuttaStepInterpolator prototype,
final double minStep, final double maxStep,
final double[] vecAbsoluteTolerance,
final double[] vecRelativeTolerance) {
- super(minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
+ super(name, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
this.fsal = fsal;
this.c = c;
@@ -138,9 +139,6 @@
}
- /** {@inheritDoc} */
- public abstract String getName();
-
/** Get the order of the method.
* @return order of the method
*/
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerIntegrator.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerIntegrator.java Tue Jul 1 05:36:20 2008
@@ -49,10 +49,7 @@
extends RungeKuttaIntegrator {
/** Serializable version identifier. */
- private static final long serialVersionUID = -3378479003330094013L;
-
- /** Integrator method name. */
- private static final String methodName = "Euler";
+ private static final long serialVersionUID = 1828811360890387657L;
/** Time steps Butcher array. */
private static final double[] c = {
@@ -72,12 +69,7 @@
* @param step integration step
*/
public EulerIntegrator(final double step) {
- super(c, a, b, new EulerStepInterpolator(), step);
- }
-
- /** {@inheritDoc} */
- public String getName() {
- return methodName;
+ super("Euler", c, a, b, new EulerStepInterpolator(), step);
}
}
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java Tue Jul 1 05:36:20 2008
@@ -45,10 +45,7 @@
extends RungeKuttaIntegrator {
/** Serializable version identifier. */
- private static final long serialVersionUID = -3270987073897562791L;
-
- /** Integrator method name. */
- private static final String methodName = "Gill";
+ private static final long serialVersionUID = 5566682259665027132L;
/** Time steps Butcher array. */
private static final double[] c = {
@@ -72,12 +69,7 @@
* @param step integration step
*/
public GillIntegrator(final double step) {
- super(c, a, b, new GillStepInterpolator(), step);
- }
-
- /** {@inheritDoc} */
- public String getName() {
- return methodName;
+ super("Gill", c, a, b, new GillStepInterpolator(), step);
}
}
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java Tue Jul 1 05:36:20 2008
@@ -17,7 +17,6 @@
package org.apache.commons.math.ode.nonstiff;
-import org.apache.commons.math.ode.AdaptiveStepsizeIntegrator;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
import org.apache.commons.math.ode.IntegratorException;
@@ -97,10 +96,10 @@
extends AdaptiveStepsizeIntegrator {
/** Serializable version identifier. */
- private static final long serialVersionUID = -1263159462413447366L;
+ private static final long serialVersionUID = 7364884082146325264L;
/** Integrator method name. */
- private static final String methodName = "Gragg-Bulirsch-Stoer";
+ private static final String METHOD_NAME = "Gragg-Bulirsch-Stoer";
/** Simple constructor.
* Build a Gragg-Bulirsch-Stoer integrator with the given step
@@ -116,7 +115,8 @@
public GraggBulirschStoerIntegrator(final double minStep, final double maxStep,
final double scalAbsoluteTolerance,
final double scalRelativeTolerance) {
- super(minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
+ super(METHOD_NAME, minStep, maxStep,
+ scalAbsoluteTolerance, scalRelativeTolerance);
denseOutput = (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty()));
setStabilityCheck(true, -1, -1, -1);
setStepsizeControl(-1, -1, -1, -1);
@@ -138,7 +138,8 @@
public GraggBulirschStoerIntegrator(final double minStep, final double maxStep,
final double[] vecAbsoluteTolerance,
final double[] vecRelativeTolerance) {
- super(minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
+ super(METHOD_NAME, minStep, maxStep,
+ vecAbsoluteTolerance, vecRelativeTolerance);
denseOutput = (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty()));
setStabilityCheck(true, -1, -1, -1);
setStepsizeControl(-1, -1, -1, -1);
@@ -375,11 +376,6 @@
}
- /** {@inheritDoc} */
- public String getName() {
- return methodName;
- }
-
/** Update scaling array.
* @param y1 first state vector to use for scaling
* @param y2 second state vector to use for scaling
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java Tue Jul 1 05:36:20 2008
@@ -35,10 +35,10 @@
extends EmbeddedRungeKuttaIntegrator {
/** Serializable version identifier. */
- private static final long serialVersionUID = -1499486749907617454L;
+ private static final long serialVersionUID = 1462328766749870097L;
/** Integrator method name. */
- private static final String methodName = "Higham-Hall 5(4)";
+ private static final String METHOD_NAME = "Higham-Hall 5(4)";
/** Time steps Butcher array. */
private static final double[] staticC = {
@@ -77,7 +77,7 @@
public HighamHall54Integrator(final double minStep, final double maxStep,
final double scalAbsoluteTolerance,
final double scalRelativeTolerance) {
- super(false, staticC, staticA, staticB, new HighamHall54StepInterpolator(),
+ super(METHOD_NAME, false, staticC, staticA, staticB, new HighamHall54StepInterpolator(),
minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
}
@@ -93,16 +93,11 @@
public HighamHall54Integrator(final double minStep, final double maxStep,
final double[] vecAbsoluteTolerance,
final double[] vecRelativeTolerance) {
- super(false, staticC, staticA, staticB, new HighamHall54StepInterpolator(),
+ super(METHOD_NAME, false, staticC, staticA, staticB, new HighamHall54StepInterpolator(),
minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
}
/** {@inheritDoc} */
- public String getName() {
- return methodName;
- }
-
- /** {@inheritDoc} */
public int getOrder() {
return 5;
}
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.java Tue Jul 1 05:36:20 2008
@@ -43,10 +43,7 @@
extends RungeKuttaIntegrator {
/** Serializable version identifier. */
- private static final long serialVersionUID = 1871083451154005310L;
-
- /** Integrator method name. */
- private static final String methodName = "midpoint";
+ private static final long serialVersionUID = -7690774342890000483L;
/** Time steps Butcher array. */
private static final double[] c = {
@@ -68,12 +65,7 @@
* @param step integration step
*/
public MidpointIntegrator(final double step) {
- super(c, a, b, new MidpointStepInterpolator(), step);
- }
-
- /** {@inheritDoc} */
- public String getName() {
- return methodName;
+ super("midpoint", c, a, b, new MidpointStepInterpolator(), step);
}
}
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java Tue Jul 1 05:36:20 2008
@@ -17,18 +17,13 @@
package org.apache.commons.math.ode.nonstiff;
-import java.util.Collection;
+import org.apache.commons.math.ode.AbstractIntegrator;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
-import org.apache.commons.math.ode.FirstOrderIntegrator;
import org.apache.commons.math.ode.IntegratorException;
-import org.apache.commons.math.ode.events.EventHandler;
-import org.apache.commons.math.ode.events.CombinedEventsManager;
import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
-import org.apache.commons.math.ode.sampling.DummyStepHandler;
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
@@ -55,60 +50,28 @@
* @since 1.2
*/
-public abstract class RungeKuttaIntegrator
- implements FirstOrderIntegrator {
+public abstract class RungeKuttaIntegrator extends AbstractIntegrator {
/** Simple constructor.
* Build a Runge-Kutta integrator with the given
* step. The default step handler does nothing.
+ * @param name name of the method
* @param c time steps from Butcher array (without the first zero)
* @param a internal weights from Butcher array (without the first empty row)
* @param b propagation weights for the high order method from Butcher array
* @param prototype prototype of the step interpolator to use
* @param step integration step
*/
- protected RungeKuttaIntegrator(final double[] c, final double[][] a, final double[] b,
+ protected RungeKuttaIntegrator(final String name,
+ final double[] c, final double[][] a, final double[] b,
final RungeKuttaStepInterpolator prototype,
final double step) {
+ super(name);
this.c = c;
this.a = a;
this.b = b;
this.prototype = prototype;
this.step = step;
- handler = DummyStepHandler.getInstance();
- eventsHandlersManager = new CombinedEventsManager();
- resetInternalState();
- }
-
- /** {@inheritDoc} */
- public abstract String getName();
-
- /** {@inheritDoc} */
- public void setStepHandler (final StepHandler handler) {
- this.handler = handler;
- }
-
- /** {@inheritDoc} */
- public StepHandler getStepHandler() {
- return handler;
- }
-
- /** {@inheritDoc} */
- public void addEventHandler(final EventHandler function,
- final double maxCheckInterval,
- final double convergence,
- final int maxIterationCount) {
- eventsHandlersManager.addEventHandler(function, maxCheckInterval, convergence, maxIterationCount);
- }
-
- /** {@inheritDoc} */
- public Collection<EventHandler> getEventsHandlers() {
- return eventsHandlersManager.getEventsHandlers();
- }
-
- /** {@inheritDoc} */
- public void clearEventsHandlers() {
- eventsHandlersManager.clearEventsHandlers();
}
/** Perform some sanity checks on the integration parameters.
@@ -258,25 +221,10 @@
}
final double stopTime = stepStart;
- resetInternalState();
- return stopTime;
-
- }
-
- /** {@inheritDoc} */
- public double getCurrentStepStart() {
- return stepStart;
- }
-
- /** {@inheritDoc} */
- public double getCurrentSignedStepsize() {
- return stepSize;
- }
-
- /** Reset internal state to dummy values. */
- private void resetInternalState() {
stepStart = Double.NaN;
stepSize = Double.NaN;
+ return stopTime;
+
}
/** Time steps from Butcher array (without the first zero). */
@@ -294,16 +242,4 @@
/** Integration step. */
private double step;
- /** Step handler. */
- private StepHandler handler;
-
- /** Events handlers manager. */
- protected CombinedEventsManager eventsHandlersManager;
-
- /** Current step start time. */
- private double stepStart;
-
- /** Current stepsize. */
- private double stepSize;
-
}
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.java Tue Jul 1 05:36:20 2008
@@ -45,10 +45,7 @@
extends RungeKuttaIntegrator {
/** Serializable version identifier. */
- private static final long serialVersionUID = -5738562635641912717L;
-
- /** Integrator method name. */
- private static final String methodName = "3/8";
+ private static final long serialVersionUID = -2480984691453028021L;
/** Time steps Butcher array. */
private static final double[] c = {
@@ -72,12 +69,7 @@
* @param step integration step
*/
public ThreeEighthesIntegrator(final double step) {
- super(c, a, b, new ThreeEighthesStepInterpolator(), step);
- }
-
- /** {@inheritDoc} */
- public String getName() {
- return methodName;
+ super("3/8", c, a, b, new ThreeEighthesStepInterpolator(), step);
}
}
Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java Tue Jul 1 05:36:20 2008
@@ -17,7 +17,6 @@
package org.apache.commons.math.ode.nonstiff;
-import org.apache.commons.math.ode.AdaptiveStepsizeIntegrator;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.FirstOrderIntegrator;
import org.apache.commons.math.ode.IntegratorException;
Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java?rev=673069&r1=673068&r2=673069&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java Tue Jul 1 05:36:20 2008
@@ -17,7 +17,6 @@
package org.apache.commons.math.ode.nonstiff;
-import org.apache.commons.math.ode.AdaptiveStepsizeIntegrator;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.FirstOrderIntegrator;
import org.apache.commons.math.ode.IntegratorException;