From faeb05ffdac2ef510e869dac062c5be86821e066 Mon Sep 17 00:00:00 2001 From: Hossein Pourbozorg Date: Sat, 31 Aug 2024 15:37:40 +0330 Subject: [PATCH 1/2] add `AlgorithmInterpretation` --- src/SciMLBase.jl | 2 ++ src/alg_traits.jl | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/SciMLBase.jl b/src/SciMLBase.jl index e36fb110f..c35a79802 100644 --- a/src/SciMLBase.jl +++ b/src/SciMLBase.jl @@ -839,4 +839,6 @@ export ContinuousCallback, DiscreteCallback, CallbackSet, VectorContinuousCallba export Clocks, TimeDomain, is_discrete_time_domain, isclock, issolverstepclock, iscontinuous +export AlgorithmInterpretation + end diff --git a/src/alg_traits.jl b/src/alg_traits.jl index 26eea7d69..ba7e9b614 100644 --- a/src/alg_traits.jl +++ b/src/alg_traits.jl @@ -244,17 +244,24 @@ function alg_order(alg::AbstractODEAlgorithm) error("Order is not defined for this algorithm") end +EnumX.@enumx AlgorithmInterpretation Ito Stratonovich + """ -Integral interpolation for the SDE solver algorithm. SDEs solutions depend on the chosen definition of the stochastic integral. In the Ito calculus, -the left-hand rule is taken, while Stratonovich calculus uses the right-hand rule. Unlike in standard Riemannian integration, these integral rules do -not converge to the same answer. In the context of a stochastic differential equation, the underlying solution (and its mean, variance, etc.) is dependent -on the integral rule that is chosen. This trait describes which interpretation the solver algorithm subscribes to, and thus whether the solution should + alg_interpretation(alg) + +Integral interpolation for the SDE solver algorithm. SDEs solutions depend on the chosen definition of the stochastic integral. In the Ito calculus, +the left-hand rule is taken, while Stratonovich calculus uses the right-hand rule. Unlike in standard Riemannian integration, these integral rules do +not converge to the same answer. In the context of a stochastic differential equation, the underlying solution (and its mean, variance, etc.) is dependent +on the integral rule that is chosen. This trait describes which interpretation the solver algorithm subscribes to, and thus whether the solution should be interpretated as the solution to the SDE under the Ito or Stratonovich interpretation. For more information, see https://oatml.cs.ox.ac.uk/blog/2022/03/22/ito-strat.html as a good high-level explanation. !!! note - The expected solution statistics are dependent on this output. Solutions from solvers with different + + The expected solution statistics are dependent on this output. Solutions from solvers with different interpretations are expected to have different answers on almost all SDEs without additive noise. """ -function alg_interpretation end +function alg_interpretation(alg::AbstractSciMLAlgorithm) + error("Algorithm interpretation is not defined for this algorithm. It can be either AlgorithmInterpretation.Ito or AlgorithmInterpretation.Stratonovich") +end From 4bf01f7f14866fae27f67f925bb2513796cac500 Mon Sep 17 00:00:00 2001 From: Hossein Pourbozorg Date: Sat, 31 Aug 2024 15:50:10 +0330 Subject: [PATCH 2/2] don't export internal api --- src/SciMLBase.jl | 2 -- src/alg_traits.jl | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/SciMLBase.jl b/src/SciMLBase.jl index c35a79802..e36fb110f 100644 --- a/src/SciMLBase.jl +++ b/src/SciMLBase.jl @@ -839,6 +839,4 @@ export ContinuousCallback, DiscreteCallback, CallbackSet, VectorContinuousCallba export Clocks, TimeDomain, is_discrete_time_domain, isclock, issolverstepclock, iscontinuous -export AlgorithmInterpretation - end diff --git a/src/alg_traits.jl b/src/alg_traits.jl index ba7e9b614..be7e23797 100644 --- a/src/alg_traits.jl +++ b/src/alg_traits.jl @@ -263,5 +263,5 @@ For more information, see https://oatml.cs.ox.ac.uk/blog/2022/03/22/ito-strat.ht interpretations are expected to have different answers on almost all SDEs without additive noise. """ function alg_interpretation(alg::AbstractSciMLAlgorithm) - error("Algorithm interpretation is not defined for this algorithm. It can be either AlgorithmInterpretation.Ito or AlgorithmInterpretation.Stratonovich") + error("Algorithm interpretation is not defined for this algorithm. It can be either `AlgorithmInterpretation.Ito` or `AlgorithmInterpretation.Stratonovich`") end