From 742da0207073056c98fb624cea030a7e471feff8 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Caillau Date: Tue, 13 Aug 2024 21:52:10 +0200 Subject: [PATCH 1/2] added -> --- src/onepass.jl | 5 +++-- test/test_onepass.jl | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/onepass.jl b/src/onepass.jl index 1651cf21..bc96b0b1 100644 --- a/src/onepass.jl +++ b/src/onepass.jl @@ -37,6 +37,7 @@ __init_aliases(;max_dim=20) = begin al[:>=] = :≥ al[:derivative] = :∂ al[:integral] = :∫ + al[:->] = :→ al end @@ -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 diff --git a/test/test_onepass.jl b/test/test_onepass.jl index e2f49648..af7dff47 100644 --- a/test/test_onepass.jl +++ b/test/test_onepass.jl @@ -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 \ No newline at end of file From a860ddcca6ce6aefed71d23b8ae5fe8a65eb835f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Caillau Date: Tue, 13 Aug 2024 23:37:15 +0200 Subject: [PATCH 2/2] fix -> to => --- src/onepass.jl | 2 +- test/test_onepass.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/onepass.jl b/src/onepass.jl index bc96b0b1..72d1af8f 100644 --- a/src/onepass.jl +++ b/src/onepass.jl @@ -37,7 +37,7 @@ __init_aliases(;max_dim=20) = begin al[:>=] = :≥ al[:derivative] = :∂ al[:integral] = :∫ - al[:->] = :→ + al[:( => )] = :→ al end diff --git a/test/test_onepass.jl b/test/test_onepass.jl index af7dff47..7e466e56 100644 --- a/test/test_onepass.jl +++ b/test/test_onepass.jl @@ -2460,7 +2460,7 @@ end [ 0, 0 ] <= x(0) <= [ 1, 1 ], (♡) z >= 0, (3) ẋ(t) == [ v(t), r(t)^2 + z ] - ∫( u(t)^2 + z * x₁(t) ) -> min + ∫( u(t)^2 + z * x₁(t) ) => min end x0 = [ 2, 3 ] xf = [ 4, 5 ]