diff options
author | Karl Shaffer <karlshaffer@google.com> | 2023-08-11 00:04:18 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-08-11 00:04:18 +0000 |
commit | d3fac44428dd0296a04a50c6827e3205b8dbea8a (patch) | |
tree | ace24ba4307d4978ee3134f7da671a77ad172da0 /src/main/java/org/apache/commons/math3/ode/ODEIntegrator.java | |
parent | 5df6e262b13a4e2a008638ceea2b1f99db0d2331 (diff) | |
parent | 029d049e490dcd5fa609bb7632b0262d95f1bcce (diff) | |
download | apache-commons-math-android14-qpr2-s1-release.tar.gz |
Check-in commons-math 3.6.1 am: 1354beaf45 am: 0018f64b87 am: b3715644fb am: 5484895ffd am: 029d049e49HEADandroid-14.0.0_r37android-14.0.0_r36android-14.0.0_r35android-14.0.0_r34android-14.0.0_r33android-14.0.0_r32android-14.0.0_r31android-14.0.0_r30android-14.0.0_r29mastermainandroid14-qpr2-s5-releaseandroid14-qpr2-s4-releaseandroid14-qpr2-s3-releaseandroid14-qpr2-s2-releaseandroid14-qpr2-s1-releaseandroid14-qpr2-release
Original change: https://android-review.googlesource.com/c/platform/external/apache-commons-math/+/2702413
Change-Id: I6451550459c6d42417e3214f1db820289d799bc7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'src/main/java/org/apache/commons/math3/ode/ODEIntegrator.java')
-rw-r--r-- | src/main/java/org/apache/commons/math3/ode/ODEIntegrator.java | 185 |
1 files changed, 185 insertions, 0 deletions
diff --git a/src/main/java/org/apache/commons/math3/ode/ODEIntegrator.java b/src/main/java/org/apache/commons/math3/ode/ODEIntegrator.java new file mode 100644 index 0000000..f661960 --- /dev/null +++ b/src/main/java/org/apache/commons/math3/ode/ODEIntegrator.java @@ -0,0 +1,185 @@ +/* + * 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.math3.ode; + +import org.apache.commons.math3.analysis.solvers.UnivariateSolver; +import org.apache.commons.math3.ode.events.EventHandler; +import org.apache.commons.math3.ode.sampling.StepHandler; + +import java.util.Collection; + +/** + * This interface defines the common parts shared by integrators for first and second order + * differential equations. + * + * @see FirstOrderIntegrator + * @see SecondOrderIntegrator + * @since 2.0 + */ +public interface ODEIntegrator { + + /** + * Get the name of the method. + * + * @return name of the method + */ + String getName(); + + /** + * Add a step handler to this integrator. + * + * <p>The handler will be called by the integrator for each accepted step. + * + * @param handler handler for the accepted steps + * @see #getStepHandlers() + * @see #clearStepHandlers() + * @since 2.0 + */ + void addStepHandler(StepHandler handler); + + /** + * Get all the step handlers that have been added to the integrator. + * + * @return an unmodifiable collection of the added events handlers + * @see #addStepHandler(StepHandler) + * @see #clearStepHandlers() + * @since 2.0 + */ + Collection<StepHandler> getStepHandlers(); + + /** + * Remove all the step handlers that have been added to the integrator. + * + * @see #addStepHandler(StepHandler) + * @see #getStepHandlers() + * @since 2.0 + */ + void clearStepHandlers(); + + /** + * Add an event handler to the integrator. Uses a default {@link UnivariateSolver} with an + * absolute accuracy equal to the given convergence threshold, as root-finding algorithm to + * detect the state events. + * + * @param handler event handler + * @param maxCheckInterval maximal time interval between switching function checks (this + * interval prevents missing sign changes in case the integration steps becomes very large) + * @param convergence convergence threshold in the event time search + * @param maxIterationCount upper limit of the iteration count in the event time search + * @see #getEventHandlers() + * @see #clearEventHandlers() + */ + void addEventHandler( + EventHandler handler, + double maxCheckInterval, + double convergence, + int maxIterationCount); + + /** + * Add an event handler to the integrator. + * + * @param handler event handler + * @param maxCheckInterval maximal time interval between switching function checks (this + * interval prevents missing sign changes in case the integration steps becomes very large) + * @param convergence convergence threshold in the event time search + * @param maxIterationCount upper limit of the iteration count in the event time search + * @param solver The root-finding algorithm to use to detect the state events. + * @see #getEventHandlers() + * @see #clearEventHandlers() + */ + void addEventHandler( + EventHandler handler, + double maxCheckInterval, + double convergence, + int maxIterationCount, + UnivariateSolver solver); + + /** + * Get all the event handlers that have been added to the integrator. + * + * @return an unmodifiable collection of the added events handlers + * @see #addEventHandler(EventHandler, double, double, int) + * @see #clearEventHandlers() + */ + Collection<EventHandler> getEventHandlers(); + + /** + * Remove all the event handlers that have been added to the integrator. + * + * @see #addEventHandler(EventHandler, double, double, int) + * @see #getEventHandlers() + */ + void clearEventHandlers(); + + /** + * Get the current value of the step start time t<sub>i</sub>. + * + * <p>This method can be called during integration (typically by the object implementing the + * {@link FirstOrderDifferentialEquations differential equations} problem) if the value of the + * current step that is attempted is needed. + * + * <p>The result is undefined if the method is called outside of calls to <code>integrate</code> + * . + * + * @return current value of the step start time t<sub>i</sub> + */ + double getCurrentStepStart(); + + /** + * Get the current signed value of the integration stepsize. + * + * <p>This method can be called during integration (typically by the object implementing the + * {@link FirstOrderDifferentialEquations differential equations} problem) if the signed value + * of the current stepsize that is tried is needed. + * + * <p>The result is undefined if the method is called outside of calls to <code>integrate</code> + * . + * + * @return current signed value of the stepsize + */ + double getCurrentSignedStepsize(); + + /** + * Set the maximal number of differential equations function evaluations. + * + * <p>The purpose of this method is to avoid infinite loops which can occur for example when + * stringent error constraints are set or when lots of discrete events are triggered, thus + * leading to many rejected steps. + * + * @param maxEvaluations maximal number of function evaluations (negative values are silently + * converted to maximal integer value, thus representing almost unlimited evaluations) + */ + void setMaxEvaluations(int maxEvaluations); + + /** + * Get the maximal number of functions evaluations. + * + * @return maximal number of functions evaluations + */ + int getMaxEvaluations(); + + /** + * Get the number of evaluations of the differential equations function. + * + * <p>The number of evaluations corresponds to the last call to the <code>integrate</code> + * method. It is 0 if the method has not been called yet. + * + * @return number of evaluations of the differential equations function + */ + int getEvaluations(); +} |