From 3c1cfa8d354b2821dbf3c1b7edb7c054bfee9f93 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Fri, 25 Oct 2024 11:11:41 -0400 Subject: [PATCH 01/20] linear alias and ODEALias --- src/problems/linear_problems.jl | 9 +++++++++ src/problems/ode_problems.jl | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/problems/linear_problems.jl b/src/problems/linear_problems.jl index a723ee3f7..fd998acdc 100644 --- a/src/problems/linear_problems.jl +++ b/src/problems/linear_problems.jl @@ -76,3 +76,12 @@ function LinearProblem(A, b, args...; kwargs...) LinearProblem{isinplace(A, 4)}(A, b, args...; kwargs...) end end + +struct LinearAliases <: AbstractAliasSpecifier + alias_A::Union{Bool,Nothing} + alias_b::Union{Bool,Nothing} +end + +function LinearAliases(;alias_A = nothing, alias_b = nothing) + LinearAliases(alias_A, alias_b) +end \ No newline at end of file diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index bc9be9400..70497d5c2 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -511,3 +511,12 @@ function IncrementingODEProblem{iip}(f::IncrementingODEFunction, u0, tspan, p = NullParameters(); kwargs...) where {iip} ODEProblem(f, u0, tspan, p, IncrementingODEProblem{iip}(); kwargs...) end + + +struct ODEAliases <: AbstractAliasSpecifier + u0::Union{Bool,Nothing} +end + +function ODEAliases(;u0 = nothing) + ODEAliases(u0) +end \ No newline at end of file From 9ae74cb84e12fe785cb888311c1f92125c95ca2b Mon Sep 17 00:00:00 2001 From: jClugstor Date: Fri, 25 Oct 2024 11:12:00 -0400 Subject: [PATCH 02/20] abstract alias specifier --- src/SciMLBase.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/SciMLBase.jl b/src/SciMLBase.jl index f9636caa0..57d42dc82 100644 --- a/src/SciMLBase.jl +++ b/src/SciMLBase.jl @@ -642,6 +642,13 @@ abstract type ADOriginator end """ $(TYPEDEF) +Used to specify which elements can be aliased in a solve. +""" +abstract type AbstractAliasSpecifier end + +""" +$(TYPEDEF) + Internal. Used for signifying the AD context comes from a ChainRules.jl definition. """ struct ChainRulesOriginator <: ADOriginator end From c25bbd41e87799b2c2ac503ef2f5cf1ba15bf182 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Fri, 25 Oct 2024 11:53:04 -0400 Subject: [PATCH 03/20] add exports for new types --- src/SciMLBase.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SciMLBase.jl b/src/SciMLBase.jl index 57d42dc82..2ace751b2 100644 --- a/src/SciMLBase.jl +++ b/src/SciMLBase.jl @@ -870,4 +870,6 @@ export ContinuousCallback, DiscreteCallback, CallbackSet, VectorContinuousCallba export Clocks, TimeDomain, is_discrete_time_domain, isclock, issolverstepclock, iscontinuous +export ODEAliases, LinearAliases + end From 859b2165bbeb58aaf1f6ff2a361d8c19dfd6a149 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Fri, 25 Oct 2024 12:12:44 -0400 Subject: [PATCH 04/20] change kwarg name --- src/problems/ode_problems.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index 70497d5c2..88cb6b89b 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -514,9 +514,9 @@ end struct ODEAliases <: AbstractAliasSpecifier - u0::Union{Bool,Nothing} + alias_u0::Union{Bool,Nothing} end -function ODEAliases(;u0 = nothing) - ODEAliases(u0) +function ODEAliases(;alias_u0 = nothing) + ODEAliases(alias_u0) end \ No newline at end of file From 3266f37fcc54d31d0b725786483f17b6c8828f06 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Fri, 25 Oct 2024 15:13:30 -0400 Subject: [PATCH 05/20] add docs --- docs/src/interfaces/Common_Keywords.md | 4 ++-- src/problems/linear_problems.jl | 11 +++++++++++ src/problems/ode_problems.jl | 11 +++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/src/interfaces/Common_Keywords.md b/docs/src/interfaces/Common_Keywords.md index d0509722a..437a78861 100644 --- a/docs/src/interfaces/Common_Keywords.md +++ b/docs/src/interfaces/Common_Keywords.md @@ -101,8 +101,8 @@ Note that if a method does not have adaptivity, the following rules apply: ## Memory Optimizations - - `alias_u0`: allows the solver to alias the initial condition array that is contained - in the problem struct. Defaults to false. + - `alias`: an `ODEAliases` object that holds the field `alias_u0`, which allows the solver to alias the + initial condition array that is contained in the problem struct. Defaults to false. - `cache`: pass a solver cache to decrease the construction time. This is not implemented for any of the problem interfaces at this moment. diff --git a/src/problems/linear_problems.jl b/src/problems/linear_problems.jl index fd998acdc..e19458271 100644 --- a/src/problems/linear_problems.jl +++ b/src/problems/linear_problems.jl @@ -77,11 +77,22 @@ function LinearProblem(A, b, args...; kwargs...) end end +@doc doc""" + +Holds `alias_A` and `alias_b` which determine whether +to alias `A` and `b` when solving a `LinearProblem`. +""" struct LinearAliases <: AbstractAliasSpecifier alias_A::Union{Bool,Nothing} alias_b::Union{Bool,Nothing} end +""" + LinearAliases(;alias_A = nothing, alias_b = nothing) + +Creates a `LinearAliases` where `alias_A` and `alias_b` default to `nothing`. +When `alias_A` or `alias_b` is nothing, the default value of the solver is used. +""" function LinearAliases(;alias_A = nothing, alias_b = nothing) LinearAliases(alias_A, alias_b) end \ No newline at end of file diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index 88cb6b89b..46b72026b 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -512,11 +512,22 @@ function IncrementingODEProblem{iip}(f::IncrementingODEFunction, u0, tspan, ODEProblem(f, u0, tspan, p, IncrementingODEProblem{iip}(); kwargs...) end +@doc doc""" +Holds information on what variables to alias +when solving an ODE. The field `alias_u0` determines whether the initial condition +will be aliased when the ODE is solved. +""" struct ODEAliases <: AbstractAliasSpecifier alias_u0::Union{Bool,Nothing} end +""" + ODEAliases(;alias_u0 = nothing) + +Creates an `ODEAliases`, with a default `alias_u0` value of `nothing`. +When `alias_u0` is `nothing`, the solvers default to not aliasing `u0`. +""" function ODEAliases(;alias_u0 = nothing) ODEAliases(alias_u0) end \ No newline at end of file From 0a0649aaa7cc312e317a08afcba69e15c9c2b386 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Fri, 25 Oct 2024 15:44:02 -0400 Subject: [PATCH 06/20] update docs --- docs/src/interfaces/Common_Keywords.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/interfaces/Common_Keywords.md b/docs/src/interfaces/Common_Keywords.md index 437a78861..82e89a7a4 100644 --- a/docs/src/interfaces/Common_Keywords.md +++ b/docs/src/interfaces/Common_Keywords.md @@ -102,7 +102,8 @@ Note that if a method does not have adaptivity, the following rules apply: ## Memory Optimizations - `alias`: an `ODEAliases` object that holds the field `alias_u0`, which allows the solver to alias the - initial condition array that is contained in the problem struct. Defaults to false. + initial condition array that is contained in the problem struct. For example, tell the solver to alias `u0`, + `solve(prob,alias = ODEAliases(alias_u0 = true))`. Defaults to `ODEAliases(alias_u0 = false)`. - `cache`: pass a solver cache to decrease the construction time. This is not implemented for any of the problem interfaces at this moment. From 953b90b561d2cb85c686a6bb15710e635000f113 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Mon, 28 Oct 2024 15:59:44 -0400 Subject: [PATCH 07/20] change to ODEAliasSpecifier --- src/SciMLBase.jl | 2 +- src/problems/ode_problems.jl | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/SciMLBase.jl b/src/SciMLBase.jl index 2ace751b2..dae5b427b 100644 --- a/src/SciMLBase.jl +++ b/src/SciMLBase.jl @@ -870,6 +870,6 @@ export ContinuousCallback, DiscreteCallback, CallbackSet, VectorContinuousCallba export Clocks, TimeDomain, is_discrete_time_domain, isclock, issolverstepclock, iscontinuous -export ODEAliases, LinearAliases +export ODEAliasSpecifier, LinearAliases end diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index 46b72026b..1763dcdf3 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -518,8 +518,12 @@ Holds information on what variables to alias when solving an ODE. The field `alias_u0` determines whether the initial condition will be aliased when the ODE is solved. """ -struct ODEAliases <: AbstractAliasSpecifier +struct ODEAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool,Nothing} + alias_f::Union{Bool,Nothing} alias_u0::Union{Bool,Nothing} + alias_du0::Union{Bool,Nothing} + alias_tstops::Union{Bool,Nothing} end """ @@ -528,6 +532,12 @@ end Creates an `ODEAliases`, with a default `alias_u0` value of `nothing`. When `alias_u0` is `nothing`, the solvers default to not aliasing `u0`. """ -function ODEAliases(;alias_u0 = nothing) - ODEAliases(alias_u0) +function ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = nothing, alias = nothing) + if alias == true + ODEAliasSpecifier(true,true,true,true,true) + elseif alias == false + ODEAliasSpecifier(false, false, false, false, false) + elseif isnothing(alias) + ODEAliasSpecifier(alias_p,alias_f,alias_u0,alias_du0,alias_tstops) + end end \ No newline at end of file From 63590a1cab81fb211bc0846ba2b239926b9a2a5a Mon Sep 17 00:00:00 2001 From: jClugstor Date: Tue, 29 Oct 2024 14:55:07 -0400 Subject: [PATCH 08/20] add some more alias options --- src/SciMLBase.jl | 2 +- src/problems/linear_problems.jl | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/SciMLBase.jl b/src/SciMLBase.jl index dae5b427b..7b0495956 100644 --- a/src/SciMLBase.jl +++ b/src/SciMLBase.jl @@ -870,6 +870,6 @@ export ContinuousCallback, DiscreteCallback, CallbackSet, VectorContinuousCallba export Clocks, TimeDomain, is_discrete_time_domain, isclock, issolverstepclock, iscontinuous -export ODEAliasSpecifier, LinearAliases +export ODEAliasSpecifier, LinearAliasSpecifier end diff --git a/src/problems/linear_problems.jl b/src/problems/linear_problems.jl index e19458271..5715dd73d 100644 --- a/src/problems/linear_problems.jl +++ b/src/problems/linear_problems.jl @@ -82,17 +82,25 @@ end Holds `alias_A` and `alias_b` which determine whether to alias `A` and `b` when solving a `LinearProblem`. """ -struct LinearAliases <: AbstractAliasSpecifier +struct LinearAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool,Nothing} + alias_f::Union{Bool,Nothing} alias_A::Union{Bool,Nothing} alias_b::Union{Bool,Nothing} end """ - LinearAliases(;alias_A = nothing, alias_b = nothing) + LinearAliasSpecifier(;alias_A = nothing, alias_b = nothing) -Creates a `LinearAliases` where `alias_A` and `alias_b` default to `nothing`. +Creates a `LinearAliasSpecifier` where `alias_A` and `alias_b` default to `nothing`. When `alias_A` or `alias_b` is nothing, the default value of the solver is used. """ -function LinearAliases(;alias_A = nothing, alias_b = nothing) - LinearAliases(alias_A, alias_b) +function LinearAliasSpecifier(;alias_A = nothing, alias_b = nothing, alias_p = nothing, alias_f = nothing, alias = nothing) + if alias == true + LinearAliasSpecifier(true,true,true,true) + elseif alias == false + LinearAliasSpecifier(false,false,false,false) + elseif isnothing(alias) + LinearAliasSpecifier(alias_p, alias_f, alias_A, alias_b) + end end \ No newline at end of file From fb70e00e7ade62d8f3cabb7d7ee004f51b468fd7 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Wed, 30 Oct 2024 11:13:42 -0400 Subject: [PATCH 09/20] add AliasSpecifiers for more types --- src/problems/integral_problems.jl | 5 +++++ src/problems/nonlinear_problems.jl | 6 ++++++ src/problems/ode_problems.jl | 4 ++-- src/problems/optimization_problems.jl | 6 ++++++ src/problems/rode_problems.jl | 6 ++++++ src/problems/sdde_problems.jl | 5 +++++ src/problems/sde_problems.jl | 5 +++++ src/problems/steady_state_problems.jl | 5 +++++ 8 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/problems/integral_problems.jl b/src/problems/integral_problems.jl index b3087ae4b..b35193cca 100644 --- a/src/problems/integral_problems.jl +++ b/src/problems/integral_problems.jl @@ -167,3 +167,8 @@ struct SampledIntegralProblem{Y, X, K} <: AbstractIntegralProblem{false} new{typeof(y), typeof(x), typeof(kwargs)}(y, x, dim, kwargs) end end + +struct IntegralAliasSpecifier <: AbstractAliasSpecifier + alias_p + alias_f +end \ No newline at end of file diff --git a/src/problems/nonlinear_problems.jl b/src/problems/nonlinear_problems.jl index fe5448dba..132c17979 100644 --- a/src/problems/nonlinear_problems.jl +++ b/src/problems/nonlinear_problems.jl @@ -549,3 +549,9 @@ function SymbolicIndexingInterface.set_parameter!(prob::SCCNonlinearProblem, val set_parameter!(scc, val, idx) end end + + +struct NonlinearAliasSpecifier <: AbstractAliasSpecifier + alias_p + alias_f +end diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index 1763dcdf3..6cd96c67d 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -527,12 +527,12 @@ struct ODEAliasSpecifier <: AbstractAliasSpecifier end """ - ODEAliases(;alias_u0 = nothing) + ODEAliasSpecifier(;alias_u0 = nothing) Creates an `ODEAliases`, with a default `alias_u0` value of `nothing`. When `alias_u0` is `nothing`, the solvers default to not aliasing `u0`. """ -function ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = nothing, alias = nothing) +function ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) if alias == true ODEAliasSpecifier(true,true,true,true,true) elseif alias == false diff --git a/src/problems/optimization_problems.jl b/src/problems/optimization_problems.jl index b5e66482d..3441a4f80 100644 --- a/src/problems/optimization_problems.jl +++ b/src/problems/optimization_problems.jl @@ -154,3 +154,9 @@ end isinplace(f::OptimizationFunction{iip}) where {iip} = iip isinplace(f::OptimizationProblem{iip}) where {iip} = iip + +struct OptimizationAliasSpecifier <: AbstractAliasSpecifier + alias_p + alias_f + +end \ No newline at end of file diff --git a/src/problems/rode_problems.jl b/src/problems/rode_problems.jl index 479888f75..d529cb6b9 100644 --- a/src/problems/rode_problems.jl +++ b/src/problems/rode_problems.jl @@ -90,3 +90,9 @@ end function RODEProblem(f, u0, tspan, p = NullParameters(); kwargs...) RODEProblem(RODEFunction(f), u0, tspan, p; kwargs...) end + + +struct RODEAliasSpecifier <: AbstractAliasSpecifier + alias_p + alias_f +end \ No newline at end of file diff --git a/src/problems/sdde_problems.jl b/src/problems/sdde_problems.jl index abbee7c9a..a4a6427b5 100644 --- a/src/problems/sdde_problems.jl +++ b/src/problems/sdde_problems.jl @@ -173,3 +173,8 @@ function ConstructionBase.constructorof(::Type{P}) where {P <: SDDEProblem} end SymbolicIndexingInterface.get_history_function(prob::AbstractSDDEProblem) = prob.h + +struct SDDEAliasSpecifier + alias_p + alias_f +end \ No newline at end of file diff --git a/src/problems/sde_problems.jl b/src/problems/sde_problems.jl index 6592940a1..de12d2c4f 100644 --- a/src/problems/sde_problems.jl +++ b/src/problems/sde_problems.jl @@ -215,3 +215,8 @@ function DynamicalSDEProblem{iip}(f::DynamicalSDEFunction, v0, u0, tspan, end SDEProblem(_f, ArrayPartition(v0, u0), tspan, p; kwargs...) end + +struct SDEAliasSpecifier <: AbstractAliasSpecifier + alias_p + alias_f +end \ No newline at end of file diff --git a/src/problems/steady_state_problems.jl b/src/problems/steady_state_problems.jl index bec982820..e71444b76 100644 --- a/src/problems/steady_state_problems.jl +++ b/src/problems/steady_state_problems.jl @@ -121,3 +121,8 @@ Define a steady state problem from a standard ODE problem. function SteadyStateProblem(prob::AbstractODEProblem) SteadyStateProblem{isinplace(prob)}(prob.f, prob.u0, prob.p; prob.kwargs...) end + +struct SteadyStateAliasSpecifier <: AbstractAliasSpecifier + alias_p + alias_f +end \ No newline at end of file From e1e45fdbeb59b18bcf89434b37423379c89cb5b9 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Wed, 30 Oct 2024 11:40:43 -0400 Subject: [PATCH 10/20] add constructor for NonlinearAlias --- src/problems/nonlinear_problems.jl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/problems/nonlinear_problems.jl b/src/problems/nonlinear_problems.jl index 132c17979..0f211552c 100644 --- a/src/problems/nonlinear_problems.jl +++ b/src/problems/nonlinear_problems.jl @@ -552,6 +552,17 @@ end struct NonlinearAliasSpecifier <: AbstractAliasSpecifier - alias_p - alias_f + alias_p::Union{Bool,Nothing} + alias_f::Union{Bool,Nothing} + alias_u0::Union{Bool,Nothing} end + +function NonlinearAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) + if isnothing(alias) + NonlinearAliasSpecifier(alias_p, alias_f, alias_u0) + elseif alias + NonlinearAliasSpecifier(true, true, true) + elseif !alias + NonlinearAliasSpecifier(false, false, false) + end +end \ No newline at end of file From 343f6621ba987fc5e7a2a289f32f8d1057688085 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Wed, 30 Oct 2024 12:45:31 -0400 Subject: [PATCH 11/20] add better docs --- src/SciMLBase.jl | 3 ++- src/problems/ode_problems.jl | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/SciMLBase.jl b/src/SciMLBase.jl index 7b0495956..fc0fa2d78 100644 --- a/src/SciMLBase.jl +++ b/src/SciMLBase.jl @@ -642,7 +642,8 @@ abstract type ADOriginator end """ $(TYPEDEF) -Used to specify which elements can be aliased in a solve. +Used to specify which elements can be aliased in a solve. +Every concrete AbstractAliasSpecifier should have at least the fields `alias_p` and `alias_f`. """ abstract type AbstractAliasSpecifier end diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index 6cd96c67d..bcd376ec3 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -512,12 +512,7 @@ function IncrementingODEProblem{iip}(f::IncrementingODEFunction, u0, tspan, ODEProblem(f, u0, tspan, p, IncrementingODEProblem{iip}(); kwargs...) end -@doc doc""" -Holds information on what variables to alias -when solving an ODE. The field `alias_u0` determines whether the initial condition -will be aliased when the ODE is solved. -""" struct ODEAliasSpecifier <: AbstractAliasSpecifier alias_p::Union{Bool,Nothing} alias_f::Union{Bool,Nothing} @@ -526,13 +521,22 @@ struct ODEAliasSpecifier <: AbstractAliasSpecifier alias_tstops::Union{Bool,Nothing} end -""" - ODEAliasSpecifier(;alias_u0 = nothing) +@doc doc""" + +Holds information on what variables to alias +when solving an ODE. Conforms to the AbstractAliasSpecifier interface. + ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = false, alias = nothing) + +### Keywords +* `alias_p::Bool` +* `alias_f::Bool` +* `alias_u0::Bool = false`: alias the u0 array +* `alias_du0::Bool = false`: alias the du0 array for DAEs +* `alias_tstops::Bool = false`: alias the tstops array +* `alias::Bool`: sets all fields to `alias` -Creates an `ODEAliases`, with a default `alias_u0` value of `nothing`. -When `alias_u0` is `nothing`, the solvers default to not aliasing `u0`. """ -function ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) +function ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = false, alias = nothing) if alias == true ODEAliasSpecifier(true,true,true,true,true) elseif alias == false From b18b92fc185f0da3e87400955135cf9883a189b1 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Wed, 30 Oct 2024 14:03:22 -0400 Subject: [PATCH 12/20] update the docs --- src/SciMLBase.jl | 2 +- src/problems/linear_problems.jl | 17 ++++++++++------- src/problems/nonlinear_problems.jl | 11 +++++++++++ src/problems/ode_problems.jl | 10 +++++----- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/SciMLBase.jl b/src/SciMLBase.jl index fc0fa2d78..2e30d27a5 100644 --- a/src/SciMLBase.jl +++ b/src/SciMLBase.jl @@ -642,7 +642,7 @@ abstract type ADOriginator end """ $(TYPEDEF) -Used to specify which elements can be aliased in a solve. +Used to specify which variables can be aliased in a solve. Every concrete AbstractAliasSpecifier should have at least the fields `alias_p` and `alias_f`. """ abstract type AbstractAliasSpecifier end diff --git a/src/problems/linear_problems.jl b/src/problems/linear_problems.jl index 5715dd73d..ee9be75e3 100644 --- a/src/problems/linear_problems.jl +++ b/src/problems/linear_problems.jl @@ -77,11 +77,6 @@ function LinearProblem(A, b, args...; kwargs...) end end -@doc doc""" - -Holds `alias_A` and `alias_b` which determine whether -to alias `A` and `b` when solving a `LinearProblem`. -""" struct LinearAliasSpecifier <: AbstractAliasSpecifier alias_p::Union{Bool,Nothing} alias_f::Union{Bool,Nothing} @@ -89,8 +84,16 @@ struct LinearAliasSpecifier <: AbstractAliasSpecifier alias_b::Union{Bool,Nothing} end -""" - LinearAliasSpecifier(;alias_A = nothing, alias_b = nothing) +@doc doc""" + Holds information on what variables to alias when solving a `LinearProblem` + +### Keywords + +* `alias_p::Bool` +* `alias_f::Bool` +* `alias_A::Bool`: alias the `A` array. +* `alias_b::Bool`: alias the `b` array. +* `alias::Bool`: sets all fields of the `LinearAliasSpecifier` to `alias`. Creates a `LinearAliasSpecifier` where `alias_A` and `alias_b` default to `nothing`. When `alias_A` or `alias_b` is nothing, the default value of the solver is used. diff --git a/src/problems/nonlinear_problems.jl b/src/problems/nonlinear_problems.jl index 0f211552c..70cd5b169 100644 --- a/src/problems/nonlinear_problems.jl +++ b/src/problems/nonlinear_problems.jl @@ -557,6 +557,17 @@ struct NonlinearAliasSpecifier <: AbstractAliasSpecifier alias_u0::Union{Bool,Nothing} end +@doc doc""" + Holds information on what variables to alias when solving a `NonlinearProblem`. + +### Keywords + +* `alias_p::Bool` +* `alias_f::Bool` +* `alias_A::Bool`: alias the `A` array. +* `alias_b::Bool`: alias the `b` array. +* `alias::Bool`: sets all fields of the `LinearAliasSpecifier` to `alias`. +""" function NonlinearAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) if isnothing(alias) NonlinearAliasSpecifier(alias_p, alias_f, alias_u0) diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index bcd376ec3..1e3223ba1 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -530,13 +530,13 @@ when solving an ODE. Conforms to the AbstractAliasSpecifier interface. ### Keywords * `alias_p::Bool` * `alias_f::Bool` -* `alias_u0::Bool = false`: alias the u0 array -* `alias_du0::Bool = false`: alias the du0 array for DAEs -* `alias_tstops::Bool = false`: alias the tstops array -* `alias::Bool`: sets all fields to `alias` +* `alias_u0::Bool`: alias the u0 array. Defaults to false . +* `alias_du0::Bool`: alias the du0 array for DAEs. Defaults to false. +* `alias_tstops::Bool`: alias the tstops array +* `alias::Bool`: sets all fields of the `ODEAliasSpecifier` to `alias` """ -function ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = false, alias = nothing) +function ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) if alias == true ODEAliasSpecifier(true,true,true,true,true) elseif alias == false From 5c81a89754f818797990817e4aee91b66e90d177 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Tue, 12 Nov 2024 11:08:23 -0500 Subject: [PATCH 13/20] LinearProblems have no f or p --- src/problems/linear_problems.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/problems/linear_problems.jl b/src/problems/linear_problems.jl index ee9be75e3..8caea327f 100644 --- a/src/problems/linear_problems.jl +++ b/src/problems/linear_problems.jl @@ -78,8 +78,6 @@ function LinearProblem(A, b, args...; kwargs...) end struct LinearAliasSpecifier <: AbstractAliasSpecifier - alias_p::Union{Bool,Nothing} - alias_f::Union{Bool,Nothing} alias_A::Union{Bool,Nothing} alias_b::Union{Bool,Nothing} end From 990f4790caf25178eccb7ee7c222075861bf8064 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Wed, 11 Dec 2024 12:03:06 -0500 Subject: [PATCH 14/20] add OptimizationProblem AliasSpecifier --- src/problems/optimization_problems.jl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/problems/optimization_problems.jl b/src/problems/optimization_problems.jl index 3441a4f80..5feec83a3 100644 --- a/src/problems/optimization_problems.jl +++ b/src/problems/optimization_problems.jl @@ -158,5 +158,15 @@ isinplace(f::OptimizationProblem{iip}) where {iip} = iip struct OptimizationAliasSpecifier <: AbstractAliasSpecifier alias_p alias_f - + alias_u0 +end + +function OptimizationAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) + if alias == true + OptimizationAliasSpecifier(true, true, true, true, true) + elseif alias == false + OptimizationAliasSpecifier(false, false, false, false, false) + elseif isnothing(alias) + OptimizationAliasSpecifier(alias_p, alias_f, alias_u0, alias_tstops) + end end \ No newline at end of file From 081910e50c03ac0880555061e45b47709ea51b84 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Wed, 11 Dec 2024 12:08:44 -0500 Subject: [PATCH 15/20] add integral alias constructor --- src/problems/integral_problems.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/problems/integral_problems.jl b/src/problems/integral_problems.jl index b35193cca..80e15d712 100644 --- a/src/problems/integral_problems.jl +++ b/src/problems/integral_problems.jl @@ -171,4 +171,14 @@ end struct IntegralAliasSpecifier <: AbstractAliasSpecifier alias_p alias_f +end + +function IntegralAliasSpecifier(alias_p = nothing, alias_f = nothing, alias = nothing) + if alias == true + IntegralAliasSpecifier(true, true) + elseif alias == false + IntegralAliasSpecifier(false, false) + elseif isnothing(alias) + IntegralAliasSpecifier(alias_p, alias_f) + end end \ No newline at end of file From dcd70efb7441c92ebfd869b8530762e630f218f4 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Wed, 11 Dec 2024 13:54:07 -0500 Subject: [PATCH 16/20] Add AliasSpecifiers for more problem types --- src/problems/analytical_problems.jl | 34 ++++++++++++++++++++ src/problems/bvp_problems.jl | 36 ++++++++++++++++++++++ src/problems/dae_problems.jl | 36 ++++++++++++++++++++++ src/problems/dde_problems.jl | 34 ++++++++++++++++++++ src/problems/discrete_problems.jl | 31 +++++++++++++++++++ src/problems/implicit_discrete_problems.jl | 31 +++++++++++++++++++ src/problems/integral_problems.jl | 12 ++++++++ src/problems/linear_problems.jl | 13 ++++---- src/problems/nonlinear_problems.jl | 13 ++++---- src/problems/ode_problems.jl | 12 ++++---- src/problems/optimization_problems.jl | 18 +++++++++-- src/problems/rode_problems.jl | 30 ++++++++++++++++++ src/problems/sdde_problems.jl | 30 ++++++++++++++++++ src/problems/sde_problems.jl | 25 +++++++++++++++ src/problems/steady_state_problems.jl | 33 ++++++++++++++++++-- 15 files changed, 366 insertions(+), 22 deletions(-) diff --git a/src/problems/analytical_problems.jl b/src/problems/analytical_problems.jl index 0aed1af1c..937475df4 100644 --- a/src/problems/analytical_problems.jl +++ b/src/problems/analytical_problems.jl @@ -28,3 +28,37 @@ function AnalyticalProblem(f, u0, tspan, p = NullParameters(); kwargs...) end export AnalyticalProblem, AbstractAnalyticalProblem + +struct AnalyticalAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_du0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} +end + +@doc doc""" + +Holds information on what variables to alias +when solving an AnalyticalProblem. Conforms to the AbstractAliasSpecifier interface. + AnalyticalAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false. +* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array +* `alias::Union{Bool, Nothing}`: sets all fields of the `AnalyticalAliasSpecifier` to `alias` + +""" +function AnalyticalAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + AnalyticalAliasSpecifier(true, true, true, true, true) + elseif alias == false + AnalyticalAliasSpecifier(false, false, false, false, false) + elseif isnothing(alias) + AnalyticalAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end +end \ No newline at end of file diff --git a/src/problems/bvp_problems.jl b/src/problems/bvp_problems.jl index 49909a591..20536e2cd 100644 --- a/src/problems/bvp_problems.jl +++ b/src/problems/bvp_problems.jl @@ -438,3 +438,39 @@ function TwoPointSecondOrderBVProblem( u0 = [initialGuess(i) for i in tspan] return TwoPointSecondOrderBVProblem(f, bc, u0, (tspan[1], tspan[end]), p; kwargs...) end + + +struct BVPAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_du0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} +end + + +@doc doc""" + +Holds information on what variables to alias +when solving an BVP. Conforms to the AbstractAliasSpecifier interface. + BVPAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false. +* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array +* `alias::Union{Bool, Nothing}`: sets all fields of the `BVPAliasSpecifier` to `alias` + +""" +function BVPAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + BVPAliasSpecifier(true, true, true, true, true) + elseif alias == false + BVPAliasSpecifier(false, false, false, false, false) + elseif isnothing(alias) + BVPAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end +end \ No newline at end of file diff --git a/src/problems/dae_problems.jl b/src/problems/dae_problems.jl index 1755d29b1..2881f22ab 100644 --- a/src/problems/dae_problems.jl +++ b/src/problems/dae_problems.jl @@ -119,3 +119,39 @@ function ConstructionBase.constructorof(::Type{P}) where {P <: DAEProblem} return DAEProblem{iip}(f, du0, u0, tspan, p; differential_vars = dv, kw...) end end + + +struct DAEAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_du0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} +end + + +@doc doc""" + +Holds information on what variables to alias +when solving a DAE. Conforms to the AbstractAliasSpecifier interface. + DAEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false. +* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false. +* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array +* `alias::Union{Bool, Nothing}`: sets all fields of the `DAEAliasSpecifier` to `alias` + +""" +function DAEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + DAEAliasSpecifier(true, true, true, true, true) + elseif alias == false + DAEAliasSpecifier(false, false, false, false, false) + elseif isnothing(alias) + DAEAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end +end \ No newline at end of file diff --git a/src/problems/dde_problems.jl b/src/problems/dde_problems.jl index 641b1651b..88bc5c926 100644 --- a/src/problems/dde_problems.jl +++ b/src/problems/dde_problems.jl @@ -396,3 +396,37 @@ function SecondOrderDDEProblem(f::DynamicalDDEFunction, args...; kwargs...) kwargs...) end end + +struct DDEAliasSpecifier + alias_p + alias_f + alias_u0 + alias_tstops +end + + +@doc doc""" + +Holds information on what variables to alias +when solving a DDE. Conforms to the AbstractAliasSpecifier interface. + DDEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false. +* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array +* `alias::Union{Bool, Nothing}`: sets all fields of the `DDEAliasSpecifier` to `alias` + +""" +function DDEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + DDEAliasSpecifier(true, true, true, true, true) + elseif alias == false + DDEAliasSpecifier(false, false, false, false, false) + elseif isnothing(alias) + DDEAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end +end \ No newline at end of file diff --git a/src/problems/discrete_problems.jl b/src/problems/discrete_problems.jl index 8d89e4779..fbf10949b 100644 --- a/src/problems/discrete_problems.jl +++ b/src/problems/discrete_problems.jl @@ -153,3 +153,34 @@ function DiscreteProblem(u0::Union{AbstractArray, Number}, tspan::Tuple, end DiscreteProblem(f, u0, tspan, p; kwargs...) end + +struct DiscreteAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} +end + + +@doc doc""" + +Holds information on what variables to alias +when solving a DiscreteProblem. Conforms to the AbstractAliasSpecifier interface. + DiscreteAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias::Union{Bool, Nothing}`: sets all fields of the `DiscreteAliasSpecifier` to `alias` + +""" +function DiscreteAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias = nothing) + if alias == true + DiscreteAliasSpecifier(true, true, true, true, true) + elseif alias == false + DiscreteAliasAliasSpecifier(false, false, false, false, false) + elseif isnothing(alias) + DiscreteAliasSpecifier(alias_p, alias_f, alias_u0) + end +end \ No newline at end of file diff --git a/src/problems/implicit_discrete_problems.jl b/src/problems/implicit_discrete_problems.jl index 4df3e6ea7..6179219c5 100644 --- a/src/problems/implicit_discrete_problems.jl +++ b/src/problems/implicit_discrete_problems.jl @@ -119,3 +119,34 @@ function ImplicitDiscreteProblem(f, u0, tspan, p = NullParameters(); iip = isinplace(f, 6) ImplicitDiscreteProblem(ImplicitDiscreteFunction{iip}(f), u0, tspan, p; kwargs...) end + + +struct ImplicitDiscreteAliasSpecifier + alias_p::Union{Bool,Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} +end + +@doc doc""" + +Holds information on what variables to alias +when solving an ODE. Conforms to the AbstractAliasSpecifier interface. + DiscreteAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias::Union{Bool, Nothing}`: sets all fields of the `ImplicitDiscreteAliasSpecifier` to `alias` + +""" +function ImplicitDiscreteAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias = nothing) + if alias == true + ImplicitDiscreteAliasSpecifier(true, true, true, true, true) + elseif alias == false + ImplicitDiscreteAliasAliasSpecifier(false, false, false, false, false) + elseif isnothing(alias) + ImplicitDiscreteAliasSpecifier(alias_p, alias_f, alias_u0) + end +end \ No newline at end of file diff --git a/src/problems/integral_problems.jl b/src/problems/integral_problems.jl index 80e15d712..4b41f0854 100644 --- a/src/problems/integral_problems.jl +++ b/src/problems/integral_problems.jl @@ -173,6 +173,18 @@ struct IntegralAliasSpecifier <: AbstractAliasSpecifier alias_f end +@doc doc""" + +Holds information on what variables to alias +when solving an IntegralProblem. Conforms to the AbstractAliasSpecifier interface. + IntegralAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias::Union{Bool, Nothing}`: sets all fields of the `IntegralAliasSpecifier` to `alias` + +""" function IntegralAliasSpecifier(alias_p = nothing, alias_f = nothing, alias = nothing) if alias == true IntegralAliasSpecifier(true, true) diff --git a/src/problems/linear_problems.jl b/src/problems/linear_problems.jl index 8caea327f..44a9acbe2 100644 --- a/src/problems/linear_problems.jl +++ b/src/problems/linear_problems.jl @@ -83,15 +83,16 @@ struct LinearAliasSpecifier <: AbstractAliasSpecifier end @doc doc""" - Holds information on what variables to alias when solving a `LinearProblem` + Holds information on what variables to alias +when solving a LinearProblem. Conforms to the AbstractAliasSpecifier interface. ### Keywords -* `alias_p::Bool` -* `alias_f::Bool` -* `alias_A::Bool`: alias the `A` array. -* `alias_b::Bool`: alias the `b` array. -* `alias::Bool`: sets all fields of the `LinearAliasSpecifier` to `alias`. +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_A::Union{Bool, Nothing}`: alias the `A` array. +* `alias_b::Union{Bool, Nothing}`: alias the `b` array. +* `alias::Union{Bool, Nothing}`: sets all fields of the `LinearAliasSpecifier` to `alias`. Creates a `LinearAliasSpecifier` where `alias_A` and `alias_b` default to `nothing`. When `alias_A` or `alias_b` is nothing, the default value of the solver is used. diff --git a/src/problems/nonlinear_problems.jl b/src/problems/nonlinear_problems.jl index 70cd5b169..bfbf50671 100644 --- a/src/problems/nonlinear_problems.jl +++ b/src/problems/nonlinear_problems.jl @@ -558,15 +558,16 @@ struct NonlinearAliasSpecifier <: AbstractAliasSpecifier end @doc doc""" - Holds information on what variables to alias when solving a `NonlinearProblem`. + Holds information on what variables to alias when solving a `NonlinearProblem`. +Conforms to the AbstractAliasSpecifier interface. ### Keywords -* `alias_p::Bool` -* `alias_f::Bool` -* `alias_A::Bool`: alias the `A` array. -* `alias_b::Bool`: alias the `b` array. -* `alias::Bool`: sets all fields of the `LinearAliasSpecifier` to `alias`. +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_A::Union{Bool, Nothing}`: alias the `A` array. +* `alias_b::Union{Bool, Nothing}`: alias the `b` array. +* `alias::Union{Bool, Nothing}`: sets all fields of the `NonlinearAliasSpecifier` to `alias`. """ function NonlinearAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) if isnothing(alias) diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index 1e3223ba1..81574834e 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -528,12 +528,12 @@ when solving an ODE. Conforms to the AbstractAliasSpecifier interface. ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = false, alias = nothing) ### Keywords -* `alias_p::Bool` -* `alias_f::Bool` -* `alias_u0::Bool`: alias the u0 array. Defaults to false . -* `alias_du0::Bool`: alias the du0 array for DAEs. Defaults to false. -* `alias_tstops::Bool`: alias the tstops array -* `alias::Bool`: sets all fields of the `ODEAliasSpecifier` to `alias` +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false. +* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array +* `alias::Union{Bool, Nothing}`: sets all fields of the `ODEAliasSpecifier` to `alias` """ function ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) diff --git a/src/problems/optimization_problems.jl b/src/problems/optimization_problems.jl index 5feec83a3..aad085f08 100644 --- a/src/problems/optimization_problems.jl +++ b/src/problems/optimization_problems.jl @@ -161,11 +161,25 @@ struct OptimizationAliasSpecifier <: AbstractAliasSpecifier alias_u0 end + +@doc doc""" + +Holds information on what variables to alias +when solving an OptimizationProblem. Conforms to the AbstractAliasSpecifier interface. + OptimizationAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias::Union{Bool, Nothing}`: sets all fields of the `OptimizationAliasSpecifier` to `alias` + +""" function OptimizationAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) if alias == true - OptimizationAliasSpecifier(true, true, true, true, true) + OptimizationAliasSpecifier(true, true, true) elseif alias == false - OptimizationAliasSpecifier(false, false, false, false, false) + OptimizationAliasSpecifier(false, false, false) elseif isnothing(alias) OptimizationAliasSpecifier(alias_p, alias_f, alias_u0, alias_tstops) end diff --git a/src/problems/rode_problems.jl b/src/problems/rode_problems.jl index d529cb6b9..05221cd0b 100644 --- a/src/problems/rode_problems.jl +++ b/src/problems/rode_problems.jl @@ -95,4 +95,34 @@ end struct RODEAliasSpecifier <: AbstractAliasSpecifier alias_p alias_f + alias_u0 + alias_du0 + alias_tstops +end + + +@doc doc""" + +Holds information on what variables to alias +when solving an RODEProblem. Conforms to the AbstractAliasSpecifier interface. + ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = false, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false. +* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array +* `alias::Union{Bool, Nothing}`: sets all fields of the `RODEAliasSpecifier` to `alias` + +""" +function RODEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + RODEAliasSpecifier(true, true, true, true, true) + elseif alias == false + RODEAliasSpecifier(false, false, false, false, false) + elseif isnothing(alias) + RODEAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end end \ No newline at end of file diff --git a/src/problems/sdde_problems.jl b/src/problems/sdde_problems.jl index a4a6427b5..c2b4db2ac 100644 --- a/src/problems/sdde_problems.jl +++ b/src/problems/sdde_problems.jl @@ -177,4 +177,34 @@ SymbolicIndexingInterface.get_history_function(prob::AbstractSDDEProblem) = prob struct SDDEAliasSpecifier alias_p alias_f + alias_u0 + alias_tstops +end + + +@doc doc""" + +Holds information on what variables to alias +when solving an SDDEProblem. Conforms to the AbstractAliasSpecifier interface. + SDDEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array +* `alias::Union{Bool, Nothing}`: sets all fields of the `SDDEAliasSpecifier` to `alias` + + + +""" +function SDDEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + SDDEAliasSpecifier(true, true, true, true) + elseif alias == false + SDDEAliasSpecifier(false, false, false, false) + elseif isnothing(alias) + SDDEAliasSpecifier(alias_p, alias_f, alias_u0, alias_tstops) + end end \ No newline at end of file diff --git a/src/problems/sde_problems.jl b/src/problems/sde_problems.jl index de12d2c4f..6596708df 100644 --- a/src/problems/sde_problems.jl +++ b/src/problems/sde_problems.jl @@ -219,4 +219,29 @@ end struct SDEAliasSpecifier <: AbstractAliasSpecifier alias_p alias_f +end + +@doc doc""" + +Holds information on what variables to alias +when solving an SDEProblem. Conforms to the AbstractAliasSpecifier interface. + SDEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_tstops = nothing, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array +* `alias::Union{Bool, Nothing}`: sets all fields of the `SDEAliasSpecifier` to `alias` + +""" +function SDEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + SDDEAliasSpecifier(true, true, true, true, true) + elseif alias == false + SDDEAliasSpecifier(false, false, false, false, false) + elseif isnothing(alias) + SDDEAliasSpecifier(alias_p, alias_f, alias_u0, alias_tstops) + end end \ No newline at end of file diff --git a/src/problems/steady_state_problems.jl b/src/problems/steady_state_problems.jl index e71444b76..e8711f12f 100644 --- a/src/problems/steady_state_problems.jl +++ b/src/problems/steady_state_problems.jl @@ -123,6 +123,35 @@ function SteadyStateProblem(prob::AbstractODEProblem) end struct SteadyStateAliasSpecifier <: AbstractAliasSpecifier - alias_p - alias_f + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_du0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} +end + +@doc doc""" + +Holds information on what variables to alias +when solving a SteadyStateProblem. Conforms to the AbstractAliasSpecifier interface. + ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + +### Keywords +* `alias_p::Union{Bool, Nothing}` +* `alias_f::Union{Bool, Nothing}` +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false. +* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array +* `alias::Union{Bool, Nothing}`: sets all fields of the `SteadStateAliasSpecifier` to `alias` + +""" +function SteadyStateAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + SteadyStateAliasSpecifier(true, true, true, true, true) + elseif alias == false + SteadyStateAliasSpecifier(false, false, false, false, false) + elseif isnothing(alias) + SteadyStateAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end end \ No newline at end of file From b420a7be6ce1405af7e362713c32c5da9966195f Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 12 Dec 2024 11:40:41 -0500 Subject: [PATCH 17/20] update docstrings --- src/problems/analytical_problems.jl | 6 ++++-- src/problems/bvp_problems.jl | 4 +++- src/problems/dae_problems.jl | 4 +++- src/problems/dde_problems.jl | 4 +++- src/problems/discrete_problems.jl | 4 +++- src/problems/implicit_discrete_problems.jl | 4 +++- src/problems/integral_problems.jl | 4 +++- src/problems/linear_problems.jl | 5 ++++- src/problems/nonlinear_problems.jl | 8 +++++--- src/problems/ode_problems.jl | 4 +++- src/problems/optimization_problems.jl | 2 +- src/problems/rode_problems.jl | 4 +++- src/problems/sdde_problems.jl | 4 +++- src/problems/sde_problems.jl | 4 +++- src/problems/steady_state_problems.jl | 4 +++- 15 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/problems/analytical_problems.jl b/src/problems/analytical_problems.jl index 937475df4..c7b4a8f57 100644 --- a/src/problems/analytical_problems.jl +++ b/src/problems/analytical_problems.jl @@ -41,12 +41,14 @@ end Holds information on what variables to alias when solving an AnalyticalProblem. Conforms to the AbstractAliasSpecifier interface. - AnalyticalAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + `AnalyticalAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing)` +When a keyword argument is `nothing`, the default behaviour of the solver is used. + ### Keywords * `alias_p::Union{Bool, Nothing}` * `alias_f::Union{Bool, Nothing}` -* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false . +* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. * `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false. * `alias_tstops::Union{Bool, Nothing}`: alias the tstops array * `alias::Union{Bool, Nothing}`: sets all fields of the `AnalyticalAliasSpecifier` to `alias` diff --git a/src/problems/bvp_problems.jl b/src/problems/bvp_problems.jl index 20536e2cd..a493807aa 100644 --- a/src/problems/bvp_problems.jl +++ b/src/problems/bvp_problems.jl @@ -453,7 +453,9 @@ end Holds information on what variables to alias when solving an BVP. Conforms to the AbstractAliasSpecifier interface. - BVPAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + `BVPAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` diff --git a/src/problems/dae_problems.jl b/src/problems/dae_problems.jl index 2881f22ab..c613722e5 100644 --- a/src/problems/dae_problems.jl +++ b/src/problems/dae_problems.jl @@ -134,7 +134,9 @@ end Holds information on what variables to alias when solving a DAE. Conforms to the AbstractAliasSpecifier interface. - DAEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + `DAEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` diff --git a/src/problems/dde_problems.jl b/src/problems/dde_problems.jl index 88bc5c926..9441ad264 100644 --- a/src/problems/dde_problems.jl +++ b/src/problems/dde_problems.jl @@ -409,7 +409,9 @@ end Holds information on what variables to alias when solving a DDE. Conforms to the AbstractAliasSpecifier interface. - DDEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + `DDEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` diff --git a/src/problems/discrete_problems.jl b/src/problems/discrete_problems.jl index fbf10949b..f8b89e258 100644 --- a/src/problems/discrete_problems.jl +++ b/src/problems/discrete_problems.jl @@ -165,7 +165,9 @@ end Holds information on what variables to alias when solving a DiscreteProblem. Conforms to the AbstractAliasSpecifier interface. - DiscreteAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) + `DiscreteAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` diff --git a/src/problems/implicit_discrete_problems.jl b/src/problems/implicit_discrete_problems.jl index 6179219c5..7d116da45 100644 --- a/src/problems/implicit_discrete_problems.jl +++ b/src/problems/implicit_discrete_problems.jl @@ -131,7 +131,9 @@ end Holds information on what variables to alias when solving an ODE. Conforms to the AbstractAliasSpecifier interface. - DiscreteAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) + `DiscreteAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` diff --git a/src/problems/integral_problems.jl b/src/problems/integral_problems.jl index 4b41f0854..d04ad5e2d 100644 --- a/src/problems/integral_problems.jl +++ b/src/problems/integral_problems.jl @@ -177,7 +177,9 @@ end Holds information on what variables to alias when solving an IntegralProblem. Conforms to the AbstractAliasSpecifier interface. - IntegralAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) + `IntegralAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing)`` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` diff --git a/src/problems/linear_problems.jl b/src/problems/linear_problems.jl index 44a9acbe2..873cf11be 100644 --- a/src/problems/linear_problems.jl +++ b/src/problems/linear_problems.jl @@ -83,8 +83,11 @@ struct LinearAliasSpecifier <: AbstractAliasSpecifier end @doc doc""" - Holds information on what variables to alias +Holds information on what variables to alias when solving a LinearProblem. Conforms to the AbstractAliasSpecifier interface. + `LinearAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_A = nothing, alias_b = nothing, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords diff --git a/src/problems/nonlinear_problems.jl b/src/problems/nonlinear_problems.jl index bfbf50671..01b1ff881 100644 --- a/src/problems/nonlinear_problems.jl +++ b/src/problems/nonlinear_problems.jl @@ -558,15 +558,17 @@ struct NonlinearAliasSpecifier <: AbstractAliasSpecifier end @doc doc""" - Holds information on what variables to alias when solving a `NonlinearProblem`. +Holds information on what variables to alias when solving a `NonlinearProblem`. Conforms to the AbstractAliasSpecifier interface. + `NonlinearAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` * `alias_f::Union{Bool, Nothing}` -* `alias_A::Union{Bool, Nothing}`: alias the `A` array. -* `alias_b::Union{Bool, Nothing}`: alias the `b` array. +* `alias_u0::Union{Bool, Nothing}`: alias the `u0` array. * `alias::Union{Bool, Nothing}`: sets all fields of the `NonlinearAliasSpecifier` to `alias`. """ function NonlinearAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index 81574834e..bd9885b80 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -525,7 +525,9 @@ end Holds information on what variables to alias when solving an ODE. Conforms to the AbstractAliasSpecifier interface. - ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = false, alias = nothing) + `ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = false, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` diff --git a/src/problems/optimization_problems.jl b/src/problems/optimization_problems.jl index aad085f08..74a66b3a3 100644 --- a/src/problems/optimization_problems.jl +++ b/src/problems/optimization_problems.jl @@ -166,7 +166,7 @@ end Holds information on what variables to alias when solving an OptimizationProblem. Conforms to the AbstractAliasSpecifier interface. - OptimizationAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias = nothing) + `OptimizationAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias = nothing)` ### Keywords * `alias_p::Union{Bool, Nothing}` diff --git a/src/problems/rode_problems.jl b/src/problems/rode_problems.jl index 05221cd0b..b7c63b3bd 100644 --- a/src/problems/rode_problems.jl +++ b/src/problems/rode_problems.jl @@ -105,7 +105,9 @@ end Holds information on what variables to alias when solving an RODEProblem. Conforms to the AbstractAliasSpecifier interface. - ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = false, alias = nothing) + `RODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = false, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` diff --git a/src/problems/sdde_problems.jl b/src/problems/sdde_problems.jl index c2b4db2ac..38c212903 100644 --- a/src/problems/sdde_problems.jl +++ b/src/problems/sdde_problems.jl @@ -186,7 +186,9 @@ end Holds information on what variables to alias when solving an SDDEProblem. Conforms to the AbstractAliasSpecifier interface. - SDDEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + `SDDEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` diff --git a/src/problems/sde_problems.jl b/src/problems/sde_problems.jl index 6596708df..4bfa93c56 100644 --- a/src/problems/sde_problems.jl +++ b/src/problems/sde_problems.jl @@ -225,7 +225,9 @@ end Holds information on what variables to alias when solving an SDEProblem. Conforms to the AbstractAliasSpecifier interface. - SDEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_tstops = nothing, alias = nothing) + `SDEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_tstops = nothing, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` diff --git a/src/problems/steady_state_problems.jl b/src/problems/steady_state_problems.jl index e8711f12f..0e025c854 100644 --- a/src/problems/steady_state_problems.jl +++ b/src/problems/steady_state_problems.jl @@ -134,7 +134,9 @@ end Holds information on what variables to alias when solving a SteadyStateProblem. Conforms to the AbstractAliasSpecifier interface. - ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + `SteadyStateAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing)` + +When a keyword argument is `nothing`, the default behaviour of the solver is used. ### Keywords * `alias_p::Union{Bool, Nothing}` From ead4d02dae386ebf2d903ed8603f75a19b6b7229 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 12 Dec 2024 11:57:09 -0500 Subject: [PATCH 18/20] better docs for AliasSpecifiers --- docs/src/interfaces/Common_Keywords.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/src/interfaces/Common_Keywords.md b/docs/src/interfaces/Common_Keywords.md index 82e89a7a4..d778ff904 100644 --- a/docs/src/interfaces/Common_Keywords.md +++ b/docs/src/interfaces/Common_Keywords.md @@ -101,9 +101,12 @@ Note that if a method does not have adaptivity, the following rules apply: ## Memory Optimizations - - `alias`: an `ODEAliases` object that holds the field `alias_u0`, which allows the solver to alias the - initial condition array that is contained in the problem struct. For example, tell the solver to alias `u0`, - `solve(prob,alias = ODEAliases(alias_u0 = true))`. Defaults to `ODEAliases(alias_u0 = false)`. + - `alias`: an `AbstractAliasSpecifier` object that holds fields specifying which variables to alias + when solving. For example, to tell an ODE solver to alias the `u0` array, you can use an `ODEAliases` object, + and the `alias_u0` keyword argument, e.g. `solve(prob,alias = ODEAliases(alias_u0 = true))`. The fields of + every `AbstractAliasSpecifier` default to `nothing`, which tells the solver to use its default behavior. + For more information on what can be aliased for each problem type, see the documentation for the `AbstractAliasSpecifier` + associated with that problem type. - `cache`: pass a solver cache to decrease the construction time. This is not implemented for any of the problem interfaces at this moment. From 02c630093845a8287095a40ad97ef4d4faab2bcb Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 12 Dec 2024 12:04:18 -0500 Subject: [PATCH 19/20] more alias explanation --- docs/src/interfaces/Common_Keywords.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/interfaces/Common_Keywords.md b/docs/src/interfaces/Common_Keywords.md index d778ff904..63061fad8 100644 --- a/docs/src/interfaces/Common_Keywords.md +++ b/docs/src/interfaces/Common_Keywords.md @@ -103,10 +103,10 @@ Note that if a method does not have adaptivity, the following rules apply: - `alias`: an `AbstractAliasSpecifier` object that holds fields specifying which variables to alias when solving. For example, to tell an ODE solver to alias the `u0` array, you can use an `ODEAliases` object, - and the `alias_u0` keyword argument, e.g. `solve(prob,alias = ODEAliases(alias_u0 = true))`. The fields of - every `AbstractAliasSpecifier` default to `nothing`, which tells the solver to use its default behavior. + and the `alias_u0` keyword argument, e.g. `solve(prob,alias = ODEAliases(alias_u0 = true))`. For more information on what can be aliased for each problem type, see the documentation for the `AbstractAliasSpecifier` - associated with that problem type. + associated with that problem type. Set to `true` to alias every variable possible, or to `false` to disable aliasing. + Defaults to an `AbstractAliasSpecifier` instance with `nothing` for all fields, which tells the solver to use the default behavior. - `cache`: pass a solver cache to decrease the construction time. This is not implemented for any of the problem interfaces at this moment. From a698ec104678aad71951bd5d1d114b65fdf29535 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 12 Dec 2024 12:54:26 -0500 Subject: [PATCH 20/20] make inner so there's no overriding --- src/problems/analytical_problems.jl | 36 +++++++++++--------- src/problems/bvp_problems.jl | 39 +++++++++++----------- src/problems/dae_problems.jl | 39 +++++++++++----------- src/problems/dde_problems.jl | 34 ++++++++++--------- src/problems/discrete_problems.jl | 35 ++++++++++--------- src/problems/implicit_discrete_problems.jl | 34 ++++++++++--------- src/problems/integral_problems.jl | 28 ++++++++-------- src/problems/linear_problems.jl | 29 ++++++++-------- src/problems/nonlinear_problems.jl | 32 +++++++++--------- src/problems/ode_problems.jl | 35 +++++++++---------- src/problems/optimization_problems.jl | 33 +++++++++--------- src/problems/rode_problems.jl | 38 +++++++++++---------- src/problems/sdde_problems.jl | 38 ++++++++++----------- src/problems/sde_problems.jl | 32 ++++++++++-------- src/problems/steady_state_problems.jl | 37 ++++++++++---------- 15 files changed, 276 insertions(+), 243 deletions(-) diff --git a/src/problems/analytical_problems.jl b/src/problems/analytical_problems.jl index c7b4a8f57..26ec6bd89 100644 --- a/src/problems/analytical_problems.jl +++ b/src/problems/analytical_problems.jl @@ -29,13 +29,6 @@ end export AnalyticalProblem, AbstractAnalyticalProblem -struct AnalyticalAliasSpecifier <: AbstractAliasSpecifier - alias_p::Union{Bool, Nothing} - alias_f::Union{Bool, Nothing} - alias_u0::Union{Bool, Nothing} - alias_du0::Union{Bool, Nothing} - alias_tstops::Union{Bool, Nothing} -end @doc doc""" @@ -54,13 +47,24 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias::Union{Bool, Nothing}`: sets all fields of the `AnalyticalAliasSpecifier` to `alias` """ -function AnalyticalAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, - alias_du0 = nothing, alias_tstops = nothing, alias = nothing) - if alias == true - AnalyticalAliasSpecifier(true, true, true, true, true) - elseif alias == false - AnalyticalAliasSpecifier(false, false, false, false, false) - elseif isnothing(alias) - AnalyticalAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) +struct AnalyticalAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_du0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} + + function AnalyticalAliasSpecifier(; + alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + new(true, true, true, true, true) + elseif alias == false + new(false, false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end end -end \ No newline at end of file +end + + diff --git a/src/problems/bvp_problems.jl b/src/problems/bvp_problems.jl index a493807aa..1073d854a 100644 --- a/src/problems/bvp_problems.jl +++ b/src/problems/bvp_problems.jl @@ -439,16 +439,6 @@ function TwoPointSecondOrderBVProblem( return TwoPointSecondOrderBVProblem(f, bc, u0, (tspan[1], tspan[end]), p; kwargs...) end - -struct BVPAliasSpecifier <: AbstractAliasSpecifier - alias_p::Union{Bool, Nothing} - alias_f::Union{Bool, Nothing} - alias_u0::Union{Bool, Nothing} - alias_du0::Union{Bool, Nothing} - alias_tstops::Union{Bool, Nothing} -end - - @doc doc""" Holds information on what variables to alias @@ -466,13 +456,24 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias::Union{Bool, Nothing}`: sets all fields of the `BVPAliasSpecifier` to `alias` """ -function BVPAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, - alias_du0 = nothing, alias_tstops = nothing, alias = nothing) - if alias == true - BVPAliasSpecifier(true, true, true, true, true) - elseif alias == false - BVPAliasSpecifier(false, false, false, false, false) - elseif isnothing(alias) - BVPAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) +struct BVPAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_du0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} + + function BVPAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + new(true, true, true, true, true) + elseif alias == false + new(false, false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end end -end \ No newline at end of file +end + + + diff --git a/src/problems/dae_problems.jl b/src/problems/dae_problems.jl index c613722e5..c525a67a5 100644 --- a/src/problems/dae_problems.jl +++ b/src/problems/dae_problems.jl @@ -120,16 +120,6 @@ function ConstructionBase.constructorof(::Type{P}) where {P <: DAEProblem} end end - -struct DAEAliasSpecifier - alias_p::Union{Bool, Nothing} - alias_f::Union{Bool, Nothing} - alias_u0::Union{Bool, Nothing} - alias_du0::Union{Bool, Nothing} - alias_tstops::Union{Bool, Nothing} -end - - @doc doc""" Holds information on what variables to alias @@ -147,13 +137,24 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias::Union{Bool, Nothing}`: sets all fields of the `DAEAliasSpecifier` to `alias` """ -function DAEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, - alias_du0 = nothing, alias_tstops = nothing, alias = nothing) - if alias == true - DAEAliasSpecifier(true, true, true, true, true) - elseif alias == false - DAEAliasSpecifier(false, false, false, false, false) - elseif isnothing(alias) - DAEAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) +struct DAEAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_du0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} + + function DAEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + new(true, true, true, true, true) + elseif alias == false + new(false, false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end end -end \ No newline at end of file +end + + + diff --git a/src/problems/dde_problems.jl b/src/problems/dde_problems.jl index 9441ad264..b1b925536 100644 --- a/src/problems/dde_problems.jl +++ b/src/problems/dde_problems.jl @@ -397,13 +397,6 @@ function SecondOrderDDEProblem(f::DynamicalDDEFunction, args...; kwargs...) end end -struct DDEAliasSpecifier - alias_p - alias_f - alias_u0 - alias_tstops -end - @doc doc""" @@ -422,13 +415,22 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias::Union{Bool, Nothing}`: sets all fields of the `DDEAliasSpecifier` to `alias` """ -function DDEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, - alias_du0 = nothing, alias_tstops = nothing, alias = nothing) - if alias == true - DDEAliasSpecifier(true, true, true, true, true) - elseif alias == false - DDEAliasSpecifier(false, false, false, false, false) - elseif isnothing(alias) - DDEAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) +struct DDEAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} + + function DDEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + new(true, true, true, true, true) + elseif alias == false + new(false, false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end end -end \ No newline at end of file +end + + diff --git a/src/problems/discrete_problems.jl b/src/problems/discrete_problems.jl index f8b89e258..face982f2 100644 --- a/src/problems/discrete_problems.jl +++ b/src/problems/discrete_problems.jl @@ -154,13 +154,6 @@ function DiscreteProblem(u0::Union{AbstractArray, Number}, tspan::Tuple, DiscreteProblem(f, u0, tspan, p; kwargs...) end -struct DiscreteAliasSpecifier - alias_p::Union{Bool, Nothing} - alias_f::Union{Bool, Nothing} - alias_u0::Union{Bool, Nothing} -end - - @doc doc""" Holds information on what variables to alias @@ -176,13 +169,23 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias::Union{Bool, Nothing}`: sets all fields of the `DiscreteAliasSpecifier` to `alias` """ -function DiscreteAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, - alias_du0 = nothing, alias = nothing) - if alias == true - DiscreteAliasSpecifier(true, true, true, true, true) - elseif alias == false - DiscreteAliasAliasSpecifier(false, false, false, false, false) - elseif isnothing(alias) - DiscreteAliasSpecifier(alias_p, alias_f, alias_u0) +struct DiscreteAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + + function DiscreteAliasSpecifier(; + alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias = nothing) + if alias == true + new(true, true, true, true, true) + elseif alias == false + new(false, false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0) + end end -end \ No newline at end of file +end + + + diff --git a/src/problems/implicit_discrete_problems.jl b/src/problems/implicit_discrete_problems.jl index 7d116da45..deae91c23 100644 --- a/src/problems/implicit_discrete_problems.jl +++ b/src/problems/implicit_discrete_problems.jl @@ -120,13 +120,6 @@ function ImplicitDiscreteProblem(f, u0, tspan, p = NullParameters(); ImplicitDiscreteProblem(ImplicitDiscreteFunction{iip}(f), u0, tspan, p; kwargs...) end - -struct ImplicitDiscreteAliasSpecifier - alias_p::Union{Bool,Nothing} - alias_f::Union{Bool, Nothing} - alias_u0::Union{Bool, Nothing} -end - @doc doc""" Holds information on what variables to alias @@ -142,13 +135,22 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias::Union{Bool, Nothing}`: sets all fields of the `ImplicitDiscreteAliasSpecifier` to `alias` """ -function ImplicitDiscreteAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, - alias_du0 = nothing, alias = nothing) - if alias == true - ImplicitDiscreteAliasSpecifier(true, true, true, true, true) - elseif alias == false - ImplicitDiscreteAliasAliasSpecifier(false, false, false, false, false) - elseif isnothing(alias) - ImplicitDiscreteAliasSpecifier(alias_p, alias_f, alias_u0) +struct ImplicitDiscreteAliasSpecifier + alias_p::Union{Bool,Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + + function ImplicitDiscreteAliasSpecifier(; + alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias = nothing) + if alias == true + new(true, true, true, true, true) + elseif alias == false + new(false, false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0) + end end -end \ No newline at end of file +end + + diff --git a/src/problems/integral_problems.jl b/src/problems/integral_problems.jl index d04ad5e2d..b951a8edb 100644 --- a/src/problems/integral_problems.jl +++ b/src/problems/integral_problems.jl @@ -168,11 +168,6 @@ struct SampledIntegralProblem{Y, X, K} <: AbstractIntegralProblem{false} end end -struct IntegralAliasSpecifier <: AbstractAliasSpecifier - alias_p - alias_f -end - @doc doc""" Holds information on what variables to alias @@ -187,12 +182,19 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias::Union{Bool, Nothing}`: sets all fields of the `IntegralAliasSpecifier` to `alias` """ -function IntegralAliasSpecifier(alias_p = nothing, alias_f = nothing, alias = nothing) - if alias == true - IntegralAliasSpecifier(true, true) - elseif alias == false - IntegralAliasSpecifier(false, false) - elseif isnothing(alias) - IntegralAliasSpecifier(alias_p, alias_f) +struct IntegralAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + + function IntegralAliasSpecifier(alias_p = nothing, alias_f = nothing, alias = nothing) + if alias == true + new(true, true) + elseif alias == false + new(false, false) + elseif isnothing(alias) + new(alias_p, alias_f) + end end -end \ No newline at end of file +end + + diff --git a/src/problems/linear_problems.jl b/src/problems/linear_problems.jl index 873cf11be..614674436 100644 --- a/src/problems/linear_problems.jl +++ b/src/problems/linear_problems.jl @@ -77,11 +77,6 @@ function LinearProblem(A, b, args...; kwargs...) end end -struct LinearAliasSpecifier <: AbstractAliasSpecifier - alias_A::Union{Bool,Nothing} - alias_b::Union{Bool,Nothing} -end - @doc doc""" Holds information on what variables to alias when solving a LinearProblem. Conforms to the AbstractAliasSpecifier interface. @@ -100,12 +95,20 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use Creates a `LinearAliasSpecifier` where `alias_A` and `alias_b` default to `nothing`. When `alias_A` or `alias_b` is nothing, the default value of the solver is used. """ -function LinearAliasSpecifier(;alias_A = nothing, alias_b = nothing, alias_p = nothing, alias_f = nothing, alias = nothing) - if alias == true - LinearAliasSpecifier(true,true,true,true) - elseif alias == false - LinearAliasSpecifier(false,false,false,false) - elseif isnothing(alias) - LinearAliasSpecifier(alias_p, alias_f, alias_A, alias_b) +struct LinearAliasSpecifier <: AbstractAliasSpecifier + alias_A::Union{Bool,Nothing} + alias_b::Union{Bool,Nothing} + + function LinearAliasSpecifier(; alias_A = nothing, alias_b = nothing, + alias_p = nothing, alias_f = nothing, alias = nothing) + if alias == true + new(true, true, true, true) + elseif alias == false + new(false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_A, alias_b) + end end -end \ No newline at end of file +end + + diff --git a/src/problems/nonlinear_problems.jl b/src/problems/nonlinear_problems.jl index 01b1ff881..b6da1e2d3 100644 --- a/src/problems/nonlinear_problems.jl +++ b/src/problems/nonlinear_problems.jl @@ -550,13 +550,6 @@ function SymbolicIndexingInterface.set_parameter!(prob::SCCNonlinearProblem, val end end - -struct NonlinearAliasSpecifier <: AbstractAliasSpecifier - alias_p::Union{Bool,Nothing} - alias_f::Union{Bool,Nothing} - alias_u0::Union{Bool,Nothing} -end - @doc doc""" Holds information on what variables to alias when solving a `NonlinearProblem`. Conforms to the AbstractAliasSpecifier interface. @@ -571,12 +564,21 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias_u0::Union{Bool, Nothing}`: alias the `u0` array. * `alias::Union{Bool, Nothing}`: sets all fields of the `NonlinearAliasSpecifier` to `alias`. """ -function NonlinearAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) - if isnothing(alias) - NonlinearAliasSpecifier(alias_p, alias_f, alias_u0) - elseif alias - NonlinearAliasSpecifier(true, true, true) - elseif !alias - NonlinearAliasSpecifier(false, false, false) + +struct NonlinearAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool,Nothing} + alias_f::Union{Bool,Nothing} + alias_u0::Union{Bool,Nothing} + + function NonlinearAliasSpecifier(; + alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) + if isnothing(alias) + new(alias_p, alias_f, alias_u0) + elseif alias + new(true, true, true) + elseif !alias + new(false, false, false) + end end -end \ No newline at end of file +end + diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index bd9885b80..94a2a4675 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -512,15 +512,6 @@ function IncrementingODEProblem{iip}(f::IncrementingODEFunction, u0, tspan, ODEProblem(f, u0, tspan, p, IncrementingODEProblem{iip}(); kwargs...) end - -struct ODEAliasSpecifier <: AbstractAliasSpecifier - alias_p::Union{Bool,Nothing} - alias_f::Union{Bool,Nothing} - alias_u0::Union{Bool,Nothing} - alias_du0::Union{Bool,Nothing} - alias_tstops::Union{Bool,Nothing} -end - @doc doc""" Holds information on what variables to alias @@ -538,12 +529,22 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias::Union{Bool, Nothing}`: sets all fields of the `ODEAliasSpecifier` to `alias` """ -function ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing) - if alias == true - ODEAliasSpecifier(true,true,true,true,true) - elseif alias == false - ODEAliasSpecifier(false, false, false, false, false) - elseif isnothing(alias) - ODEAliasSpecifier(alias_p,alias_f,alias_u0,alias_du0,alias_tstops) +struct ODEAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool,Nothing} + alias_f::Union{Bool,Nothing} + alias_u0::Union{Bool,Nothing} + alias_du0::Union{Bool,Nothing} + alias_tstops::Union{Bool,Nothing} + + function ODEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + new(true, true, true, true, true) + elseif alias == false + new(false, false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end end -end \ No newline at end of file +end + diff --git a/src/problems/optimization_problems.jl b/src/problems/optimization_problems.jl index 74a66b3a3..37bdce06a 100644 --- a/src/problems/optimization_problems.jl +++ b/src/problems/optimization_problems.jl @@ -155,13 +155,6 @@ end isinplace(f::OptimizationFunction{iip}) where {iip} = iip isinplace(f::OptimizationProblem{iip}) where {iip} = iip -struct OptimizationAliasSpecifier <: AbstractAliasSpecifier - alias_p - alias_f - alias_u0 -end - - @doc doc""" Holds information on what variables to alias @@ -175,12 +168,22 @@ when solving an OptimizationProblem. Conforms to the AbstractAliasSpecifier inte * `alias::Union{Bool, Nothing}`: sets all fields of the `OptimizationAliasSpecifier` to `alias` """ -function OptimizationAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) - if alias == true - OptimizationAliasSpecifier(true, true, true) - elseif alias == false - OptimizationAliasSpecifier(false, false, false) - elseif isnothing(alias) - OptimizationAliasSpecifier(alias_p, alias_f, alias_u0, alias_tstops) +struct OptimizationAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + + function OptimizationAliasSpecifier(; + alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing) + if alias == true + new(true, true, true) + elseif alias == false + new(false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0, alias_tstops) + end end -end \ No newline at end of file +end + + + diff --git a/src/problems/rode_problems.jl b/src/problems/rode_problems.jl index b7c63b3bd..38ed6bc80 100644 --- a/src/problems/rode_problems.jl +++ b/src/problems/rode_problems.jl @@ -92,15 +92,6 @@ function RODEProblem(f, u0, tspan, p = NullParameters(); kwargs...) end -struct RODEAliasSpecifier <: AbstractAliasSpecifier - alias_p - alias_f - alias_u0 - alias_du0 - alias_tstops -end - - @doc doc""" Holds information on what variables to alias @@ -118,13 +109,24 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias::Union{Bool, Nothing}`: sets all fields of the `RODEAliasSpecifier` to `alias` """ -function RODEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, - alias_du0 = nothing, alias_tstops = nothing, alias = nothing) - if alias == true - RODEAliasSpecifier(true, true, true, true, true) - elseif alias == false - RODEAliasSpecifier(false, false, false, false, false) - elseif isnothing(alias) - RODEAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + +struct RODEAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_du0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} + + function RODEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + new(true, true, true, true, true) + elseif alias == false + new(false, false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end end -end \ No newline at end of file +end + + diff --git a/src/problems/sdde_problems.jl b/src/problems/sdde_problems.jl index 38c212903..2c4ff0887 100644 --- a/src/problems/sdde_problems.jl +++ b/src/problems/sdde_problems.jl @@ -174,14 +174,6 @@ end SymbolicIndexingInterface.get_history_function(prob::AbstractSDDEProblem) = prob.h -struct SDDEAliasSpecifier - alias_p - alias_f - alias_u0 - alias_tstops -end - - @doc doc""" Holds information on what variables to alias @@ -197,16 +189,24 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias_tstops::Union{Bool, Nothing}`: alias the tstops array * `alias::Union{Bool, Nothing}`: sets all fields of the `SDDEAliasSpecifier` to `alias` - - """ -function SDDEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, - alias_du0 = nothing, alias_tstops = nothing, alias = nothing) - if alias == true - SDDEAliasSpecifier(true, true, true, true) - elseif alias == false - SDDEAliasSpecifier(false, false, false, false) - elseif isnothing(alias) - SDDEAliasSpecifier(alias_p, alias_f, alias_u0, alias_tstops) +struct SDDEAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} + + function SDDEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + new(true, true, true, true) + elseif alias == false + new(false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0, alias_tstops) + end end -end \ No newline at end of file +end + + + diff --git a/src/problems/sde_problems.jl b/src/problems/sde_problems.jl index 4bfa93c56..31cece3eb 100644 --- a/src/problems/sde_problems.jl +++ b/src/problems/sde_problems.jl @@ -216,11 +216,6 @@ function DynamicalSDEProblem{iip}(f::DynamicalSDEFunction, v0, u0, tspan, SDEProblem(_f, ArrayPartition(v0, u0), tspan, p; kwargs...) end -struct SDEAliasSpecifier <: AbstractAliasSpecifier - alias_p - alias_f -end - @doc doc""" Holds information on what variables to alias @@ -237,13 +232,22 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias::Union{Bool, Nothing}`: sets all fields of the `SDEAliasSpecifier` to `alias` """ -function SDEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, - alias_du0 = nothing, alias_tstops = nothing, alias = nothing) - if alias == true - SDDEAliasSpecifier(true, true, true, true, true) - elseif alias == false - SDDEAliasSpecifier(false, false, false, false, false) - elseif isnothing(alias) - SDDEAliasSpecifier(alias_p, alias_f, alias_u0, alias_tstops) +struct SDEAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} + + function SDEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + new(true, true, true, true, true) + elseif alias == false + new(false, false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0, alias_tstops) + end end -end \ No newline at end of file +end + + diff --git a/src/problems/steady_state_problems.jl b/src/problems/steady_state_problems.jl index 0e025c854..57c6290fd 100644 --- a/src/problems/steady_state_problems.jl +++ b/src/problems/steady_state_problems.jl @@ -122,14 +122,6 @@ function SteadyStateProblem(prob::AbstractODEProblem) SteadyStateProblem{isinplace(prob)}(prob.f, prob.u0, prob.p; prob.kwargs...) end -struct SteadyStateAliasSpecifier <: AbstractAliasSpecifier - alias_p::Union{Bool, Nothing} - alias_f::Union{Bool, Nothing} - alias_u0::Union{Bool, Nothing} - alias_du0::Union{Bool, Nothing} - alias_tstops::Union{Bool, Nothing} -end - @doc doc""" Holds information on what variables to alias @@ -147,13 +139,24 @@ When a keyword argument is `nothing`, the default behaviour of the solver is use * `alias::Union{Bool, Nothing}`: sets all fields of the `SteadStateAliasSpecifier` to `alias` """ -function SteadyStateAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing, - alias_du0 = nothing, alias_tstops = nothing, alias = nothing) - if alias == true - SteadyStateAliasSpecifier(true, true, true, true, true) - elseif alias == false - SteadyStateAliasSpecifier(false, false, false, false, false) - elseif isnothing(alias) - SteadyStateAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) +struct SteadyStateAliasSpecifier <: AbstractAliasSpecifier + alias_p::Union{Bool, Nothing} + alias_f::Union{Bool, Nothing} + alias_u0::Union{Bool, Nothing} + alias_du0::Union{Bool, Nothing} + alias_tstops::Union{Bool, Nothing} + + function SteadyStateAliasSpecifier(; + alias_p = nothing, alias_f = nothing, alias_u0 = nothing, + alias_du0 = nothing, alias_tstops = nothing, alias = nothing) + if alias == true + new(true, true, true, true, true) + elseif alias == false + new(false, false, false, false, false) + elseif isnothing(alias) + new(alias_p, alias_f, alias_u0, alias_du0, alias_tstops) + end end -end \ No newline at end of file +end + +