@@ -17,7 +17,9 @@ wrapped to return either a scalar or vector depending on the model's state dimen
1717"""
1818function __dynamics (ocp:: CTModels.Model )
1919 n = CTModels. state_dimension (ocp)
20- dyn = (t, x, u, v) -> (r = zeros (eltype (x), n); CTModels. dynamics (ocp)(r, t, x, u, v); n== 1 ? r[1 ] : r)
20+ dyn =
21+ (t, x, u, v) ->
22+ (r= zeros (eltype (x), n); CTModels. dynamics (ocp)(r, t, x, u, v); n== 1 ? r[1 ] : r)
2123 return Dynamics (dyn, NonAutonomous, NonFixed)
2224end
2325
@@ -55,10 +57,14 @@ The Hamiltonian is built using model dynamics (and possibly a running cost) and
5557
5658Returns a tuple `(H, u)` where `H` is the Hamiltonian function and `u` is the control law.
5759"""
58- function __create_hamiltonian (ocp:: CTModels.Model , u:: ControlLaw{<:Function,T,V} ) where {T,V}
60+ function __create_hamiltonian (
61+ ocp:: CTModels.Model , u:: ControlLaw{<:Function,T,V}
62+ ) where {T,V}
5963 f, f⁰, p⁰, s = __get_data_for_ocp_flow (ocp) # data
6064 @assert f ≠ nothing " no dynamics in ocp"
61- h = Hamiltonian (f⁰ ≠ nothing ? makeH (f, u, f⁰, p⁰, s) : makeH (f, u), NonAutonomous, NonFixed)
65+ h = Hamiltonian (
66+ f⁰ ≠ nothing ? makeH (f, u, f⁰, p⁰, s) : makeH (f, u), NonAutonomous, NonFixed
67+ )
6268 return h, u
6369end
6470
@@ -69,12 +75,14 @@ Helper method to construct the Hamiltonian when control is given as a plain func
6975
7076The function is wrapped in a `ControlLaw`, and the flags `autonomous` and `variable` define its behavior type.
7177"""
72- function __create_hamiltonian (ocp:: CTModels.Model , u:: Function ; autonomous:: Bool , variable:: Bool )
78+ function __create_hamiltonian (
79+ ocp:: CTModels.Model , u:: Function ; autonomous:: Bool , variable:: Bool
80+ )
7381 T, V = @match (autonomous, variable) begin
74- (true , false ) => (Autonomous, Fixed)
75- (true , true ) => (Autonomous, NonFixed)
76- (false , false ) => (NonAutonomous, Fixed)
77- _ => (NonAutonomous, NonFixed)
82+ (true , false ) => (Autonomous, Fixed)
83+ (true , true ) => (Autonomous, NonFixed)
84+ (false , false ) => (NonAutonomous, Fixed)
85+ _ => (NonAutonomous, NonFixed)
7886 end
7987 return __create_hamiltonian (ocp, ControlLaw (u, T, V))
8088end
@@ -147,12 +155,14 @@ $(TYPEDSIGNATURES)
147155
148156Overload for control law as a raw function with autonomous and variable flags.
149157"""
150- function __create_hamiltonian (ocp:: CTModels.Model , u:: Function , g, μ; autonomous:: Bool , variable:: Bool )
158+ function __create_hamiltonian (
159+ ocp:: CTModels.Model , u:: Function , g, μ; autonomous:: Bool , variable:: Bool
160+ )
151161 T, V = @match (autonomous, variable) begin
152- (true , false ) => (Autonomous, Fixed)
153- (true , true ) => (Autonomous, NonFixed)
154- (false , false ) => (NonAutonomous, Fixed)
155- _ => (NonAutonomous, NonFixed)
162+ (true , false ) => (Autonomous, Fixed)
163+ (true , true ) => (Autonomous, NonFixed)
164+ (false , false ) => (NonAutonomous, Fixed)
165+ _ => (NonAutonomous, NonFixed)
156166 end
157167 return __create_hamiltonian (ocp, ControlLaw (u, T, V), g, μ)
158168end
@@ -191,7 +201,10 @@ $(TYPEDSIGNATURES)
191201Overload that converts StateConstraint objects into MixedConstraint with appropriate signature adaptation.
192202"""
193203function __create_hamiltonian (
194- ocp:: CTModels.Model , u:: ControlLaw{<:Function,T,V} , g_:: StateConstraint{<:Function,T,V} , μ
204+ ocp:: CTModels.Model ,
205+ u:: ControlLaw{<:Function,T,V} ,
206+ g_:: StateConstraint{<:Function,T,V} ,
207+ μ,
195208) where {T,V}
196209 g = @match (T, V) begin
197210 (Autonomous, Fixed) => MixedConstraint ((x, u) -> g_ (x), T, V)
@@ -208,7 +221,10 @@ $(TYPEDSIGNATURES)
208221Overload that wraps multiplier functions into Multiplier objects.
209222"""
210223function __create_hamiltonian (
211- ocp:: CTModels.Model , u:: ControlLaw{<:Function,T,V} , g:: MixedConstraint{<:Function,T,V} , μ:: Function
224+ ocp:: CTModels.Model ,
225+ u:: ControlLaw{<:Function,T,V} ,
226+ g:: MixedConstraint{<:Function,T,V} ,
227+ μ:: Function ,
212228) where {T,V}
213229 return __create_hamiltonian (ocp, u, g, Multiplier (μ, T, V))
214230end
0 commit comments