mirror of
https://github.com/apache/commons-math.git
synced 2025-03-04 15:39:17 +00:00
Use the refactored exceptions framework for ODE.
The IntegratorException and EvenException classes have been removed. The uses of the checked ConvergenceException have been replaced by the unchecked one from the exception package. Sanity checks now use the nes DimensionMismatchException. Step size underflows now trigger NumberIsTooSmallException. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1164573 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8b24302b3d
commit
c9943deeb9
@ -151,7 +151,7 @@ public enum LocalizedFormats implements Localizable {
|
||||
MAX_COUNT_EXCEEDED("maximal count ({0}) exceeded"), /* keep */
|
||||
MAX_EVALUATIONS_EXCEEDED("maximal number of evaluations ({0}) exceeded"),
|
||||
MAX_ITERATIONS_EXCEEDED("maximal number of iterations ({0}) exceeded"),
|
||||
MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION("minimal step size ({0,number,0.00E00}) reached, integration needs {1,number,0.00E00}"),
|
||||
MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION("minimal step size ({1,number,0.00E00}) reached, integration needs {0,number,0.00E00}"),
|
||||
MISMATCHED_LOESS_ABSCISSA_ORDINATE_ARRAYS("Loess expects the abscissa and ordinate arrays to be of the same size, but got {0} abscissae and {1} ordinatae"),
|
||||
NAN_ELEMENT_AT_INDEX("element {0} is NaN"),
|
||||
NAN_VALUE_CONVERSION("cannot convert NaN value"),
|
||||
|
@ -26,13 +26,14 @@ import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.MaxEvaluationsExceededException;
|
||||
import org.apache.commons.math.analysis.solvers.BracketingNthOrderBrentSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolver;
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.ode.events.EventException;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.events.EventState;
|
||||
import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
|
||||
@ -226,14 +227,13 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
||||
* @param yDot placeholder array where to put the time derivative of the state vector
|
||||
* @param tEnd final integration time
|
||||
* @return time at end of step
|
||||
* @exception IntegratorException if the value of one event state cannot be evaluated
|
||||
* @exception MathIllegalStateException if the value of one event state cannot be evaluated
|
||||
* @since 2.2
|
||||
*/
|
||||
protected double acceptStep(final AbstractStepInterpolator interpolator,
|
||||
final double[] y, final double[] yDot, final double tEnd)
|
||||
throws IntegratorException {
|
||||
throws MathIllegalStateException {
|
||||
|
||||
try {
|
||||
double previousT = interpolator.getGlobalPreviousTime();
|
||||
final double currentT = interpolator.getGlobalCurrentTime();
|
||||
resetOccurred = false;
|
||||
@ -329,15 +329,6 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
||||
}
|
||||
|
||||
return currentT;
|
||||
} catch (EventException se) {
|
||||
final Throwable cause = se.getCause();
|
||||
if ((cause != null) && (cause instanceof MathUserException)) {
|
||||
throw (MathUserException) cause;
|
||||
}
|
||||
throw new IntegratorException(se);
|
||||
} catch (ConvergenceException ce) {
|
||||
throw new IntegratorException(ce);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -347,27 +338,27 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
||||
* @param y0 state vector at t0
|
||||
* @param t target time for the integration
|
||||
* @param y placeholder where to put the state vector
|
||||
* @exception IntegratorException if some inconsistency is detected
|
||||
* @exception DimensionMismatchException if some inconsistency is detected
|
||||
* @exception NumberIsTooSmallException if integration span is too small
|
||||
*/
|
||||
protected void sanityChecks(final FirstOrderDifferentialEquations ode,
|
||||
final double t0, final double[] y0,
|
||||
final double t, final double[] y)
|
||||
throws IntegratorException {
|
||||
throws DimensionMismatchException, NumberIsTooSmallException {
|
||||
|
||||
if (ode.getDimension() != y0.length) {
|
||||
throw new IntegratorException(
|
||||
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, ode.getDimension(), y0.length);
|
||||
throw new DimensionMismatchException(ode.getDimension(), y0.length);
|
||||
}
|
||||
|
||||
if (ode.getDimension() != y.length) {
|
||||
throw new IntegratorException(
|
||||
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, ode.getDimension(), y.length);
|
||||
throw new DimensionMismatchException(ode.getDimension(), y.length);
|
||||
}
|
||||
|
||||
if (FastMath.abs(t - t0) <= 1.0e-12 * FastMath.max(FastMath.abs(t0), FastMath.abs(t))) {
|
||||
throw new IntegratorException(
|
||||
LocalizedFormats.TOO_SMALL_INTEGRATION_INTERVAL,
|
||||
FastMath.abs(t - t0));
|
||||
throw new NumberIsTooSmallException(LocalizedFormats.TOO_SMALL_INTEGRATION_INTERVAL,
|
||||
FastMath.abs(t - t0),
|
||||
1.0e-12 * FastMath.max(FastMath.abs(t0), FastMath.abs(t)),
|
||||
false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,8 @@
|
||||
|
||||
package org.apache.commons.math.ode;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
|
||||
/** This interface represents a first order integrator for
|
||||
* differential equations.
|
||||
@ -51,12 +52,12 @@ public interface FirstOrderIntegrator extends ODEIntegrator {
|
||||
* @return stop time, will be the same as target time if integration reached its
|
||||
* target, but may be different if some {@link
|
||||
* org.apache.commons.math.ode.events.EventHandler} stops it at some point.
|
||||
* @throws IntegratorException if the integrator cannot perform integration
|
||||
* @throws MathUserException this exception is propagated to the caller if
|
||||
* the underlying user function triggers one
|
||||
* @throws MathIllegalStateException if the integrator cannot perform integration
|
||||
* @throws MathIllegalArgumentException if integration parameters are wrong (typically
|
||||
* too small integration span)
|
||||
*/
|
||||
double integrate (FirstOrderDifferentialEquations equations,
|
||||
double t0, double[] y0,
|
||||
double t, double[] y) throws MathUserException, IntegratorException;
|
||||
double t0, double[] y0, double t, double[] y)
|
||||
throws MathIllegalStateException, MathIllegalArgumentException;
|
||||
|
||||
}
|
||||
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* 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 org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.exception.util.Localizable;
|
||||
|
||||
/**
|
||||
* This exception is made available to users to report
|
||||
* the error conditions that are triggered during integration
|
||||
* @version $Id$
|
||||
* @since 1.2
|
||||
*/
|
||||
public class IntegratorException
|
||||
extends MathException {
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = -1607588949778036796L;
|
||||
|
||||
/** Simple constructor.
|
||||
* Build an exception by translating and formating a message
|
||||
* @param specifier format specifier (to be translated)
|
||||
* @param parts to insert in the format (no translation)
|
||||
* @since 2.2
|
||||
*/
|
||||
public IntegratorException(final Localizable specifier, final Object ... parts) {
|
||||
super(specifier, parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an exception with a given root cause.
|
||||
* @param cause the exception or error that caused this exception to be thrown
|
||||
*/
|
||||
public IntegratorException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
package org.apache.commons.math.ode;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.linear.Array2DRowRealMatrix;
|
||||
@ -204,12 +205,10 @@ public abstract class MultistepIntegrator extends AdaptiveStepsizeIntegrator {
|
||||
* @param y0 initial value of the state vector at t0
|
||||
* @param t target time for the integration
|
||||
* (can be set to a value smaller than <code>t0</code> for backward integration)
|
||||
* @throws IntegratorException if the integrator cannot perform integration
|
||||
* @throws MathUserException this exception is propagated to the caller if
|
||||
* the underlying user function triggers one
|
||||
* @throws MathIllegalStateException if the integrator cannot perform integration
|
||||
*/
|
||||
protected void start(final double t0, final double[] y0, final double t)
|
||||
throws MathUserException, IntegratorException {
|
||||
throws MathIllegalStateException {
|
||||
|
||||
// make sure NO user event nor user step handler is triggered,
|
||||
// this is the task of the top level integrator, not the task
|
||||
|
@ -17,7 +17,8 @@
|
||||
|
||||
package org.apache.commons.math.ode;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
|
||||
|
||||
/** This interface represents a second order integrator for
|
||||
@ -48,13 +49,13 @@ public interface SecondOrderIntegrator extends ODEIntegrator {
|
||||
* same object as y0
|
||||
* @param yDot placeholder where to put the first derivative of
|
||||
* the state vector at time t, can be the same object as yDot0
|
||||
* @throws IntegratorException if the integrator cannot perform integration
|
||||
* @throws MathUserException this exception is propagated to the caller if the
|
||||
* underlying user function triggers one
|
||||
* @throws MathIllegalStateException if the integrator cannot perform integration
|
||||
* @throws MathIllegalArgumentException if integration parameters are wrong (typically
|
||||
* too small integration span)
|
||||
*/
|
||||
void integrate(SecondOrderDifferentialEquations equations,
|
||||
double t0, double[] y0, double[] yDot0,
|
||||
double t, double[] y, double[] yDot)
|
||||
throws MathUserException, IntegratorException;
|
||||
throws MathIllegalStateException, MathIllegalArgumentException;
|
||||
|
||||
}
|
||||
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.exception.util.Localizable;
|
||||
|
||||
/**
|
||||
* This exception is made available to users to report
|
||||
* the error conditions that are triggered by {@link EventHandler}
|
||||
* @version $Id$
|
||||
* @since 2.0
|
||||
*/
|
||||
public class EventException extends MathException {
|
||||
|
||||
/** Serialization UID. */
|
||||
private static final long serialVersionUID = -898215297400035290L;
|
||||
|
||||
/** Simple constructor.
|
||||
* Build an exception by translating and formating a message
|
||||
* @param specifier format specifier (to be translated)
|
||||
* @param parts to insert in the format (no translation)
|
||||
* @since 2.2
|
||||
*/
|
||||
public EventException(final Localizable specifier, final Object ... parts) {
|
||||
super(specifier, parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an exception with a given root cause.
|
||||
* @param cause the exception or error that caused this exception to be thrown
|
||||
*/
|
||||
public EventException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
@ -94,9 +94,8 @@ public interface EventHandler {
|
||||
* @param t current value of the independent <i>time</i> variable
|
||||
* @param y array containing the current value of the state vector
|
||||
* @return value of the g switching function
|
||||
* @exception EventException if the switching function cannot be evaluated
|
||||
*/
|
||||
double g(double t, double[] y) throws EventException;
|
||||
double g(double t, double[] y);
|
||||
|
||||
/** Handle an event and choose what to do next.
|
||||
|
||||
@ -158,9 +157,8 @@ public interface EventHandler {
|
||||
* @return indication of what the integrator should do next, this
|
||||
* value must be one of {@link #STOP}, {@link #RESET_STATE},
|
||||
* {@link #RESET_DERIVATIVES} or {@link #CONTINUE}
|
||||
* @exception EventException if the event occurrence triggers an error
|
||||
*/
|
||||
int eventOccurred(double t, double[] y, boolean increasing) throws EventException;
|
||||
int eventOccurred(double t, double[] y, boolean increasing);
|
||||
|
||||
/** Reset the state prior to continue the integration.
|
||||
|
||||
@ -176,8 +174,7 @@ public interface EventHandler {
|
||||
* @param t current value of the independent <i>time</i> variable
|
||||
* @param y array containing the current value of the state vector
|
||||
* the new state should be put in the same array
|
||||
* @exception EventException if the state cannot be reseted
|
||||
*/
|
||||
void resetState(double t, double[] y) throws EventException;
|
||||
void resetState(double t, double[] y);
|
||||
|
||||
}
|
||||
|
@ -17,14 +17,13 @@
|
||||
|
||||
package org.apache.commons.math.ode.events;
|
||||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.solvers.AllowedSolution;
|
||||
import org.apache.commons.math.analysis.solvers.BracketedUnivariateRealSolver;
|
||||
import org.apache.commons.math.analysis.solvers.PegasusSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolver;
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolverUtils;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.ConvergenceException;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
@ -148,12 +147,8 @@ public class EventState {
|
||||
|
||||
/** Reinitialize the beginning of the step.
|
||||
* @param interpolator valid for the current step
|
||||
* @exception EventException if the event handler
|
||||
* value cannot be evaluated at the beginning of the step
|
||||
*/
|
||||
public void reinitializeBegin(final StepInterpolator interpolator)
|
||||
throws EventException {
|
||||
try {
|
||||
public void reinitializeBegin(final StepInterpolator interpolator) {
|
||||
|
||||
t0 = interpolator.getPreviousTime();
|
||||
interpolator.setInterpolatedTime(t0);
|
||||
@ -180,25 +175,16 @@ public class EventState {
|
||||
}
|
||||
g0Positive = g0 >= 0;
|
||||
|
||||
} catch (MathUserException mue) {
|
||||
throw new EventException(mue);
|
||||
}
|
||||
}
|
||||
|
||||
/** Evaluate the impact of the proposed step on the event handler.
|
||||
* @param interpolator step interpolator for the proposed step
|
||||
* @return true if the event handler triggers an event before
|
||||
* the end of the proposed step
|
||||
* @exception MathUserException if the interpolator fails to
|
||||
* compute the switching function somewhere within the step
|
||||
* @exception EventException if the switching function
|
||||
* cannot be evaluated
|
||||
* @exception ConvergenceException if an event cannot be located
|
||||
*/
|
||||
public boolean evaluateStep(final StepInterpolator interpolator)
|
||||
throws MathUserException, EventException, ConvergenceException {
|
||||
|
||||
try {
|
||||
throws ConvergenceException {
|
||||
|
||||
forward = interpolator.isForward();
|
||||
final double t1 = interpolator.getCurrentTime();
|
||||
@ -212,12 +198,8 @@ public class EventState {
|
||||
|
||||
final UnivariateRealFunction f = new UnivariateRealFunction() {
|
||||
public double value(final double t) {
|
||||
try {
|
||||
interpolator.setInterpolatedTime(t);
|
||||
return handler.g(t, interpolator.getInterpolatedState());
|
||||
} catch (EventException e) {
|
||||
throw new ConveyedException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -292,10 +274,6 @@ public class EventState {
|
||||
pendingEventTime = Double.NaN;
|
||||
return false;
|
||||
|
||||
} catch (ConveyedException ce) {
|
||||
throw ce.getConveyedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Get the occurrence time of the event triggered in the current step.
|
||||
@ -313,11 +291,8 @@ public class EventState {
|
||||
* end of the step
|
||||
* @param y array containing the current value of the state vector
|
||||
* at the end of the step
|
||||
* @exception EventException if the value of the event
|
||||
* handler cannot be evaluated
|
||||
*/
|
||||
public void stepAccepted(final double t, final double[] y)
|
||||
throws EventException {
|
||||
public void stepAccepted(final double t, final double[] y) {
|
||||
|
||||
t0 = t;
|
||||
g0 = handler.g(t, y);
|
||||
@ -347,11 +322,8 @@ public class EventState {
|
||||
* @param y array were to put the desired state vector at the beginning
|
||||
* of the next step
|
||||
* @return true if the integrator should reset the derivatives too
|
||||
* @exception EventException if the state cannot be reseted by the event
|
||||
* handler
|
||||
*/
|
||||
public boolean reset(final double t, final double[] y)
|
||||
throws EventException {
|
||||
public boolean reset(final double t, final double[] y) {
|
||||
|
||||
if (!(pendingEvent && (FastMath.abs(pendingEventTime - t) <= convergence))) {
|
||||
return false;
|
||||
@ -368,29 +340,4 @@ public class EventState {
|
||||
|
||||
}
|
||||
|
||||
/** Local exception to convey EventException instances through root finding algorithms. */
|
||||
private static class ConveyedException extends RuntimeException {
|
||||
|
||||
/** Serializable uid. */
|
||||
private static final long serialVersionUID = 2668348550531980574L;
|
||||
|
||||
/** Conveyed exception. */
|
||||
private final EventException conveyedException;
|
||||
|
||||
/** Simple constructor.
|
||||
* @param conveyedException conveyed exception
|
||||
*/
|
||||
public ConveyedException(final EventException conveyedException) {
|
||||
this.conveyedException = conveyedException;
|
||||
}
|
||||
|
||||
/** Get the conveyed exception.
|
||||
* @return conveyed exception
|
||||
*/
|
||||
public EventException getConveyedException() {
|
||||
return conveyedException;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.linear.Array2DRowRealMatrix;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.sampling.NordsieckStepInterpolator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
@ -192,7 +192,7 @@ public class AdamsBashforthIntegrator extends AdamsIntegrator {
|
||||
public double integrate(final FirstOrderDifferentialEquations equations,
|
||||
final double t0, final double[] y0,
|
||||
final double t, final double[] y)
|
||||
throws MathUserException, IntegratorException {
|
||||
throws MathIllegalStateException, MathIllegalArgumentException {
|
||||
|
||||
final int n = y0.length;
|
||||
sanityChecks(equations, t0, y0, t, y);
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.linear.Array2DRowRealMatrix;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.MultistepIntegrator;
|
||||
|
||||
|
||||
@ -89,7 +89,7 @@ public abstract class AdamsIntegrator extends MultistepIntegrator {
|
||||
public abstract double integrate(final FirstOrderDifferentialEquations equations,
|
||||
final double t0, final double[] y0,
|
||||
final double t, final double[] y)
|
||||
throws MathUserException, IntegratorException;
|
||||
throws MathIllegalStateException, MathIllegalArgumentException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
|
@ -19,11 +19,11 @@ package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.linear.Array2DRowRealMatrix;
|
||||
import org.apache.commons.math.linear.RealMatrixPreservingVisitor;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.sampling.NordsieckStepInterpolator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
@ -209,7 +209,7 @@ public class AdamsMoultonIntegrator extends AdamsIntegrator {
|
||||
public double integrate(final FirstOrderDifferentialEquations equations,
|
||||
final double t0, final double[] y0,
|
||||
final double t, final double[] y)
|
||||
throws MathUserException, IntegratorException {
|
||||
throws MathIllegalStateException, MathIllegalArgumentException {
|
||||
|
||||
final int n = y0.length;
|
||||
sanityChecks(equations, t0, y0, t, y);
|
||||
|
@ -17,12 +17,15 @@
|
||||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.ode.AbstractIntegrator;
|
||||
import org.apache.commons.math.ode.ExtendedFirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
/**
|
||||
@ -218,13 +221,14 @@ public abstract class AdaptiveStepsizeIntegrator
|
||||
* @param y0 state vector at t0
|
||||
* @param t target time for the integration
|
||||
* @param y placeholder where to put the state vector
|
||||
* @exception IntegratorException if some inconsistency is detected
|
||||
* @exception DimensionMismatchException if some inconsistency is detected
|
||||
* @exception NumberIsTooSmallException if integration span is too small
|
||||
*/
|
||||
@Override
|
||||
protected void sanityChecks(final FirstOrderDifferentialEquations equations,
|
||||
final double t0, final double[] y0,
|
||||
final double t, final double[] y)
|
||||
throws IntegratorException {
|
||||
throws DimensionMismatchException, NumberIsTooSmallException {
|
||||
|
||||
super.sanityChecks(equations, t0, y0, t, y);
|
||||
|
||||
@ -235,13 +239,11 @@ public abstract class AdaptiveStepsizeIntegrator
|
||||
}
|
||||
|
||||
if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != mainSetDimension)) {
|
||||
throw new IntegratorException(
|
||||
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, mainSetDimension, vecAbsoluteTolerance.length);
|
||||
throw new DimensionMismatchException(mainSetDimension, vecAbsoluteTolerance.length);
|
||||
}
|
||||
|
||||
if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != mainSetDimension)) {
|
||||
throw new IntegratorException(
|
||||
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, mainSetDimension, vecRelativeTolerance.length);
|
||||
throw new DimensionMismatchException(mainSetDimension, vecRelativeTolerance.length);
|
||||
}
|
||||
|
||||
}
|
||||
@ -332,19 +334,18 @@ public abstract class AdaptiveStepsizeIntegrator
|
||||
* are silently increased up to this value, if false such small
|
||||
* steps generate an exception
|
||||
* @return a bounded integration step (h if no bound is reach, or a bounded value)
|
||||
* @exception IntegratorException if the step is too small and acceptSmall is false
|
||||
* @exception NumberIsTooSmallException if the step is too small and acceptSmall is false
|
||||
*/
|
||||
protected double filterStep(final double h, final boolean forward, final boolean acceptSmall)
|
||||
throws IntegratorException {
|
||||
throws MathIllegalArgumentException {
|
||||
|
||||
double filteredH = h;
|
||||
if (FastMath.abs(h) < minStep) {
|
||||
if (acceptSmall) {
|
||||
filteredH = forward ? minStep : -minStep;
|
||||
} else {
|
||||
throw new IntegratorException(
|
||||
LocalizedFormats.MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION,
|
||||
minStep, FastMath.abs(h));
|
||||
throw new NumberIsTooSmallException(LocalizedFormats.MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION,
|
||||
minStep, FastMath.abs(h), true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,7 +363,7 @@ public abstract class AdaptiveStepsizeIntegrator
|
||||
public abstract double integrate (FirstOrderDifferentialEquations equations,
|
||||
double t0, double[] y0,
|
||||
double t, double[] y)
|
||||
throws MathUserException, IntegratorException;
|
||||
throws MathIllegalStateException, MathIllegalArgumentException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
|
@ -17,9 +17,9 @@
|
||||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
@ -192,7 +192,7 @@ public abstract class EmbeddedRungeKuttaIntegrator
|
||||
public double integrate(final FirstOrderDifferentialEquations equations,
|
||||
final double t0, final double[] y0,
|
||||
final double t, final double[] y)
|
||||
throws MathUserException, IntegratorException {
|
||||
throws MathIllegalStateException, MathIllegalArgumentException {
|
||||
|
||||
sanityChecks(equations, t0, y0, t, y);
|
||||
setEquations(equations);
|
||||
|
@ -18,9 +18,10 @@
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.analysis.solvers.UnivariateRealSolver;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
@ -546,7 +547,7 @@ public class GraggBulirschStoerIntegrator extends AdaptiveStepsizeIntegrator {
|
||||
@Override
|
||||
public double integrate(final FirstOrderDifferentialEquations equations,
|
||||
final double t0, final double[] y0, final double t, final double[] y)
|
||||
throws MathUserException, IntegratorException {
|
||||
throws MathIllegalStateException, MathIllegalArgumentException {
|
||||
|
||||
sanityChecks(equations, t0, y0, t, y);
|
||||
setEquations(equations);
|
||||
|
@ -18,10 +18,10 @@
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.ode.AbstractIntegrator;
|
||||
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
@ -93,7 +93,7 @@ public abstract class RungeKuttaIntegrator extends AbstractIntegrator {
|
||||
public double integrate(final FirstOrderDifferentialEquations equations,
|
||||
final double t0, final double[] y0,
|
||||
final double t, final double[] y)
|
||||
throws MathUserException, IntegratorException {
|
||||
throws MathIllegalStateException, MathIllegalArgumentException {
|
||||
|
||||
sanityChecks(equations, t0, y0, t, y);
|
||||
setEquations(equations);
|
||||
|
@ -122,7 +122,7 @@ EVALUATIONS = \u00e9valuations
|
||||
MAX_COUNT_EXCEEDED = limite ({0}) d\u00e9pass\u00e9
|
||||
MAX_EVALUATIONS_EXCEEDED = nombre maximal d''\u00e9valuations ({0}) d\u00e9pass\u00e9
|
||||
MAX_ITERATIONS_EXCEEDED = nombre maximal d''it\u00e9rations ({0}) d\u00e9pass\u00e9
|
||||
MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION = pas minimal ({0,number,0.00E00}) atteint, l''int\u00e9gration n\u00e9cessite {1,number,0.00E00}
|
||||
MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION = pas minimal ({1,number,0.00E00}) atteint, l''int\u00e9gration n\u00e9cessite {0,number,0.00E00}
|
||||
MISMATCHED_LOESS_ABSCISSA_ORDINATE_ARRAYS = Loess a besoin de tableaux d'abscisses et d'oordonn\u00e9es de m\u00eame taille, mais il y a {0} points en abscisse et {1} en ordonn\u00e9e
|
||||
NAN_ELEMENT_AT_INDEX = l''\u00e9l\u00e9ment {0} est un NaN
|
||||
NAN_VALUE_CONVERSION = les valeurs NaN ne peuvent \u00eatre converties
|
||||
|
@ -52,6 +52,9 @@ The <action> type attribute can be add,update,fix,remove.
|
||||
If the output is not quite correct, check for invisible trailing spaces!
|
||||
-->
|
||||
<release version="3.0" date="TBD" description="TBD">
|
||||
<action dev="luc" type="update" issue="MATH-488" >
|
||||
Use the refactored exceptions framework for ODE.
|
||||
</action>
|
||||
<action dev="luc" type="add" >
|
||||
Added a getter to allow retrieving the exception related to an exception context
|
||||
provider.
|
||||
|
@ -20,9 +20,6 @@ package org.apache.commons.math.ode;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.nonstiff.DormandPrince54Integrator;
|
||||
import org.apache.commons.math.ode.nonstiff.DormandPrince853Integrator;
|
||||
import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
|
||||
@ -41,8 +38,7 @@ public class ContinuousOutputModelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoundaries()
|
||||
throws MathUserException, IntegratorException {
|
||||
public void testBoundaries() {
|
||||
integ.addStepHandler(new ContinuousOutputModel());
|
||||
integ.integrate(pb,
|
||||
pb.getInitialTime(), pb.getInitialState(),
|
||||
@ -54,8 +50,7 @@ public class ContinuousOutputModelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRandomAccess()
|
||||
throws MathUserException, IntegratorException {
|
||||
public void testRandomAccess() {
|
||||
|
||||
ContinuousOutputModel cm = new ContinuousOutputModel();
|
||||
integ.addStepHandler(cm);
|
||||
@ -84,8 +79,7 @@ public class ContinuousOutputModelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelsMerging()
|
||||
throws MathUserException, IntegratorException {
|
||||
public void testModelsMerging() {
|
||||
|
||||
// theoretical solution: y[0] = cos(t), y[1] = sin(t)
|
||||
FirstOrderDifferentialEquations problem =
|
||||
|
@ -17,10 +17,8 @@
|
||||
|
||||
package org.apache.commons.math.ode;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.FirstOrderConverter;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.SecondOrderDifferentialEquations;
|
||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.ode.nonstiff.ClassicalRungeKuttaIntegrator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
@ -39,8 +37,7 @@ public class FirstOrderConverterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecreasingSteps()
|
||||
throws MathUserException, IntegratorException {
|
||||
public void testDecreasingSteps() {
|
||||
|
||||
double previousError = Double.NaN;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
@ -57,16 +54,14 @@ public class FirstOrderConverterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSmallStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
public void testSmallStep() {
|
||||
double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, 1.0e-4)
|
||||
- FastMath.sin(4.0);
|
||||
Assert.assertTrue(FastMath.abs(error) < 1.0e-10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBigStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
public void testBigStep() {
|
||||
double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, 0.5)
|
||||
- FastMath.sin(4.0);
|
||||
Assert.assertTrue(FastMath.abs(error) > 0.1);
|
||||
@ -100,7 +95,7 @@ public class FirstOrderConverterTest {
|
||||
private double integrateWithSpecifiedStep(double omega,
|
||||
double t0, double t,
|
||||
double step)
|
||||
throws MathUserException, IntegratorException {
|
||||
throws MathIllegalStateException, MathIllegalArgumentException {
|
||||
double[] y0 = new double[2];
|
||||
y0[0] = FastMath.sin(omega * t0);
|
||||
y0[1] = omega * FastMath.cos(omega * t0);
|
||||
|
@ -18,9 +18,7 @@
|
||||
package org.apache.commons.math.ode.events;
|
||||
|
||||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.analysis.solvers.BrentSolver;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
|
||||
import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
|
||||
import org.junit.Assert;
|
||||
@ -30,8 +28,7 @@ public class EventStateTest {
|
||||
|
||||
// JIRA: MATH-322
|
||||
@Test
|
||||
public void closeEvents()
|
||||
throws EventException, ConvergenceException, MathUserException {
|
||||
public void closeEvents() {
|
||||
|
||||
final double r1 = 90.0;
|
||||
final double r2 = 135.0;
|
||||
|
@ -24,7 +24,6 @@ import org.apache.commons.math.analysis.solvers.PegasusSolver;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
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.nonstiff.DormandPrince853Integrator;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@ -48,12 +47,9 @@ public class OverlappingEventsTest implements FirstOrderDifferentialEquations {
|
||||
* calculations occur very close together instead. Uses event type 0. See
|
||||
* {@link org.apache.commons.math.ode.events.EventHandler#g(double, double[])
|
||||
* EventHandler.g(double, double[])}.
|
||||
* @throws EventException in case of event evaluation failure
|
||||
* @throws IntegratorException in case of integration failure
|
||||
* @throws MathUserException in case of derivative evaluation failure
|
||||
*/
|
||||
@Test
|
||||
public void testOverlappingEvents0() throws MathUserException, IntegratorException, EventException {
|
||||
public void testOverlappingEvents0() {
|
||||
test(0);
|
||||
}
|
||||
|
||||
@ -61,12 +57,9 @@ public class OverlappingEventsTest implements FirstOrderDifferentialEquations {
|
||||
* calculations occur very close together instead. Uses event type 1. See
|
||||
* {@link org.apache.commons.math.ode.events.EventHandler#g(double, double[])
|
||||
* EventHandler.g(double, double[])}.
|
||||
* @throws EventException in case of event evaluation failure
|
||||
* @throws IntegratorException in case of integration failure
|
||||
* @throws MathUserException in case of derivative evaluation failure
|
||||
*/
|
||||
@Test
|
||||
public void testOverlappingEvents1() throws MathUserException, IntegratorException, EventException {
|
||||
public void testOverlappingEvents1() {
|
||||
test(1);
|
||||
}
|
||||
|
||||
@ -75,11 +68,8 @@ public class OverlappingEventsTest implements FirstOrderDifferentialEquations {
|
||||
* @param eventType the type of events to use. See
|
||||
* {@link org.apache.commons.math.ode.events.EventHandler#g(double, double[])
|
||||
* EventHandler.g(double, double[])}.
|
||||
* @throws EventException in case of event evaluation failure
|
||||
* @throws IntegratorException in case of integration failure
|
||||
* @throws MathUserException in case of derivative evaluation failure
|
||||
*/
|
||||
public void test(int eventType) throws MathUserException, IntegratorException, EventException {
|
||||
public void test(int eventType) {
|
||||
double e = 1e-15;
|
||||
FirstOrderIntegrator integrator = new DormandPrince853Integrator(e, 100.0, 1e-7, 1e-7);
|
||||
BaseSecantSolver rootSolver = new PegasusSolver(e, e);
|
||||
@ -147,18 +137,18 @@ public class OverlappingEventsTest implements FirstOrderDifferentialEquations {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public double g(double t, double[] y) throws EventException {
|
||||
public double g(double t, double[] y) {
|
||||
return (eventType == 0) ? y[idx] >= 1.0 ? 1.0 : -1.0
|
||||
: y[idx] - 1.0;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public int eventOccurred(double t, double[] y, boolean increasing) throws EventException {
|
||||
public int eventOccurred(double t, double[] y, boolean increasing) {
|
||||
return STOP;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void resetState(double t, double[] y) throws EventException {
|
||||
public void resetState(double t, double[] y) {
|
||||
// Never called.
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,10 @@
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem5;
|
||||
import org.apache.commons.math.ode.TestProblem6;
|
||||
@ -31,8 +32,8 @@ import org.junit.Test;
|
||||
|
||||
public class AdamsBashforthIntegratorTest {
|
||||
|
||||
@Test(expected=IntegratorException.class)
|
||||
public void dimensionCheck() throws MathUserException, IntegratorException {
|
||||
@Test(expected=DimensionMismatchException.class)
|
||||
public void dimensionCheck() {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
FirstOrderIntegrator integ =
|
||||
new AdamsBashforthIntegrator(2, 0.0, 1.0, 1.0e-10, 1.0e-10);
|
||||
@ -41,8 +42,8 @@ public class AdamsBashforthIntegratorTest {
|
||||
1.0, new double[pb.getDimension()+10]);
|
||||
}
|
||||
|
||||
@Test(expected=IntegratorException.class)
|
||||
public void testMinStep() throws MathUserException, IntegratorException {
|
||||
@Test(expected=NumberIsTooSmallException.class)
|
||||
public void testMinStep() {
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double minStep = 0.1 * (pb.getFinalTime() - pb.getInitialTime());
|
||||
@ -63,7 +64,7 @@ public class AdamsBashforthIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testIncreasingTolerance()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
int previousCalls = Integer.MAX_VALUE;
|
||||
for (int i = -12; i < -5; ++i) {
|
||||
@ -99,7 +100,7 @@ public class AdamsBashforthIntegratorTest {
|
||||
}
|
||||
|
||||
@Test(expected = MathUserException.class)
|
||||
public void exceedMaxEvaluations() throws MathUserException, IntegratorException {
|
||||
public void exceedMaxEvaluations() {
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double range = pb.getFinalTime() - pb.getInitialTime();
|
||||
@ -115,7 +116,7 @@ public class AdamsBashforthIntegratorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void backward() throws MathUserException, IntegratorException {
|
||||
public void backward() {
|
||||
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
|
||||
@ -133,7 +134,7 @@ public class AdamsBashforthIntegratorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void polynomial() throws MathUserException, IntegratorException {
|
||||
public void polynomial() {
|
||||
TestProblem6 pb = new TestProblem6();
|
||||
double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
|
||||
|
||||
|
@ -18,9 +18,10 @@
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem5;
|
||||
import org.apache.commons.math.ode.TestProblem6;
|
||||
@ -31,8 +32,8 @@ import org.junit.Test;
|
||||
|
||||
public class AdamsMoultonIntegratorTest {
|
||||
|
||||
@Test(expected=IntegratorException.class)
|
||||
public void dimensionCheck() throws MathUserException, IntegratorException {
|
||||
@Test(expected=DimensionMismatchException.class)
|
||||
public void dimensionCheck() {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
FirstOrderIntegrator integ =
|
||||
new AdamsMoultonIntegrator(2, 0.0, 1.0, 1.0e-10, 1.0e-10);
|
||||
@ -41,8 +42,8 @@ public class AdamsMoultonIntegratorTest {
|
||||
1.0, new double[pb.getDimension()+10]);
|
||||
}
|
||||
|
||||
@Test(expected=IntegratorException.class)
|
||||
public void testMinStep() throws MathUserException, IntegratorException {
|
||||
@Test(expected=NumberIsTooSmallException.class)
|
||||
public void testMinStep() {
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double minStep = 0.1 * (pb.getFinalTime() - pb.getInitialTime());
|
||||
@ -63,7 +64,7 @@ public class AdamsMoultonIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testIncreasingTolerance()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
int previousCalls = Integer.MAX_VALUE;
|
||||
for (int i = -12; i < -2; ++i) {
|
||||
@ -99,7 +100,7 @@ public class AdamsMoultonIntegratorTest {
|
||||
}
|
||||
|
||||
@Test(expected = MathUserException.class)
|
||||
public void exceedMaxEvaluations() throws MathUserException, IntegratorException {
|
||||
public void exceedMaxEvaluations() {
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double range = pb.getFinalTime() - pb.getInitialTime();
|
||||
@ -115,7 +116,7 @@ public class AdamsMoultonIntegratorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void backward() throws MathUserException, IntegratorException {
|
||||
public void backward() {
|
||||
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
|
||||
@ -133,7 +134,7 @@ public class AdamsMoultonIntegratorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void polynomial() throws MathUserException, IntegratorException {
|
||||
public void polynomial() {
|
||||
TestProblem6 pb = new TestProblem6();
|
||||
double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
|
||||
|
||||
|
@ -18,10 +18,11 @@
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
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.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.TestProblem5;
|
||||
@ -29,7 +30,6 @@ import org.apache.commons.math.ode.TestProblemAbstract;
|
||||
import org.apache.commons.math.ode.TestProblemFactory;
|
||||
import org.apache.commons.math.ode.TestProblemHandler;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.nonstiff.ClassicalRungeKuttaIntegrator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
@ -39,7 +39,7 @@ import org.junit.Test;
|
||||
public class ClassicalRungeKuttaIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testMissedEndEvent() throws IntegratorException, MathUserException {
|
||||
public void testMissedEndEvent() {
|
||||
final double t0 = 1878250320.0000029;
|
||||
final double tEvent = 1878250379.9999986;
|
||||
final double[] k = { 1.0e-4, 1.0e-5, 1.0e-6 };
|
||||
@ -100,9 +100,7 @@ public class ClassicalRungeKuttaIntegratorTest {
|
||||
0.0, new double[pb.getDimension()+10],
|
||||
1.0, new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
} catch(DimensionMismatchException ie) {
|
||||
}
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
@ -110,9 +108,7 @@ public class ClassicalRungeKuttaIntegratorTest {
|
||||
0.0, new double[pb.getDimension()],
|
||||
1.0, new double[pb.getDimension()+10]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
} catch(DimensionMismatchException ie) {
|
||||
}
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
@ -120,15 +116,13 @@ public class ClassicalRungeKuttaIntegratorTest {
|
||||
0.0, new double[pb.getDimension()],
|
||||
0.0, new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
} catch(NumberIsTooSmallException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecreasingSteps()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
|
||||
for (int k = 0; k < problems.length; ++k) {
|
||||
@ -177,7 +171,7 @@ public class ClassicalRungeKuttaIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testSmallStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
@ -196,7 +190,7 @@ public class ClassicalRungeKuttaIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBigStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;
|
||||
@ -215,7 +209,7 @@ public class ClassicalRungeKuttaIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBackward()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
@ -234,7 +228,7 @@ public class ClassicalRungeKuttaIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testKepler()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
final TestProblem3 pb = new TestProblem3(0.9);
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
|
||||
@ -278,7 +272,7 @@ public class ClassicalRungeKuttaIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testStepSize()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
final double step = 1.23456;
|
||||
FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
|
||||
integ.addStepHandler(new StepHandler() {
|
||||
|
@ -25,9 +25,7 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
|
||||
@ -38,7 +36,7 @@ public class ClassicalRungeKuttaStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void derivativesConsistency()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
ClassicalRungeKuttaIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
|
||||
@ -47,8 +45,7 @@ public class ClassicalRungeKuttaStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void serialization()
|
||||
throws MathUserException, IntegratorException,
|
||||
IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
|
||||
|
@ -17,9 +17,10 @@
|
||||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.TestProblem4;
|
||||
@ -27,8 +28,6 @@ import org.apache.commons.math.ode.TestProblem5;
|
||||
import org.apache.commons.math.ode.TestProblemAbstract;
|
||||
import org.apache.commons.math.ode.TestProblemHandler;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.nonstiff.DormandPrince54Integrator;
|
||||
import org.apache.commons.math.ode.nonstiff.EmbeddedRungeKuttaIntegrator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
@ -38,26 +37,19 @@ import org.junit.Test;
|
||||
|
||||
public class DormandPrince54IntegratorTest {
|
||||
|
||||
@Test
|
||||
@Test(expected=DimensionMismatchException.class)
|
||||
public void testDimensionCheck() {
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
DormandPrince54Integrator integrator = new DormandPrince54Integrator(0.0, 1.0,
|
||||
1.0e-10, 1.0e-10);
|
||||
integrator.integrate(pb,
|
||||
0.0, new double[pb.getDimension()+10],
|
||||
1.0, new double[pb.getDimension()+10]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=NumberIsTooSmallException.class)
|
||||
public void testMinStep() {
|
||||
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double minStep = 0.1 * (pb.getFinalTime() - pb.getInitialTime());
|
||||
double maxStep = pb.getFinalTime() - pb.getInitialTime();
|
||||
@ -73,16 +65,12 @@ public class DormandPrince54IntegratorTest {
|
||||
pb.getInitialTime(), pb.getInitialState(),
|
||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSmallLastStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblemAbstract pb = new TestProblem5();
|
||||
double minStep = 1.25;
|
||||
@ -108,7 +96,7 @@ public class DormandPrince54IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBackward()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double minStep = 0;
|
||||
@ -159,7 +147,7 @@ public class DormandPrince54IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testIncreasingTolerance()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
int previousCalls = Integer.MAX_VALUE;
|
||||
for (int i = -12; i < -2; ++i) {
|
||||
@ -201,7 +189,7 @@ public class DormandPrince54IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testEvents()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem4 pb = new TestProblem4();
|
||||
double minStep = 0;
|
||||
@ -235,7 +223,7 @@ public class DormandPrince54IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testKepler()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
final TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
@ -258,7 +246,7 @@ public class DormandPrince54IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testVariableSteps()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
final TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
|
@ -27,7 +27,6 @@ import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
@ -40,7 +39,7 @@ public class DormandPrince54StepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void derivativesConsistency()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3(0.1);
|
||||
double minStep = 0;
|
||||
double maxStep = pb.getFinalTime() - pb.getInitialTime();
|
||||
@ -54,8 +53,7 @@ public class DormandPrince54StepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void serialization()
|
||||
throws MathUserException, IntegratorException,
|
||||
IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
@ -105,7 +103,7 @@ public class DormandPrince54StepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void checkClone()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
double maxStep = pb.getFinalTime() - pb.getInitialTime();
|
||||
|
@ -17,10 +17,11 @@
|
||||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
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.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.TestProblem4;
|
||||
@ -37,7 +38,7 @@ import org.junit.Test;
|
||||
public class DormandPrince853IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testMissedEndEvent() throws IntegratorException, MathUserException {
|
||||
public void testMissedEndEvent() {
|
||||
final double t0 = 1878250320.0000029;
|
||||
final double tEvent = 1878250379.9999986;
|
||||
final double[] k = { 1.0e-4, 1.0e-5, 1.0e-6 };
|
||||
@ -93,9 +94,8 @@ public class DormandPrince853IntegratorTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=DimensionMismatchException.class)
|
||||
public void testDimensionCheck() {
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
DormandPrince853Integrator integrator = new DormandPrince853Integrator(0.0, 1.0,
|
||||
1.0e-10, 1.0e-10);
|
||||
@ -103,15 +103,10 @@ public class DormandPrince853IntegratorTest {
|
||||
0.0, new double[pb.getDimension()+10],
|
||||
1.0, new double[pb.getDimension()+10]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=NumberIsTooSmallException.class)
|
||||
public void testNullIntervalCheck() {
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
DormandPrince853Integrator integrator = new DormandPrince853Integrator(0.0, 1.0,
|
||||
1.0e-10, 1.0e-10);
|
||||
@ -119,16 +114,11 @@ public class DormandPrince853IntegratorTest {
|
||||
0.0, new double[pb.getDimension()],
|
||||
0.0, new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=NumberIsTooSmallException.class)
|
||||
public void testMinStep() {
|
||||
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double minStep = 0.1 * (pb.getFinalTime() - pb.getInitialTime());
|
||||
double maxStep = pb.getFinalTime() - pb.getInitialTime();
|
||||
@ -144,16 +134,12 @@ public class DormandPrince853IntegratorTest {
|
||||
pb.getInitialTime(), pb.getInitialState(),
|
||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncreasingTolerance()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
int previousCalls = Integer.MAX_VALUE;
|
||||
AdaptiveStepsizeIntegrator integ =
|
||||
@ -190,7 +176,7 @@ public class DormandPrince853IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBackward()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double minStep = 0;
|
||||
@ -214,7 +200,7 @@ public class DormandPrince853IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testEvents()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem4 pb = new TestProblem4();
|
||||
double minStep = 0;
|
||||
@ -247,7 +233,7 @@ public class DormandPrince853IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testKepler()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
final TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
@ -270,7 +256,7 @@ public class DormandPrince853IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testVariableSteps()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
final TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
@ -291,7 +277,7 @@ public class DormandPrince853IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testUnstableDerivative()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
final StepProblem stepProblem = new StepProblem(0.0, 1.0, 2.0);
|
||||
FirstOrderIntegrator integ =
|
||||
new DormandPrince853Integrator(0.1, 10, 1.0e-12, 0.0);
|
||||
|
@ -27,7 +27,6 @@ import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
@ -40,7 +39,7 @@ public class DormandPrince853StepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void derivativesConsistency()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3(0.1);
|
||||
double minStep = 0;
|
||||
double maxStep = pb.getFinalTime() - pb.getInitialTime();
|
||||
@ -54,8 +53,7 @@ public class DormandPrince853StepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void serialization()
|
||||
throws MathUserException, IntegratorException,
|
||||
IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
@ -105,7 +103,7 @@ public class DormandPrince853StepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void checklone()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
double maxStep = pb.getFinalTime() - pb.getInitialTime();
|
||||
|
@ -18,17 +18,15 @@
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
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.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem5;
|
||||
import org.apache.commons.math.ode.TestProblemAbstract;
|
||||
import org.apache.commons.math.ode.TestProblemFactory;
|
||||
import org.apache.commons.math.ode.TestProblemHandler;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.nonstiff.EulerIntegrator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
@ -37,23 +35,18 @@ import org.junit.Test;
|
||||
|
||||
public class EulerIntegratorTest {
|
||||
|
||||
@Test
|
||||
@Test(expected=DimensionMismatchException.class)
|
||||
public void testDimensionCheck() {
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
new EulerIntegrator(0.01).integrate(pb,
|
||||
0.0, new double[pb.getDimension()+10],
|
||||
1.0, new double[pb.getDimension()+10]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecreasingSteps()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
|
||||
for (int k = 0; k < problems.length; ++k) {
|
||||
@ -99,7 +92,7 @@ public class EulerIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testSmallStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
@ -120,7 +113,7 @@ public class EulerIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBigStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;
|
||||
@ -140,7 +133,7 @@ public class EulerIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBackward()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
@ -159,7 +152,7 @@ public class EulerIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testStepSize()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
final double step = 1.23456;
|
||||
FirstOrderIntegrator integ = new EulerIntegrator(step);
|
||||
integ.addStepHandler(new StepHandler() {
|
||||
|
@ -27,7 +27,6 @@ import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
@ -39,7 +38,7 @@ import org.junit.Test;
|
||||
public class EulerStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void noReset() throws MathUserException {
|
||||
public void noReset() {
|
||||
|
||||
double[] y = { 0.0, 1.0, -2.0 };
|
||||
double[][] yDot = { { 1.0, 2.0, -2.0 } };
|
||||
@ -121,7 +120,7 @@ public class EulerStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void derivativesConsistency()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
EulerIntegrator integ = new EulerIntegrator(step);
|
||||
@ -130,8 +129,7 @@ public class EulerStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void serialization()
|
||||
throws MathUserException, IntegratorException,
|
||||
IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
|
@ -18,10 +18,10 @@
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
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.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.TestProblem5;
|
||||
@ -29,7 +29,6 @@ import org.apache.commons.math.ode.TestProblemAbstract;
|
||||
import org.apache.commons.math.ode.TestProblemFactory;
|
||||
import org.apache.commons.math.ode.TestProblemHandler;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.nonstiff.GillIntegrator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
@ -38,23 +37,18 @@ import org.junit.Test;
|
||||
|
||||
public class GillIntegratorTest {
|
||||
|
||||
@Test
|
||||
@Test(expected=DimensionMismatchException.class)
|
||||
public void testDimensionCheck() {
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
new GillIntegrator(0.01).integrate(pb,
|
||||
0.0, new double[pb.getDimension()+10],
|
||||
1.0, new double[pb.getDimension()+10]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecreasingSteps()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
|
||||
for (int k = 0; k < problems.length; ++k) {
|
||||
@ -100,7 +94,7 @@ public class GillIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testSmallStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
@ -120,7 +114,7 @@ public class GillIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBigStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;
|
||||
@ -139,7 +133,7 @@ public class GillIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBackward()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
@ -158,7 +152,7 @@ public class GillIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testKepler()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
final TestProblem3 pb = new TestProblem3(0.9);
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
|
||||
@ -172,7 +166,7 @@ public class GillIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testUnstableDerivative()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
final StepProblem stepProblem = new StepProblem(0.0, 1.0, 2.0);
|
||||
FirstOrderIntegrator integ = new GillIntegrator(0.3);
|
||||
integ.addEventHandler(stepProblem, 1.0, 1.0e-12, 1000);
|
||||
@ -213,7 +207,7 @@ public class GillIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testStepSize()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
final double step = 1.23456;
|
||||
FirstOrderIntegrator integ = new GillIntegrator(step);
|
||||
integ.addStepHandler(new StepHandler() {
|
||||
|
@ -18,18 +18,15 @@
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.nonstiff.GillIntegrator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
|
||||
import org.junit.Assert;
|
||||
@ -39,7 +36,7 @@ public class GillStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void testDerivativesConsistency()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
GillIntegrator integ = new GillIntegrator(step);
|
||||
@ -48,8 +45,7 @@ public class GillStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void serialization()
|
||||
throws MathUserException, IntegratorException,
|
||||
IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
|
||||
|
@ -17,10 +17,11 @@
|
||||
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
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.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.TestProblem4;
|
||||
@ -28,7 +29,6 @@ import org.apache.commons.math.ode.TestProblem5;
|
||||
import org.apache.commons.math.ode.TestProblemAbstract;
|
||||
import org.apache.commons.math.ode.TestProblemHandler;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.nonstiff.GraggBulirschStoerIntegrator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
@ -38,42 +38,29 @@ import org.junit.Test;
|
||||
|
||||
public class GraggBulirschStoerIntegratorTest {
|
||||
|
||||
@Test
|
||||
@Test(expected=DimensionMismatchException.class)
|
||||
public void testDimensionCheck() {
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
AdaptiveStepsizeIntegrator integrator =
|
||||
new GraggBulirschStoerIntegrator(0.0, 1.0, 1.0e-10, 1.0e-10);
|
||||
integrator.integrate(pb,
|
||||
0.0, new double[pb.getDimension()+10],
|
||||
1.0, new double[pb.getDimension()+10]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=NumberIsTooSmallException.class)
|
||||
public void testNullIntervalCheck() {
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
GraggBulirschStoerIntegrator integrator =
|
||||
new GraggBulirschStoerIntegrator(0.0, 1.0, 1.0e-10, 1.0e-10);
|
||||
integrator.integrate(pb,
|
||||
0.0, new double[pb.getDimension()],
|
||||
0.0, new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=NumberIsTooSmallException.class)
|
||||
public void testMinStep() {
|
||||
|
||||
try {
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double minStep = 0.1 * FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
|
||||
double maxStep = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
|
||||
@ -88,17 +75,12 @@ public class GraggBulirschStoerIntegratorTest {
|
||||
integ.integrate(pb,
|
||||
pb.getInitialTime(), pb.getInitialState(),
|
||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackward()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double minStep = 0;
|
||||
@ -122,7 +104,7 @@ public class GraggBulirschStoerIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testIncreasingTolerance()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
int previousCalls = Integer.MAX_VALUE;
|
||||
for (int i = -12; i < -4; ++i) {
|
||||
@ -160,7 +142,7 @@ public class GraggBulirschStoerIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testIntegratorControls()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem3 pb = new TestProblem3(0.999);
|
||||
GraggBulirschStoerIntegrator integ =
|
||||
@ -189,7 +171,7 @@ public class GraggBulirschStoerIntegratorTest {
|
||||
}
|
||||
|
||||
private double getMaxError(FirstOrderIntegrator integrator, TestProblemAbstract pb)
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblemHandler handler = new TestProblemHandler(pb, integrator);
|
||||
integrator.addStepHandler(handler);
|
||||
integrator.integrate(pb,
|
||||
@ -200,7 +182,7 @@ public class GraggBulirschStoerIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testEvents()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem4 pb = new TestProblem4();
|
||||
double minStep = 0;
|
||||
@ -233,7 +215,7 @@ public class GraggBulirschStoerIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testKepler()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
final TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
@ -256,7 +238,7 @@ public class GraggBulirschStoerIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testVariableSteps()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
final TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
@ -276,7 +258,7 @@ public class GraggBulirschStoerIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testUnstableDerivative()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
final StepProblem stepProblem = new StepProblem(0.0, 1.0, 2.0);
|
||||
FirstOrderIntegrator integ =
|
||||
new GraggBulirschStoerIntegrator(0.1, 10, 1.0e-12, 0.0);
|
||||
@ -287,7 +269,7 @@ public class GraggBulirschStoerIntegratorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIssue596() throws MathUserException, IntegratorException {
|
||||
public void testIssue596() {
|
||||
FirstOrderIntegrator integ = new GraggBulirschStoerIntegrator(1e-10, 100.0, 1e-7, 1e-7);
|
||||
integ.addStepHandler(new StepHandler() {
|
||||
|
||||
|
@ -27,7 +27,6 @@ import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
@ -40,7 +39,7 @@ public class GraggBulirschStoerStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void derivativesConsistency()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
double maxStep = pb.getFinalTime() - pb.getInitialTime();
|
||||
@ -55,8 +54,7 @@ public class GraggBulirschStoerStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void serialization()
|
||||
throws MathUserException, IntegratorException,
|
||||
IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
@ -107,7 +105,7 @@ public class GraggBulirschStoerStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void checklone()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
double maxStep = pb.getFinalTime() - pb.getInitialTime();
|
||||
|
@ -18,18 +18,18 @@
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
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.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.TestProblem4;
|
||||
import org.apache.commons.math.ode.TestProblem5;
|
||||
import org.apache.commons.math.ode.TestProblemHandler;
|
||||
import org.apache.commons.math.ode.events.EventException;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
@ -72,10 +72,9 @@ public class HighamHall54IntegratorTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=NumberIsTooSmallException.class)
|
||||
public void testMinStep() {
|
||||
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double minStep = 0.1 * (pb.getFinalTime() - pb.getInitialTime());
|
||||
double maxStep = pb.getFinalTime() - pb.getInitialTime();
|
||||
@ -91,16 +90,12 @@ public class HighamHall54IntegratorTest {
|
||||
pb.getInitialTime(), pb.getInitialState(),
|
||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncreasingTolerance()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
int previousCalls = Integer.MAX_VALUE;
|
||||
for (int i = -12; i < -2; ++i) {
|
||||
@ -136,7 +131,7 @@ public class HighamHall54IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBackward()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double minStep = 0;
|
||||
@ -160,7 +155,7 @@ public class HighamHall54IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testEvents()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem4 pb = new TestProblem4();
|
||||
double minStep = 0;
|
||||
@ -211,11 +206,11 @@ public class HighamHall54IntegratorTest {
|
||||
public int eventOccurred(double t, double[] y, boolean increasing) {
|
||||
return EventHandler.CONTINUE;
|
||||
}
|
||||
public double g(double t, double[] y) throws EventException {
|
||||
public double g(double t, double[] y) {
|
||||
double middle = (pb.getInitialTime() + pb.getFinalTime()) / 2;
|
||||
double offset = t - middle;
|
||||
if (offset > 0) {
|
||||
throw new EventException(LocalizedFormats.EVALUATION_FAILED, t);
|
||||
throw new MathUserException(LocalizedFormats.EVALUATION_FAILED, t);
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
@ -228,7 +223,7 @@ public class HighamHall54IntegratorTest {
|
||||
pb.getInitialTime(), pb.getInitialState(),
|
||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch (IntegratorException ie) {
|
||||
} catch (MathUserException ie) {
|
||||
// expected behavior
|
||||
}
|
||||
|
||||
@ -285,7 +280,7 @@ public class HighamHall54IntegratorTest {
|
||||
integ.integrate(pb, pb.getInitialTime(), new double[6],
|
||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch (IntegratorException ie) {
|
||||
} catch (DimensionMismatchException ie) {
|
||||
// expected behavior
|
||||
}
|
||||
|
||||
@ -295,7 +290,7 @@ public class HighamHall54IntegratorTest {
|
||||
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
|
||||
pb.getFinalTime(), new double[6]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch (IntegratorException ie) {
|
||||
} catch (DimensionMismatchException ie) {
|
||||
// expected behavior
|
||||
}
|
||||
|
||||
@ -305,7 +300,7 @@ public class HighamHall54IntegratorTest {
|
||||
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
|
||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch (IntegratorException ie) {
|
||||
} catch (DimensionMismatchException ie) {
|
||||
// expected behavior
|
||||
}
|
||||
|
||||
@ -315,7 +310,7 @@ public class HighamHall54IntegratorTest {
|
||||
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
|
||||
pb.getFinalTime(), new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch (IntegratorException ie) {
|
||||
} catch (DimensionMismatchException ie) {
|
||||
// expected behavior
|
||||
}
|
||||
|
||||
@ -325,7 +320,7 @@ public class HighamHall54IntegratorTest {
|
||||
integ.integrate(pb, pb.getInitialTime(), pb.getInitialState(),
|
||||
pb.getInitialTime(), new double[pb.getDimension()]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch (IntegratorException ie) {
|
||||
} catch (NumberIsTooSmallException ie) {
|
||||
// expected behavior
|
||||
}
|
||||
|
||||
@ -333,7 +328,7 @@ public class HighamHall54IntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testKepler()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
final TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
|
@ -27,7 +27,6 @@ import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
@ -40,7 +39,7 @@ public class HighamHall54StepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void derivativesConsistency()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3(0.1);
|
||||
double minStep = 0;
|
||||
double maxStep = pb.getFinalTime() - pb.getInitialTime();
|
||||
@ -54,8 +53,7 @@ public class HighamHall54StepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void serialization()
|
||||
throws MathUserException, IntegratorException,
|
||||
IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
@ -105,7 +103,7 @@ public class HighamHall54StepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void checkClone()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double minStep = 0;
|
||||
double maxStep = pb.getFinalTime() - pb.getInitialTime();
|
||||
|
@ -18,17 +18,15 @@
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
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.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem5;
|
||||
import org.apache.commons.math.ode.TestProblemAbstract;
|
||||
import org.apache.commons.math.ode.TestProblemFactory;
|
||||
import org.apache.commons.math.ode.TestProblemHandler;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.nonstiff.MidpointIntegrator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
@ -37,23 +35,18 @@ import org.junit.Test;
|
||||
|
||||
public class MidpointIntegratorTest {
|
||||
|
||||
@Test
|
||||
@Test(expected=DimensionMismatchException.class)
|
||||
public void testDimensionCheck() {
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
new MidpointIntegrator(0.01).integrate(pb,
|
||||
0.0, new double[pb.getDimension()+10],
|
||||
1.0, new double[pb.getDimension()+10]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecreasingSteps()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
|
||||
for (int k = 0; k < problems.length; ++k) {
|
||||
@ -99,7 +92,7 @@ public class MidpointIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testSmallStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
@ -120,7 +113,7 @@ public class MidpointIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBigStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;
|
||||
@ -140,7 +133,7 @@ public class MidpointIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBackward()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
@ -159,7 +152,7 @@ public class MidpointIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testStepSize()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
final double step = 1.23456;
|
||||
FirstOrderIntegrator integ = new MidpointIntegrator(step);
|
||||
integ.addStepHandler(new StepHandler() {
|
||||
|
@ -25,9 +25,7 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
@ -39,7 +37,7 @@ public class MidpointStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void testDerivativesConsistency()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
MidpointIntegrator integ = new MidpointIntegrator(step);
|
||||
@ -48,8 +46,7 @@ public class MidpointStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void serialization()
|
||||
throws MathUserException, IntegratorException,
|
||||
IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
|
@ -18,10 +18,10 @@
|
||||
package org.apache.commons.math.ode.nonstiff;
|
||||
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
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.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.TestProblem5;
|
||||
@ -29,7 +29,6 @@ import org.apache.commons.math.ode.TestProblemAbstract;
|
||||
import org.apache.commons.math.ode.TestProblemFactory;
|
||||
import org.apache.commons.math.ode.TestProblemHandler;
|
||||
import org.apache.commons.math.ode.events.EventHandler;
|
||||
import org.apache.commons.math.ode.nonstiff.ThreeEighthesIntegrator;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolator;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
@ -38,23 +37,18 @@ import org.junit.Test;
|
||||
|
||||
public class ThreeEighthesIntegratorTest {
|
||||
|
||||
@Test
|
||||
@Test(expected=DimensionMismatchException.class)
|
||||
public void testDimensionCheck() {
|
||||
try {
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
new ThreeEighthesIntegrator(0.01).integrate(pb,
|
||||
0.0, new double[pb.getDimension()+10],
|
||||
1.0, new double[pb.getDimension()+10]);
|
||||
Assert.fail("an exception should have been thrown");
|
||||
} catch(MathUserException de) {
|
||||
Assert.fail("wrong exception caught");
|
||||
} catch(IntegratorException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecreasingSteps()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblemAbstract[] problems = TestProblemFactory.getProblems();
|
||||
for (int k = 0; k < problems.length; ++k) {
|
||||
@ -100,7 +94,7 @@ public class ThreeEighthesIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testSmallStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
@ -120,7 +114,7 @@ public class ThreeEighthesIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBigStep()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.2;
|
||||
@ -139,7 +133,7 @@ public class ThreeEighthesIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testBackward()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
TestProblem5 pb = new TestProblem5();
|
||||
double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
@ -158,7 +152,7 @@ public class ThreeEighthesIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testKepler()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
|
||||
final TestProblem3 pb = new TestProblem3(0.9);
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
|
||||
@ -207,7 +201,7 @@ public class ThreeEighthesIntegratorTest {
|
||||
|
||||
@Test
|
||||
public void testStepSize()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
final double step = 1.23456;
|
||||
FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
|
||||
integ.addStepHandler(new StepHandler() {
|
||||
|
@ -25,9 +25,7 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.sampling.StepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
|
||||
@ -38,7 +36,7 @@ public class ThreeEighthesStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void derivativesConsistency()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
TestProblem3 pb = new TestProblem3();
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
|
||||
ThreeEighthesIntegrator integ = new ThreeEighthesIntegrator(step);
|
||||
@ -47,8 +45,7 @@ public class ThreeEighthesStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void serialization()
|
||||
throws MathUserException, IntegratorException,
|
||||
IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
TestProblem3 pb = new TestProblem3(0.9);
|
||||
double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
|
||||
|
@ -25,9 +25,7 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.ContinuousOutputModel;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem1;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.nonstiff.AdamsBashforthIntegrator;
|
||||
@ -37,8 +35,7 @@ import org.junit.Test;
|
||||
public class NordsieckStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void derivativesConsistency()
|
||||
throws MathUserException, IntegratorException {
|
||||
public void derivativesConsistency() {
|
||||
TestProblem3 pb = new TestProblem3();
|
||||
AdamsBashforthIntegrator integ = new AdamsBashforthIntegrator(4, 0.0, 1.0, 1.0e-10, 1.0e-10);
|
||||
StepInterpolatorTestUtils.checkDerivativesConsistency(integ, pb, 5e-9);
|
||||
@ -46,8 +43,7 @@ public class NordsieckStepInterpolatorTest {
|
||||
|
||||
@Test
|
||||
public void serialization()
|
||||
throws MathUserException, IntegratorException,
|
||||
IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
TestProblem1 pb = new TestProblem1();
|
||||
AdamsBashforthIntegrator integ = new AdamsBashforthIntegrator(4, 0.0, 1.0, 1.0e-10, 1.0e-10);
|
||||
|
@ -19,7 +19,6 @@ package org.apache.commons.math.ode.sampling;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblemAbstract;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
@ -28,8 +27,7 @@ public class StepInterpolatorTestUtils {
|
||||
|
||||
public static void checkDerivativesConsistency(final FirstOrderIntegrator integrator,
|
||||
final TestProblemAbstract problem,
|
||||
final double threshold)
|
||||
throws MathUserException, IntegratorException {
|
||||
final double threshold) {
|
||||
integrator.addStepHandler(new StepHandler() {
|
||||
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast)
|
||||
|
@ -8,7 +8,6 @@ import java.util.List;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
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.nonstiff.GraggBulirschStoerIntegrator;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -81,97 +80,97 @@ public abstract class StepNormalizerOutputTestBase
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncNeither() throws MathUserException, IntegratorException {
|
||||
public void testIncNeither() {
|
||||
double[] exp = getArray(getExpInc(), getO()[0][0], getO()[0][1]);
|
||||
doTest(StepNormalizerMode.INCREMENT, StepNormalizerBounds.NEITHER, exp, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncNeitherRev() throws MathUserException, IntegratorException {
|
||||
public void testIncNeitherRev() {
|
||||
double[] exp = getArray(getExpIncRev(), getO()[1][0], getO()[1][1]);
|
||||
doTest(StepNormalizerMode.INCREMENT, StepNormalizerBounds.NEITHER, exp, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncFirst() throws MathUserException, IntegratorException {
|
||||
public void testIncFirst() {
|
||||
double[] exp = getArray(getExpInc(), getO()[2][0], getO()[2][1]);
|
||||
doTest(StepNormalizerMode.INCREMENT, StepNormalizerBounds.FIRST, exp, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncFirstRev() throws MathUserException, IntegratorException {
|
||||
public void testIncFirstRev() {
|
||||
double[] exp = getArray(getExpIncRev(), getO()[3][0], getO()[3][1]);
|
||||
doTest(StepNormalizerMode.INCREMENT, StepNormalizerBounds.FIRST, exp, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncLast() throws MathUserException, IntegratorException {
|
||||
public void testIncLast() {
|
||||
double[] exp = getArray(getExpInc(), getO()[4][0], getO()[4][1]);
|
||||
doTest(StepNormalizerMode.INCREMENT, StepNormalizerBounds.LAST, exp, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncLastRev() throws MathUserException, IntegratorException {
|
||||
public void testIncLastRev() {
|
||||
double[] exp = getArray(getExpIncRev(), getO()[5][0], getO()[5][1]);
|
||||
doTest(StepNormalizerMode.INCREMENT, StepNormalizerBounds.LAST, exp, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncBoth() throws MathUserException, IntegratorException {
|
||||
public void testIncBoth() {
|
||||
double[] exp = getArray(getExpInc(), getO()[6][0], getO()[6][1]);
|
||||
doTest(StepNormalizerMode.INCREMENT, StepNormalizerBounds.BOTH, exp, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncBothRev() throws MathUserException, IntegratorException {
|
||||
public void testIncBothRev() {
|
||||
double[] exp = getArray(getExpIncRev(), getO()[7][0], getO()[7][1]);
|
||||
doTest(StepNormalizerMode.INCREMENT, StepNormalizerBounds.BOTH, exp, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMulNeither() throws MathUserException, IntegratorException {
|
||||
public void testMulNeither() {
|
||||
double[] exp = getArray(getExpMul(), getO()[8][0], getO()[8][1]);
|
||||
doTest(StepNormalizerMode.MULTIPLES, StepNormalizerBounds.NEITHER, exp, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMulNeitherRev() throws MathUserException, IntegratorException {
|
||||
public void testMulNeitherRev() {
|
||||
double[] exp = getArray(getExpMulRev(), getO()[9][0], getO()[9][1]);
|
||||
doTest(StepNormalizerMode.MULTIPLES, StepNormalizerBounds.NEITHER, exp, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMulFirst() throws MathUserException, IntegratorException {
|
||||
public void testMulFirst() {
|
||||
double[] exp = getArray(getExpMul(), getO()[10][0], getO()[10][1]);
|
||||
doTest(StepNormalizerMode.MULTIPLES, StepNormalizerBounds.FIRST, exp, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMulFirstRev() throws MathUserException, IntegratorException {
|
||||
public void testMulFirstRev() {
|
||||
double[] exp = getArray(getExpMulRev(), getO()[11][0], getO()[11][1]);
|
||||
doTest(StepNormalizerMode.MULTIPLES, StepNormalizerBounds.FIRST, exp, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMulLast() throws MathUserException, IntegratorException {
|
||||
public void testMulLast() {
|
||||
double[] exp = getArray(getExpMul(), getO()[12][0], getO()[12][1]);
|
||||
doTest(StepNormalizerMode.MULTIPLES, StepNormalizerBounds.LAST, exp, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMulLastRev() throws MathUserException, IntegratorException {
|
||||
public void testMulLastRev() {
|
||||
double[] exp = getArray(getExpMulRev(), getO()[13][0], getO()[13][1]);
|
||||
doTest(StepNormalizerMode.MULTIPLES, StepNormalizerBounds.LAST, exp, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMulBoth() throws MathUserException, IntegratorException {
|
||||
public void testMulBoth() {
|
||||
double[] exp = getArray(getExpMul(), getO()[14][0], getO()[14][1]);
|
||||
doTest(StepNormalizerMode.MULTIPLES, StepNormalizerBounds.BOTH, exp, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMulBothRev() throws MathUserException, IntegratorException {
|
||||
public void testMulBothRev() {
|
||||
double[] exp = getArray(getExpMulRev(), getO()[15][0], getO()[15][1]);
|
||||
doTest(StepNormalizerMode.MULTIPLES, StepNormalizerBounds.BOTH, exp, true);
|
||||
}
|
||||
@ -186,9 +185,7 @@ public abstract class StepNormalizerOutputTestBase
|
||||
* @param reverse whether to reverse the integration direction
|
||||
*/
|
||||
private void doTest(StepNormalizerMode mode, StepNormalizerBounds bounds,
|
||||
double[] expected, boolean reverse)
|
||||
throws MathUserException, IntegratorException
|
||||
{
|
||||
double[] expected, boolean reverse) {
|
||||
// Forward test.
|
||||
FirstOrderIntegrator integ = new GraggBulirschStoerIntegrator(
|
||||
1e-8, 1.0, 1e-5, 1e-5);
|
||||
|
@ -17,13 +17,9 @@
|
||||
|
||||
package org.apache.commons.math.ode.sampling;
|
||||
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.ode.FirstOrderIntegrator;
|
||||
import org.apache.commons.math.ode.IntegratorException;
|
||||
import org.apache.commons.math.ode.TestProblem3;
|
||||
import org.apache.commons.math.ode.nonstiff.DormandPrince54Integrator;
|
||||
import org.apache.commons.math.ode.sampling.FixedStepHandler;
|
||||
import org.apache.commons.math.ode.sampling.StepNormalizer;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
@ -40,7 +36,7 @@ public class StepNormalizerTest {
|
||||
|
||||
@Test
|
||||
public void testBoundaries()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
double range = pb.getFinalTime() - pb.getInitialTime();
|
||||
setLastSeen(false);
|
||||
integ.addStepHandler(new StepNormalizer(range / 10.0,
|
||||
@ -68,7 +64,7 @@ public class StepNormalizerTest {
|
||||
|
||||
@Test
|
||||
public void testBeforeEnd()
|
||||
throws MathUserException, IntegratorException {
|
||||
{
|
||||
final double range = pb.getFinalTime() - pb.getInitialTime();
|
||||
setLastSeen(false);
|
||||
integ.addStepHandler(new StepNormalizer(range / 10.5,
|
||||
|
Loading…
x
Reference in New Issue
Block a user