Skip to content

Commit 1bb54e9

Browse files
authored
Merge pull request #246 from control-toolbox/239-add-non-unicode-keywords
Non unicode (bis)
2 parents 590f37e + a860ddc commit 1bb54e9

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/onepass.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ __init_aliases(;max_dim=20) = begin
3737
al[:>=] = :
3838
al[:derivative] = :∂
3939
al[:integral] = :∫
40+
al[:( => )] = :
4041
al
4142
end
4243

@@ -63,11 +64,11 @@ __v_dep(p) = !isnothing(p.v)
6364
"""
6465
$(TYPEDSIGNATURES)
6566
66-
Foo
67+
Parse the expression `e` and update the `ParsingInfo` structure `p`.
6768
6869
# Example
6970
```@example
70-
Foo
71+
parse!(p, :ocp, :(v ∈ R, variable))
7172
```
7273
"""
7374
parse!(p, ocp, e; log=false) = begin

test/test_onepass.jl

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2447,7 +2447,33 @@ end
24472447
@test constraint(o, :eq3)(z) == z
24482448
@test o.dynamics(x, u, z) == [ x[2], x[1]^2 + z ]
24492449
@test o.lagrange(x, u, z) == u^2 + z * x[1]
2450-
2450+
2451+
@def o begin
2452+
z R, variable
2453+
t [ 0, 1 ], time
2454+
x R², state
2455+
u R, control
2456+
r = x₁
2457+
v = x₂
2458+
0 <= r(0) - z <= 1, (1)
2459+
0 <= v(1)^2 <= 1, (2)
2460+
[ 0, 0 ] <= x(0) <= [ 1, 1 ], (♡)
2461+
z >= 0, (3)
2462+
(t) == [ v(t), r(t)^2 + z ]
2463+
( u(t)^2 + z * x₁(t) ) => min
2464+
end
2465+
x0 = [ 2, 3 ]
2466+
xf = [ 4, 5 ]
2467+
x = [ 1, 2 ]
2468+
u = 3
2469+
z = 4
2470+
@test constraint(o, :eq1)(x0, xf, z) == x0[1] - z
2471+
@test constraint(o, :eq2)(x0, xf, z) == xf[2]^2
2472+
@test constraint(o, Symbol(""))(x0, xf, z) == x0
2473+
@test constraint(o, :eq3)(z) == z
2474+
@test o.dynamics(x, u, z) == [ x[2], x[1]^2 + z ]
2475+
@test o.lagrange(x, u, z) == u^2 + z * x[1]
2476+
24512477
end
24522478

24532479
end

0 commit comments

Comments
 (0)