added the getSwitchingFunctions and clearSwitchingfunctions to the integrator interface
JIRA: MATH-202 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@651282 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9b8972d209
commit
de621a4151
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.apache.commons.math.ode;
|
package org.apache.commons.math.ode;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This abstract class holds the common part of all adaptive
|
* This abstract class holds the common part of all adaptive
|
||||||
* stepsize integrators for Ordinary Differential Equations.
|
* stepsize integrators for Ordinary Differential Equations.
|
||||||
|
@ -154,6 +156,8 @@ public abstract class AdaptiveStepsizeIntegrator
|
||||||
* @param convergence convergence threshold in the event time search
|
* @param convergence convergence threshold in the event time search
|
||||||
* @param maxIterationCount upper limit of the iteration count in
|
* @param maxIterationCount upper limit of the iteration count in
|
||||||
* the event time search
|
* the event time search
|
||||||
|
* @see #getSwitchingFunctions()
|
||||||
|
* @see #clearSwitchingFunctions()
|
||||||
*/
|
*/
|
||||||
public void addSwitchingFunction(SwitchingFunction function,
|
public void addSwitchingFunction(SwitchingFunction function,
|
||||||
double maxCheckInterval,
|
double maxCheckInterval,
|
||||||
|
@ -162,6 +166,23 @@ public abstract class AdaptiveStepsizeIntegrator
|
||||||
switchesHandler.add(function, maxCheckInterval, convergence, maxIterationCount);
|
switchesHandler.add(function, maxCheckInterval, convergence, maxIterationCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get all the switching functions that have been added to the integrator.
|
||||||
|
* @return an unmodifiable collection of the added switching functions
|
||||||
|
* @see #add(SwitchingFunction, double, double, int)
|
||||||
|
* @see #clearSwitchingFunctions()
|
||||||
|
*/
|
||||||
|
public Collection getSwitchingFunctions() {
|
||||||
|
return switchesHandler.getSwitchingFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Remove all the switching functions that have been added to the integrator.
|
||||||
|
* @see #add(SwitchingFunction, double, double, int)
|
||||||
|
* @see #getSwitchingFunctions()
|
||||||
|
*/
|
||||||
|
public void clearSwitchingFunctions() {
|
||||||
|
switchesHandler.clearSwitchingFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
/** Perform some sanity checks on the integration parameters.
|
/** Perform some sanity checks on the integration parameters.
|
||||||
* @param equations differential equations set
|
* @param equations differential equations set
|
||||||
* @param t0 start time
|
* @param t0 start time
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.apache.commons.math.ode;
|
package org.apache.commons.math.ode;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/** This interface represents a first order integrator for
|
/** This interface represents a first order integrator for
|
||||||
* differential equations.
|
* differential equations.
|
||||||
|
|
||||||
|
@ -59,12 +61,27 @@ public interface FirstOrderIntegrator {
|
||||||
* @param convergence convergence threshold in the event time search
|
* @param convergence convergence threshold in the event time search
|
||||||
* @param maxIterationCount upper limit of the iteration count in
|
* @param maxIterationCount upper limit of the iteration count in
|
||||||
* the event time search
|
* the event time search
|
||||||
|
* @see #getSwitchingFunctions()
|
||||||
|
* @see #clearSwitchingFunctions()
|
||||||
*/
|
*/
|
||||||
public void addSwitchingFunction(SwitchingFunction function,
|
public void addSwitchingFunction(SwitchingFunction function,
|
||||||
double maxCheckInterval,
|
double maxCheckInterval,
|
||||||
double convergence,
|
double convergence,
|
||||||
int maxIterationCount);
|
int maxIterationCount);
|
||||||
|
|
||||||
|
/** Get all the switching functions that have been added to the integrator.
|
||||||
|
* @return an unmodifiable collection of the added switching functions
|
||||||
|
* @see #add(SwitchingFunction, double, double, int)
|
||||||
|
* @see #clearSwitchingFunctions()
|
||||||
|
*/
|
||||||
|
public Collection getSwitchingFunctions();
|
||||||
|
|
||||||
|
/** Remove all the switching functions that have been added to the integrator.
|
||||||
|
* @see #add(SwitchingFunction, double, double, int)
|
||||||
|
* @see #getSwitchingFunctions()
|
||||||
|
*/
|
||||||
|
public void clearSwitchingFunctions();
|
||||||
|
|
||||||
/** Integrate the differential equations up to the given time.
|
/** Integrate the differential equations up to the given time.
|
||||||
* <p>This method solves an Initial Value Problem (IVP).</p>
|
* <p>This method solves an Initial Value Problem (IVP).</p>
|
||||||
* <p>Since this method stores some internal state variables made
|
* <p>Since this method stores some internal state variables made
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.apache.commons.math.ode;
|
package org.apache.commons.math.ode;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements the common part of all fixed step Runge-Kutta
|
* This class implements the common part of all fixed step Runge-Kutta
|
||||||
* integrators for Ordinary Differential Equations.
|
* integrators for Ordinary Differential Equations.
|
||||||
|
@ -96,6 +98,8 @@ public abstract class RungeKuttaIntegrator
|
||||||
* @param convergence convergence threshold in the event time search
|
* @param convergence convergence threshold in the event time search
|
||||||
* @param maxIterationCount upper limit of the iteration count in
|
* @param maxIterationCount upper limit of the iteration count in
|
||||||
* the event time search
|
* the event time search
|
||||||
|
* @see #getSwitchingFunctions()
|
||||||
|
* @see #clearSwitchingFunctions()
|
||||||
*/
|
*/
|
||||||
public void addSwitchingFunction(SwitchingFunction function,
|
public void addSwitchingFunction(SwitchingFunction function,
|
||||||
double maxCheckInterval,
|
double maxCheckInterval,
|
||||||
|
@ -104,6 +108,23 @@ public abstract class RungeKuttaIntegrator
|
||||||
switchesHandler.add(function, maxCheckInterval, convergence, maxIterationCount);
|
switchesHandler.add(function, maxCheckInterval, convergence, maxIterationCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get all the switching functions that have been added to the integrator.
|
||||||
|
* @return an unmodifiable collection of the added switching functions
|
||||||
|
* @see #add(SwitchingFunction, double, double, int)
|
||||||
|
* @see #clearSwitchingFunctions()
|
||||||
|
*/
|
||||||
|
public Collection getSwitchingFunctions() {
|
||||||
|
return switchesHandler.getSwitchingFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Remove all the switching functions that have been added to the integrator.
|
||||||
|
* @see #add(SwitchingFunction, double, double, int)
|
||||||
|
* @see #getSwitchingFunctions()
|
||||||
|
*/
|
||||||
|
public void clearSwitchingFunctions() {
|
||||||
|
switchesHandler.clearSwitchingFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
/** Perform some sanity checks on the integration parameters.
|
/** Perform some sanity checks on the integration parameters.
|
||||||
* @param equations differential equations set
|
* @param equations differential equations set
|
||||||
* @param t0 start time
|
* @param t0 start time
|
||||||
|
|
|
@ -21,6 +21,8 @@ import org.apache.commons.math.ConvergenceException;
|
||||||
import org.apache.commons.math.FunctionEvaluationException;
|
import org.apache.commons.math.FunctionEvaluationException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -51,6 +53,8 @@ public class SwitchingFunctionsHandler {
|
||||||
* @param convergence convergence threshold in the event time search
|
* @param convergence convergence threshold in the event time search
|
||||||
* @param maxIterationCount upper limit of the iteration count in
|
* @param maxIterationCount upper limit of the iteration count in
|
||||||
* the event time search
|
* the event time search
|
||||||
|
* @see #getSwitchingFunctions()
|
||||||
|
* @see #clearSwitchingFunctions()
|
||||||
*/
|
*/
|
||||||
public void add(SwitchingFunction function, double maxCheckInterval,
|
public void add(SwitchingFunction function, double maxCheckInterval,
|
||||||
double convergence, int maxIterationCount) {
|
double convergence, int maxIterationCount) {
|
||||||
|
@ -58,6 +62,23 @@ public class SwitchingFunctionsHandler {
|
||||||
convergence, maxIterationCount));
|
convergence, maxIterationCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get all the switching functions that have been added to the handler.
|
||||||
|
* @return an unmodifiable collection of the added switching functions
|
||||||
|
* @see #add(SwitchingFunction, double, double, int)
|
||||||
|
* @see #clearSwitchingFunctions()
|
||||||
|
*/
|
||||||
|
public Collection getSwitchingFunctions() {
|
||||||
|
return Collections.unmodifiableCollection(functions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Remove all the switching functions that have been added to the handler.
|
||||||
|
* @see #add(SwitchingFunction, double, double, int)
|
||||||
|
* @see #getSwitchingFunctions()
|
||||||
|
*/
|
||||||
|
public void clearSwitchingFunctions() {
|
||||||
|
functions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/** Check if the handler does not have any condition.
|
/** Check if the handler does not have any condition.
|
||||||
* @return true if handler is empty
|
* @return true if handler is empty
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -40,6 +40,10 @@ Commons Math Release Notes</title>
|
||||||
</properties>
|
</properties>
|
||||||
<body>
|
<body>
|
||||||
<release version="2.0" date="TBD" description="TBD">
|
<release version="2.0" date="TBD" description="TBD">
|
||||||
|
<action dev="luc" type="add" issue="MATH-202">
|
||||||
|
Added the getSwitchingFunctions and clearSwitchingFunctions to the
|
||||||
|
FirstOrderIntegrator interface and all its implementations
|
||||||
|
</action>
|
||||||
<action dev="luc" type="update" >
|
<action dev="luc" type="update" >
|
||||||
Removed deprecated features. This includes the following changes. Factory-based
|
Removed deprecated features. This includes the following changes. Factory-based
|
||||||
instantiation replaced by setter injection in 1.2 in several classes have been
|
instantiation replaced by setter injection in 1.2 in several classes have been
|
||||||
|
|
|
@ -88,6 +88,7 @@ public class ClassicalRungeKuttaIntegratorTest
|
||||||
integ.addSwitchingFunction(functions[l],
|
integ.addSwitchingFunction(functions[l],
|
||||||
Double.POSITIVE_INFINITY, 1.0e-6 * step, 1000);
|
Double.POSITIVE_INFINITY, 1.0e-6 * step, 1000);
|
||||||
}
|
}
|
||||||
|
assertEquals(functions.length, integ.getSwitchingFunctions().size());
|
||||||
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
|
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
|
||||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||||
|
|
||||||
|
@ -97,6 +98,8 @@ public class ClassicalRungeKuttaIntegratorTest
|
||||||
}
|
}
|
||||||
previousError = error;
|
previousError = error;
|
||||||
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
|
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
|
||||||
|
integ.clearSwitchingFunctions();
|
||||||
|
assertEquals(0, integ.getSwitchingFunctions().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,6 +191,7 @@ public class DormandPrince54IntegratorTest
|
||||||
integ.addSwitchingFunction(functions[l],
|
integ.addSwitchingFunction(functions[l],
|
||||||
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
|
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
|
||||||
}
|
}
|
||||||
|
assertEquals(functions.length, integ.getSwitchingFunctions().size());
|
||||||
integ.integrate(pb,
|
integ.integrate(pb,
|
||||||
pb.getInitialTime(), pb.getInitialState(),
|
pb.getInitialTime(), pb.getInitialState(),
|
||||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||||
|
@ -198,6 +199,8 @@ public class DormandPrince54IntegratorTest
|
||||||
assertTrue(handler.getMaximalValueError() < 5.0e-6);
|
assertTrue(handler.getMaximalValueError() < 5.0e-6);
|
||||||
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
|
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
|
||||||
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
|
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
|
||||||
|
integ.clearSwitchingFunctions();
|
||||||
|
assertEquals(0, integ.getSwitchingFunctions().size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,7 @@ public class DormandPrince853IntegratorTest
|
||||||
integ.addSwitchingFunction(functions[l],
|
integ.addSwitchingFunction(functions[l],
|
||||||
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
|
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
|
||||||
}
|
}
|
||||||
|
assertEquals(functions.length, integ.getSwitchingFunctions().size());
|
||||||
integ.integrate(pb,
|
integ.integrate(pb,
|
||||||
pb.getInitialTime(), pb.getInitialState(),
|
pb.getInitialTime(), pb.getInitialState(),
|
||||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||||
|
@ -151,6 +152,8 @@ public class DormandPrince853IntegratorTest
|
||||||
assertTrue(handler.getMaximalValueError() < 5.0e-8);
|
assertTrue(handler.getMaximalValueError() < 5.0e-8);
|
||||||
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
|
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
|
||||||
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
|
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
|
||||||
|
integ.clearSwitchingFunctions();
|
||||||
|
assertEquals(0, integ.getSwitchingFunctions().size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,7 @@ public class GraggBulirschStoerIntegratorTest
|
||||||
integ.addSwitchingFunction(functions[l],
|
integ.addSwitchingFunction(functions[l],
|
||||||
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
|
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
|
||||||
}
|
}
|
||||||
|
assertEquals(functions.length, integ.getSwitchingFunctions().size());
|
||||||
integ.integrate(pb,
|
integ.integrate(pb,
|
||||||
pb.getInitialTime(), pb.getInitialState(),
|
pb.getInitialTime(), pb.getInitialState(),
|
||||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||||
|
@ -191,6 +192,8 @@ public class GraggBulirschStoerIntegratorTest
|
||||||
assertTrue(handler.getMaximalValueError() < 5.0e-8);
|
assertTrue(handler.getMaximalValueError() < 5.0e-8);
|
||||||
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
|
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
|
||||||
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
|
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
|
||||||
|
integ.clearSwitchingFunctions();
|
||||||
|
assertEquals(0, integ.getSwitchingFunctions().size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,6 +153,7 @@ public class HighamHall54IntegratorTest
|
||||||
integ.addSwitchingFunction(functions[l],
|
integ.addSwitchingFunction(functions[l],
|
||||||
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
|
Double.POSITIVE_INFINITY, 1.0e-8 * maxStep, 1000);
|
||||||
}
|
}
|
||||||
|
assertEquals(functions.length, integ.getSwitchingFunctions().size());
|
||||||
integ.integrate(pb,
|
integ.integrate(pb,
|
||||||
pb.getInitialTime(), pb.getInitialState(),
|
pb.getInitialTime(), pb.getInitialState(),
|
||||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||||
|
@ -160,6 +161,8 @@ public class HighamHall54IntegratorTest
|
||||||
assertTrue(handler.getMaximalValueError() < 1.0e-7);
|
assertTrue(handler.getMaximalValueError() < 1.0e-7);
|
||||||
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
|
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
|
||||||
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
|
assertEquals(12.0, handler.getLastTime(), 1.0e-8 * maxStep);
|
||||||
|
integ.clearSwitchingFunctions();
|
||||||
|
assertEquals(0, integ.getSwitchingFunctions().size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue