Skip to content

Commit dcd70ef

Browse files
committed
Add AliasSpecifiers for more problem types
1 parent 081910e commit dcd70ef

15 files changed

+366
-22
lines changed

src/problems/analytical_problems.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,37 @@ function AnalyticalProblem(f, u0, tspan, p = NullParameters(); kwargs...)
2828
end
2929

3030
export AnalyticalProblem, AbstractAnalyticalProblem
31+
32+
struct AnalyticalAliasSpecifier <: AbstractAliasSpecifier
33+
alias_p::Union{Bool, Nothing}
34+
alias_f::Union{Bool, Nothing}
35+
alias_u0::Union{Bool, Nothing}
36+
alias_du0::Union{Bool, Nothing}
37+
alias_tstops::Union{Bool, Nothing}
38+
end
39+
40+
@doc doc"""
41+
42+
Holds information on what variables to alias
43+
when solving an AnalyticalProblem. Conforms to the AbstractAliasSpecifier interface.
44+
AnalyticalAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing)
45+
46+
### Keywords
47+
* `alias_p::Union{Bool, Nothing}`
48+
* `alias_f::Union{Bool, Nothing}`
49+
* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false .
50+
* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false.
51+
* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array
52+
* `alias::Union{Bool, Nothing}`: sets all fields of the `AnalyticalAliasSpecifier` to `alias`
53+
54+
"""
55+
function AnalyticalAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing,
56+
alias_du0 = nothing, alias_tstops = nothing, alias = nothing)
57+
if alias == true
58+
AnalyticalAliasSpecifier(true, true, true, true, true)
59+
elseif alias == false
60+
AnalyticalAliasSpecifier(false, false, false, false, false)
61+
elseif isnothing(alias)
62+
AnalyticalAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops)
63+
end
64+
end

src/problems/bvp_problems.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,3 +438,39 @@ function TwoPointSecondOrderBVProblem(
438438
u0 = [initialGuess(i) for i in tspan]
439439
return TwoPointSecondOrderBVProblem(f, bc, u0, (tspan[1], tspan[end]), p; kwargs...)
440440
end
441+
442+
443+
struct BVPAliasSpecifier <: AbstractAliasSpecifier
444+
alias_p::Union{Bool, Nothing}
445+
alias_f::Union{Bool, Nothing}
446+
alias_u0::Union{Bool, Nothing}
447+
alias_du0::Union{Bool, Nothing}
448+
alias_tstops::Union{Bool, Nothing}
449+
end
450+
451+
452+
@doc doc"""
453+
454+
Holds information on what variables to alias
455+
when solving an BVP. Conforms to the AbstractAliasSpecifier interface.
456+
BVPAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing)
457+
458+
### Keywords
459+
* `alias_p::Union{Bool, Nothing}`
460+
* `alias_f::Union{Bool, Nothing}`
461+
* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false .
462+
* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false.
463+
* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array
464+
* `alias::Union{Bool, Nothing}`: sets all fields of the `BVPAliasSpecifier` to `alias`
465+
466+
"""
467+
function BVPAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing,
468+
alias_du0 = nothing, alias_tstops = nothing, alias = nothing)
469+
if alias == true
470+
BVPAliasSpecifier(true, true, true, true, true)
471+
elseif alias == false
472+
BVPAliasSpecifier(false, false, false, false, false)
473+
elseif isnothing(alias)
474+
BVPAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops)
475+
end
476+
end

src/problems/dae_problems.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,39 @@ function ConstructionBase.constructorof(::Type{P}) where {P <: DAEProblem}
119119
return DAEProblem{iip}(f, du0, u0, tspan, p; differential_vars = dv, kw...)
120120
end
121121
end
122+
123+
124+
struct DAEAliasSpecifier
125+
alias_p::Union{Bool, Nothing}
126+
alias_f::Union{Bool, Nothing}
127+
alias_u0::Union{Bool, Nothing}
128+
alias_du0::Union{Bool, Nothing}
129+
alias_tstops::Union{Bool, Nothing}
130+
end
131+
132+
133+
@doc doc"""
134+
135+
Holds information on what variables to alias
136+
when solving a DAE. Conforms to the AbstractAliasSpecifier interface.
137+
DAEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing)
138+
139+
### Keywords
140+
* `alias_p::Union{Bool, Nothing}`
141+
* `alias_f::Union{Bool, Nothing}`
142+
* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false.
143+
* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false.
144+
* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array
145+
* `alias::Union{Bool, Nothing}`: sets all fields of the `DAEAliasSpecifier` to `alias`
146+
147+
"""
148+
function DAEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing,
149+
alias_du0 = nothing, alias_tstops = nothing, alias = nothing)
150+
if alias == true
151+
DAEAliasSpecifier(true, true, true, true, true)
152+
elseif alias == false
153+
DAEAliasSpecifier(false, false, false, false, false)
154+
elseif isnothing(alias)
155+
DAEAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops)
156+
end
157+
end

src/problems/dde_problems.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,37 @@ function SecondOrderDDEProblem(f::DynamicalDDEFunction, args...; kwargs...)
396396
kwargs...)
397397
end
398398
end
399+
400+
struct DDEAliasSpecifier
401+
alias_p
402+
alias_f
403+
alias_u0
404+
alias_tstops
405+
end
406+
407+
408+
@doc doc"""
409+
410+
Holds information on what variables to alias
411+
when solving a DDE. Conforms to the AbstractAliasSpecifier interface.
412+
DDEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing)
413+
414+
### Keywords
415+
* `alias_p::Union{Bool, Nothing}`
416+
* `alias_f::Union{Bool, Nothing}`
417+
* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false .
418+
* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false.
419+
* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array
420+
* `alias::Union{Bool, Nothing}`: sets all fields of the `DDEAliasSpecifier` to `alias`
421+
422+
"""
423+
function DDEAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing,
424+
alias_du0 = nothing, alias_tstops = nothing, alias = nothing)
425+
if alias == true
426+
DDEAliasSpecifier(true, true, true, true, true)
427+
elseif alias == false
428+
DDEAliasSpecifier(false, false, false, false, false)
429+
elseif isnothing(alias)
430+
DDEAliasSpecifier(alias_p, alias_f, alias_u0, alias_du0, alias_tstops)
431+
end
432+
end

src/problems/discrete_problems.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,34 @@ function DiscreteProblem(u0::Union{AbstractArray, Number}, tspan::Tuple,
153153
end
154154
DiscreteProblem(f, u0, tspan, p; kwargs...)
155155
end
156+
157+
struct DiscreteAliasSpecifier
158+
alias_p::Union{Bool, Nothing}
159+
alias_f::Union{Bool, Nothing}
160+
alias_u0::Union{Bool, Nothing}
161+
end
162+
163+
164+
@doc doc"""
165+
166+
Holds information on what variables to alias
167+
when solving a DiscreteProblem. Conforms to the AbstractAliasSpecifier interface.
168+
DiscreteAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing)
169+
170+
### Keywords
171+
* `alias_p::Union{Bool, Nothing}`
172+
* `alias_f::Union{Bool, Nothing}`
173+
* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false .
174+
* `alias::Union{Bool, Nothing}`: sets all fields of the `DiscreteAliasSpecifier` to `alias`
175+
176+
"""
177+
function DiscreteAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing,
178+
alias_du0 = nothing, alias = nothing)
179+
if alias == true
180+
DiscreteAliasSpecifier(true, true, true, true, true)
181+
elseif alias == false
182+
DiscreteAliasAliasSpecifier(false, false, false, false, false)
183+
elseif isnothing(alias)
184+
DiscreteAliasSpecifier(alias_p, alias_f, alias_u0)
185+
end
186+
end

src/problems/implicit_discrete_problems.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,34 @@ function ImplicitDiscreteProblem(f, u0, tspan, p = NullParameters();
119119
iip = isinplace(f, 6)
120120
ImplicitDiscreteProblem(ImplicitDiscreteFunction{iip}(f), u0, tspan, p; kwargs...)
121121
end
122+
123+
124+
struct ImplicitDiscreteAliasSpecifier
125+
alias_p::Union{Bool,Nothing}
126+
alias_f::Union{Bool, Nothing}
127+
alias_u0::Union{Bool, Nothing}
128+
end
129+
130+
@doc doc"""
131+
132+
Holds information on what variables to alias
133+
when solving an ODE. Conforms to the AbstractAliasSpecifier interface.
134+
DiscreteAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing)
135+
136+
### Keywords
137+
* `alias_p::Union{Bool, Nothing}`
138+
* `alias_f::Union{Bool, Nothing}`
139+
* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false .
140+
* `alias::Union{Bool, Nothing}`: sets all fields of the `ImplicitDiscreteAliasSpecifier` to `alias`
141+
142+
"""
143+
function ImplicitDiscreteAliasSpecifier(; alias_p = nothing, alias_f = nothing, alias_u0 = nothing,
144+
alias_du0 = nothing, alias = nothing)
145+
if alias == true
146+
ImplicitDiscreteAliasSpecifier(true, true, true, true, true)
147+
elseif alias == false
148+
ImplicitDiscreteAliasAliasSpecifier(false, false, false, false, false)
149+
elseif isnothing(alias)
150+
ImplicitDiscreteAliasSpecifier(alias_p, alias_f, alias_u0)
151+
end
152+
end

src/problems/integral_problems.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,18 @@ struct IntegralAliasSpecifier <: AbstractAliasSpecifier
173173
alias_f
174174
end
175175

176+
@doc doc"""
177+
178+
Holds information on what variables to alias
179+
when solving an IntegralProblem. Conforms to the AbstractAliasSpecifier interface.
180+
IntegralAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing)
181+
182+
### Keywords
183+
* `alias_p::Union{Bool, Nothing}`
184+
* `alias_f::Union{Bool, Nothing}`
185+
* `alias::Union{Bool, Nothing}`: sets all fields of the `IntegralAliasSpecifier` to `alias`
186+
187+
"""
176188
function IntegralAliasSpecifier(alias_p = nothing, alias_f = nothing, alias = nothing)
177189
if alias == true
178190
IntegralAliasSpecifier(true, true)

src/problems/linear_problems.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,16 @@ struct LinearAliasSpecifier <: AbstractAliasSpecifier
8383
end
8484

8585
@doc doc"""
86-
Holds information on what variables to alias when solving a `LinearProblem`
86+
Holds information on what variables to alias
87+
when solving a LinearProblem. Conforms to the AbstractAliasSpecifier interface.
8788
8889
### Keywords
8990
90-
* `alias_p::Bool`
91-
* `alias_f::Bool`
92-
* `alias_A::Bool`: alias the `A` array.
93-
* `alias_b::Bool`: alias the `b` array.
94-
* `alias::Bool`: sets all fields of the `LinearAliasSpecifier` to `alias`.
91+
* `alias_p::Union{Bool, Nothing}`
92+
* `alias_f::Union{Bool, Nothing}`
93+
* `alias_A::Union{Bool, Nothing}`: alias the `A` array.
94+
* `alias_b::Union{Bool, Nothing}`: alias the `b` array.
95+
* `alias::Union{Bool, Nothing}`: sets all fields of the `LinearAliasSpecifier` to `alias`.
9596
9697
Creates a `LinearAliasSpecifier` where `alias_A` and `alias_b` default to `nothing`.
9798
When `alias_A` or `alias_b` is nothing, the default value of the solver is used.

src/problems/nonlinear_problems.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,16 @@ struct NonlinearAliasSpecifier <: AbstractAliasSpecifier
558558
end
559559

560560
@doc doc"""
561-
Holds information on what variables to alias when solving a `NonlinearProblem`.
561+
Holds information on what variables to alias when solving a `NonlinearProblem`.
562+
Conforms to the AbstractAliasSpecifier interface.
562563
563564
### Keywords
564565
565-
* `alias_p::Bool`
566-
* `alias_f::Bool`
567-
* `alias_A::Bool`: alias the `A` array.
568-
* `alias_b::Bool`: alias the `b` array.
569-
* `alias::Bool`: sets all fields of the `LinearAliasSpecifier` to `alias`.
566+
* `alias_p::Union{Bool, Nothing}`
567+
* `alias_f::Union{Bool, Nothing}`
568+
* `alias_A::Union{Bool, Nothing}`: alias the `A` array.
569+
* `alias_b::Union{Bool, Nothing}`: alias the `b` array.
570+
* `alias::Union{Bool, Nothing}`: sets all fields of the `NonlinearAliasSpecifier` to `alias`.
570571
"""
571572
function NonlinearAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias = nothing)
572573
if isnothing(alias)

src/problems/ode_problems.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,12 @@ when solving an ODE. Conforms to the AbstractAliasSpecifier interface.
528528
ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = false, alias = nothing)
529529
530530
### Keywords
531-
* `alias_p::Bool`
532-
* `alias_f::Bool`
533-
* `alias_u0::Bool`: alias the u0 array. Defaults to false .
534-
* `alias_du0::Bool`: alias the du0 array for DAEs. Defaults to false.
535-
* `alias_tstops::Bool`: alias the tstops array
536-
* `alias::Bool`: sets all fields of the `ODEAliasSpecifier` to `alias`
531+
* `alias_p::Union{Bool, Nothing}`
532+
* `alias_f::Union{Bool, Nothing}`
533+
* `alias_u0::Union{Bool, Nothing}`: alias the u0 array. Defaults to false .
534+
* `alias_du0::Union{Bool, Nothing}`: alias the du0 array for DAEs. Defaults to false.
535+
* `alias_tstops::Union{Bool, Nothing}`: alias the tstops array
536+
* `alias::Union{Bool, Nothing}`: sets all fields of the `ODEAliasSpecifier` to `alias`
537537
538538
"""
539539
function ODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = nothing, alias_du0 = nothing, alias_tstops = nothing, alias = nothing)

0 commit comments

Comments
 (0)