Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non unicode (bis) #246

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/onepass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ __init_aliases(;max_dim=20) = begin
al[:>=] = :≥
al[:derivative] = :∂
al[:integral] = :∫
al[:( => )] = :→
al
end

Expand All @@ -63,11 +64,11 @@ __v_dep(p) = !isnothing(p.v)
"""
$(TYPEDSIGNATURES)

Foo
Parse the expression `e` and update the `ParsingInfo` structure `p`.

# Example
```@example
Foo
parse!(p, :ocp, :(v ∈ R, variable))
```
"""
parse!(p, ocp, e; log=false) = begin
Expand Down
28 changes: 27 additions & 1 deletion test/test_onepass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2447,7 +2447,33 @@ end
@test constraint(o, :eq3)(z) == z
@test o.dynamics(x, u, z) == [ x[2], x[1]^2 + z ]
@test o.lagrange(x, u, z) == u^2 + z * x[1]


@def o begin
z ∈ R, variable
t ∈ [ 0, 1 ], time
x ∈ R², state
u ∈ R, control
r = x₁
v = x₂
0 <= r(0) - z <= 1, (1)
0 <= v(1)^2 <= 1, (2)
[ 0, 0 ] <= x(0) <= [ 1, 1 ], (♡)
z >= 0, (3)
ẋ(t) == [ v(t), r(t)^2 + z ]
∫( u(t)^2 + z * x₁(t) ) => min
end
x0 = [ 2, 3 ]
xf = [ 4, 5 ]
x = [ 1, 2 ]
u = 3
z = 4
@test constraint(o, :eq1)(x0, xf, z) == x0[1] - z
@test constraint(o, :eq2)(x0, xf, z) == xf[2]^2
@test constraint(o, Symbol("♡"))(x0, xf, z) == x0
@test constraint(o, :eq3)(z) == z
@test o.dynamics(x, u, z) == [ x[2], x[1]^2 + z ]
@test o.lagrange(x, u, z) == u^2 + z * x[1]

end

end
Loading