@@ -2097,24 +2097,25 @@ end
2097
2097
"""
2098
2098
$(TYPEDEF)
2099
2099
"""
2100
- abstract type AbstractControlFunction {iip} <: AbstractDiffEqFunction{iip} end
2100
+ abstract type AbstractODEInputFunction {iip} <: AbstractDiffEqFunction{iip} end
2101
2101
2102
2102
@doc doc"""
2103
2103
$(TYPEDEF)
2104
2104
2105
- A representation of a optimal control function `f`, defined by:
2105
+ A representation of a ODE function `f` with inputs , defined by:
2106
2106
2107
2107
```math
2108
2108
\f rac{dx}{dt} = f(x, u, p, t)
2109
2109
```
2110
- where `x` are the states of the system and `u` are the inputs (or control variables).
2110
+ where `x` are the states of the system and `u` are the inputs (which may represent
2111
+ different things in different contexts, such as control variables in optimal control).
2111
2112
2112
2113
Includes all of its related functions, such as the Jacobian of `f`, its gradient
2113
2114
with respect to time, and more. For all cases, `u0` is the initial condition,
2114
2115
`p` are the parameters, and `t` is the independent variable.
2115
2116
2116
2117
```julia
2117
- ControlFunction {iip, specialize}(f;
2118
+ ODEInputFunction {iip, specialize}(f;
2118
2119
mass_matrix = __has_mass_matrix(f) ? f.mass_matrix : I,
2119
2120
analytic = __has_analytic(f) ? f.analytic : nothing,
2120
2121
tgrad= __has_tgrad(f) ? f.tgrad : nothing,
@@ -2139,11 +2140,11 @@ See the section on `iip` for more details on in-place vs out-of-place handling.
2139
2140
- `mass_matrix`: the mass matrix `M` represented in the BVP function. Can be used
2140
2141
to determine that the equation is actually a BVP for differential algebraic equation (DAE)
2141
2142
if `M` is singular.
2142
- - `jac(J,dx,x,p,gamma,t)` or `J=jac(dx,x,p,gamma,t)`: returns ``\f rac{df}{dx}``
2143
- - `control_jac(J,du,u,p,gamma,t)` or `J=control_jac(du,u,p,gamma,t)`: returns ``\f rac{df}{du}``
2144
- - `jvp(Jv,v,du,u,p,gamma,t)` or `Jv=jvp(v,du,u,p,gamma,t)`: returns the directional
2143
+ - `jac(J,dx,x,u, p,gamma,t)` or `J=jac(dx,x,u ,p,gamma,t)`: returns ``\f rac{df}{dx}``
2144
+ - `control_jac(J,du,x, u,p,gamma,t)` or `J=control_jac(du,x ,u,p,gamma,t)`: returns ``\f rac{df}{du}``
2145
+ - `jvp(Jv,v,du,x, u,p,gamma,t)` or `Jv=jvp(v,du,x ,u,p,gamma,t)`: returns the directional
2145
2146
derivative ``\f rac{df}{du} v``
2146
- - `vjp(Jv,v,du,u,p,gamma,t)` or `Jv=vjp(v,du,u,p,gamma,t)`: returns the adjoint
2147
+ - `vjp(Jv,v,du,x, u,p,gamma,t)` or `Jv=vjp(v,du,x ,u,p,gamma,t)`: returns the adjoint
2147
2148
derivative ``\f rac{df}{du}^\a st v``
2148
2149
- `jac_prototype`: a prototype matrix matching the type that matches the Jacobian. For example,
2149
2150
if the Jacobian is tridiagonal, then an appropriately sized `Tridiagonal` matrix can be used
@@ -2155,7 +2156,7 @@ See the section on `iip` for more details on in-place vs out-of-place handling.
2155
2156
as the prototype and integrators will specialize on this structure where possible. Non-structured
2156
2157
sparsity patterns should use a `SparseMatrixCSC` with a correct sparsity pattern for the Jacobian.
2157
2158
The default is `nothing`, which means a dense Jacobian.
2158
- - `paramjac(pJ,u,p,t)`: returns the parameter Jacobian ``\f rac{df}{dp}``.
2159
+ - `paramjac(pJ,x, u,p,t)`: returns the parameter Jacobian ``\f rac{df}{dp}``.
2159
2160
- `colorvec`: a color vector according to the SparseDiffTools.jl definition for the sparsity
2160
2161
pattern of the `jac_prototype`. This specializes the Jacobian construction when using
2161
2162
finite differences and automatic differentiation to be computed in an accelerated manner
@@ -2170,11 +2171,11 @@ For more details on this argument, see the ODEFunction documentation.
2170
2171
For more details on this argument, see the ODEFunction documentation.
2171
2172
2172
2173
## Fields
2173
- The fields of the ControlFunction type directly match the names of the inputs.
2174
+ The fields of the ODEInputFunction type directly match the names of the inputs.
2174
2175
"""
2175
- struct ControlFunction {iip, specialize, F, TMM, Ta, Tt, TJ, CTJ, JVP, VJP,
2176
+ struct ODEInputFunction {iip, specialize, F, TMM, Ta, Tt, TJ, CTJ, JVP, VJP,
2176
2177
JP, CJP, SP, TW, TWt, WP, TPJ, O, TCV,
2177
- SYS, ID} <: AbstractControlFunction {iip}
2178
+ SYS, ID} <: AbstractODEInputFunction {iip}
2178
2179
f:: F
2179
2180
mass_matrix:: TMM
2180
2181
analytic:: Ta
@@ -2595,7 +2596,7 @@ end
2595
2596
(f:: ImplicitDiscreteFunction )(args... ) = f. f (args... )
2596
2597
(f:: DAEFunction )(args... ) = f. f (args... )
2597
2598
(f:: DDEFunction )(args... ) = f. f (args... )
2598
- (f:: ControlFunction )(args... ) = f. f (args... )
2599
+ (f:: ODEInputFunction )(args... ) = f. f (args... )
2599
2600
2600
2601
function (f:: DynamicalDDEFunction )(u, h, p, t)
2601
2602
ArrayPartition (f. f1 (u. x[1 ], u. x[2 ], h, p, t), f. f2 (u. x[1 ], u. x[2 ], h, p, t))
@@ -4698,7 +4699,7 @@ function BatchIntegralFunction(f, integrand_prototype; kwargs...)
4698
4699
BatchIntegralFunction {calculated_iip} (f, integrand_prototype; kwargs... )
4699
4700
end
4700
4701
4701
- function ControlFunction {iip, specialize} (f;
4702
+ function ODEInputFunction {iip, specialize} (f;
4702
4703
mass_matrix = __has_mass_matrix (f) ? f. mass_matrix :
4703
4704
I,
4704
4705
analytic = __has_analytic (f) ? f. analytic : nothing ,
@@ -4748,17 +4749,17 @@ function ControlFunction{iip, specialize}(f;
4748
4749
4749
4750
if jac === nothing && isa (jac_prototype, AbstractSciMLOperator)
4750
4751
if iip
4751
- jac = update_coefficients! # (J,u,p,t)
4752
+ jac = (J, x, u, p, t) -> update_coefficients! (J, x, p, t) # (J,x ,u,p,t)
4752
4753
else
4753
- jac = (u, p, t) -> update_coefficients (deepcopy (jac_prototype), u , p, t)
4754
+ jac = (x, u, p, t) -> update_coefficients (deepcopy (jac_prototype), x , p, t)
4754
4755
end
4755
4756
end
4756
4757
4757
4758
if controljac === nothing && isa (controljac_prototype, AbstractSciMLOperator)
4758
4759
if iip_bc
4759
- controljac = update_coefficients! # (J,u,p,t)
4760
+ controljac = (J, x, u, p, t) -> update_coefficients! (J, u, p, t) # (J,x ,u,p,t)
4760
4761
else
4761
- controljac = (u, p, t) -> update_coefficients! (deepcopy (controljac_prototype), u, p, t)
4762
+ controljac = (x, u, p, t) -> update_coefficients (deepcopy (controljac_prototype), u, p, t)
4762
4763
end
4763
4764
end
4764
4765
@@ -4769,14 +4770,14 @@ function ControlFunction{iip, specialize}(f;
4769
4770
_colorvec = colorvec
4770
4771
end
4771
4772
4772
- jaciip = jac != = nothing ? isinplace (jac, 4 , " jac" , iip) : iip
4773
- controljaciip = controljac != = nothing ? isinplace (controljac, 4 , " controljac" , iip) : iip
4774
- tgradiip = tgrad != = nothing ? isinplace (tgrad, 4 , " tgrad" , iip) : iip
4775
- jvpiip = jvp != = nothing ? isinplace (jvp, 5 , " jvp" , iip) : iip
4776
- vjpiip = vjp != = nothing ? isinplace (vjp, 5 , " vjp" , iip) : iip
4777
- Wfactiip = Wfact != = nothing ? isinplace (Wfact, 5 , " Wfact" , iip) : iip
4778
- Wfact_tiip = Wfact_t != = nothing ? isinplace (Wfact_t, 5 , " Wfact_t" , iip) : iip
4779
- paramjaciip = paramjac != = nothing ? isinplace (paramjac, 4 , " paramjac" , iip) : iip
4773
+ jaciip = jac != = nothing ? isinplace (jac, 5 , " jac" , iip) : iip
4774
+ controljaciip = controljac != = nothing ? isinplace (controljac, 5 , " controljac" , iip) : iip
4775
+ tgradiip = tgrad != = nothing ? isinplace (tgrad, 5 , " tgrad" , iip) : iip
4776
+ jvpiip = jvp != = nothing ? isinplace (jvp, 6 , " jvp" , iip) : iip
4777
+ vjpiip = vjp != = nothing ? isinplace (vjp, 6 , " vjp" , iip) : iip
4778
+ Wfactiip = Wfact != = nothing ? isinplace (Wfact, 6 , " Wfact" , iip) : iip
4779
+ Wfact_tiip = Wfact_t != = nothing ? isinplace (Wfact_t, 6 , " Wfact_t" , iip) : iip
4780
+ paramjaciip = paramjac != = nothing ? isinplace (paramjac, 5 , " paramjac" , iip) : iip
4780
4781
4781
4782
nonconforming = (jaciip, tgradiip, jvpiip, vjpiip, Wfactiip, Wfact_tiip,
4782
4783
paramjaciip) .!= iip
@@ -4794,7 +4795,7 @@ function ControlFunction{iip, specialize}(f;
4794
4795
initializeprobmap, initializeprobpmap)
4795
4796
4796
4797
if specialize === NoSpecialize
4797
- ControlFunction {iip, specialize,
4798
+ ODEInputFunction {iip, specialize,
4798
4799
Any, Any, Any, Any,
4799
4800
Any, Any, Any, Any, typeof (jac_prototype), typeof (controljac_prototype),
4800
4801
typeof (sparsity), Any, Any, typeof (W_prototype), Any,
@@ -4806,7 +4807,7 @@ function ControlFunction{iip, specialize}(f;
4806
4807
Wfact_t, W_prototype, paramjac,
4807
4808
observed, _colorvec, sys, initdata)
4808
4809
elseif specialize === false
4809
- ControlFunction {iip, FunctionWrapperSpecialize,
4810
+ ODEInputFunction {iip, FunctionWrapperSpecialize,
4810
4811
typeof (_f), typeof (mass_matrix), typeof (analytic), typeof (tgrad),
4811
4812
typeof (jac), typeof (controljac), typeof (jvp), typeof (vjp), typeof (jac_prototype), typeof (controljac_prototype),
4812
4813
typeof (sparsity), typeof (Wfact), typeof (Wfact_t), typeof (W_prototype),
@@ -4819,7 +4820,7 @@ function ControlFunction{iip, specialize}(f;
4819
4820
Wfact_t, W_prototype, paramjac,
4820
4821
observed, _colorvec, sys, initdata)
4821
4822
else
4822
- ControlFunction {iip, specialize,
4823
+ ODEInputFunction {iip, specialize,
4823
4824
typeof (_f), typeof (mass_matrix), typeof (analytic), typeof (tgrad),
4824
4825
typeof (jac), typeof (controljac), typeof (jvp), typeof (vjp), typeof (jac_prototype), typeof (controljac_prototype),
4825
4826
typeof (sparsity), typeof (Wfact), typeof (Wfact_t), typeof (W_prototype),
@@ -4834,12 +4835,12 @@ function ControlFunction{iip, specialize}(f;
4834
4835
end
4835
4836
end
4836
4837
4837
- function ControlFunction {iip} (f; kwargs... ) where {iip}
4838
- ControlFunction {iip, FullSpecialize} (f; kwargs... )
4838
+ function ODEInputFunction {iip} (f; kwargs... ) where {iip}
4839
+ ODEInputFunction {iip, FullSpecialize} (f; kwargs... )
4839
4840
end
4840
- ControlFunction {iip} (f:: ControlFunction ; kwargs... ) where {iip} = f
4841
- ControlFunction (f; kwargs... ) = ControlFunction {isinplace(f, 5), FullSpecialize} (f; kwargs... )
4842
- ControlFunction (f:: ControlFunction ; kwargs... ) = f
4841
+ ODEInputFunction {iip} (f:: ODEInputFunction ; kwargs... ) where {iip} = f
4842
+ ODEInputFunction (f; kwargs... ) = ODEInputFunction {isinplace(f, 5), FullSpecialize} (f; kwargs... )
4843
+ ODEInputFunction (f:: ODEInputFunction ; kwargs... ) = f
4843
4844
4844
4845
# ######### Utility functions
4845
4846
0 commit comments