@@ -38,6 +38,7 @@ __init_aliases(;max_dim=20) = begin
38
38
al[:derivative ] = :∂
39
39
al[:integral ] = :∫
40
40
al[:( => )] = :→
41
+ al[:in ] = :∈
41
42
al
42
43
end
43
44
@@ -174,13 +175,14 @@ p_variable!(p, ocp, v, q; components_names=nothing, log=false) = begin
174
175
p. v = v
175
176
vv = QuoteNode (v)
176
177
qq = q isa Integer ? q : 9
177
- for i ∈ 1 : qq p. aliases[Symbol (v, ctindices (i))] = :( $ v[$ i] ) end
178
- for i ∈ 1 : 9 p. aliases[Symbol (v, ctupperscripts (i))] = :( $ v^ $ i ) end
178
+ for i ∈ 1 : qq p. aliases[Symbol (v, ctindices (i))] = :( $ v[$ i] ) end # make: v₁, v₂... if the variable is named v
179
+ for i ∈ 1 : qq p. aliases[Symbol (v, i)] = :( $ v[$ i] ) end # make: v1, v2... if the variable is named v
180
+ for i ∈ 1 : 9 p. aliases[Symbol (v, ctupperscripts (i))] = :( $ v^ $ i ) end # make: v¹, v²... if the variable is named v
179
181
if (isnothing (components_names))
180
182
__wrap (:( variable! ($ ocp, $ q, $ vv) ), p. lnum, p. line)
181
183
else
182
184
qq== length (components_names. args) || return __throw (" the number of variable components must be $qq " , p. lnum, p. line)
183
- for i ∈ 1 : qq p. aliases[components_names. args[i]] = :( $ v[$ i] ) end
185
+ for i ∈ 1 : qq p. aliases[components_names. args[i]] = :( $ v[$ i] ) end # aliases from names given by the user
184
186
ss = QuoteNode (string .(components_names. args))
185
187
__wrap (:( variable! ($ ocp, $ q, $ vv, $ ss) ), p. lnum, p. line)
186
188
end
@@ -236,14 +238,15 @@ p_state!(p, ocp, x, n; components_names=nothing, log=false) = begin
236
238
p. x = x
237
239
xx = QuoteNode (x)
238
240
nn = n isa Integer ? n : 9
239
- for i ∈ 1 : nn p. aliases[Symbol (x, ctindices (i))] = :( $ x[$ i] ) end
240
- for i ∈ 1 : 9 p. aliases[Symbol (x, ctupperscripts (i))] = :( $ x^ $ i ) end
241
+ for i ∈ 1 : nn p. aliases[Symbol (x, ctindices (i))] = :( $ x[$ i] ) end # make: x₁, x₂... if the state is named x
242
+ for i ∈ 1 : nn p. aliases[Symbol (x, i)] = :( $ x[$ i] ) end # make: x1, x2... if the state is named x
243
+ for i ∈ 1 : 9 p. aliases[Symbol (x, ctupperscripts (i))] = :( $ x^ $ i ) end # make: x¹, x²... if the state is named x
241
244
p. aliases[Symbol (Unicode. normalize (string (x," ̇" )))] = :( ∂ ($ x) )
242
245
if (isnothing (components_names))
243
246
__wrap (:( state! ($ ocp, $ n, $ xx) ), p. lnum, p. line)
244
247
else
245
248
nn== length (components_names. args) || return __throw (" the number of state components must be $nn " , p. lnum, p. line)
246
- for i ∈ 1 : nn p. aliases[components_names. args[i]] = :( $ x[$ i] ) end
249
+ for i ∈ 1 : nn p. aliases[components_names. args[i]] = :( $ x[$ i] ) end # aliases from names given by the user
247
250
ss = QuoteNode (string .(components_names. args))
248
251
__wrap (:( state! ($ ocp, $ n, $ xx, $ ss) ), p. lnum, p. line)
249
252
end
@@ -255,13 +258,14 @@ p_control!(p, ocp, u, m; components_names=nothing, log=false) = begin
255
258
p. u = u
256
259
uu = QuoteNode (u)
257
260
mm = m isa Integer ? m : 9
258
- for i ∈ 1 : mm p. aliases[Symbol (u, ctindices (i))] = :( $ u[$ i] ) end
259
- for i ∈ 1 : 9 p. aliases[Symbol (u, ctupperscripts (i))] = :( $ u^ $ i ) end
261
+ for i ∈ 1 : mm p. aliases[Symbol (u, ctindices (i))] = :( $ u[$ i] ) end # make: u₁, u₂... if the control is named u
262
+ for i ∈ 1 : mm p. aliases[Symbol (u, i)] = :( $ u[$ i] ) end # make: u1, u2... if the control is named u
263
+ for i ∈ 1 : 9 p. aliases[Symbol (u, ctupperscripts (i))] = :( $ u^ $ i ) end # make: u¹, u²... if the control is named u
260
264
if (isnothing (components_names))
261
265
__wrap (:( control! ($ ocp, $ m, $ uu) ), p. lnum, p. line)
262
266
else
263
267
mm== length (components_names. args) || return __throw (" the number of control components must be $mm " , p. lnum, p. line)
264
- for i ∈ 1 : mm p. aliases[components_names. args[i]] = :( $ u[$ i] ) end
268
+ for i ∈ 1 : mm p. aliases[components_names. args[i]] = :( $ u[$ i] ) end # aliases from names given by the user
265
269
ss = QuoteNode (string .(components_names. args))
266
270
__wrap (:( control! ($ ocp, $ m, $ uu, $ ss) ), p. lnum, p. line)
267
271
end
0 commit comments