Skip to content

Commit fb09400

Browse files
authored
Merge pull request #118 from control-toolbox/117-bug-flow-and-jumps
Put some manual tests in test/extras
2 parents ae0a260 + 74c235b commit fb09400

File tree

7 files changed

+62
-0
lines changed

7 files changed

+62
-0
lines changed

test/extras/Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[deps]
2+
CTBase = "54762871-cc72-4466-b8e8-f6c8b58076cd"
3+
CTFlows = "1c39547c-7794-42f7-af83-d98194f657c2"
4+
CTModels = "34c4fa32-2049-4079-8329-de33c2a22e2d"
5+
CTParser = "32681960-a1b1-40db-9bff-a1ca817385d1"
6+
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
7+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using Revise
2+
using Pkg
3+
Pkg.activate("./test/extras/")
4+
5+
#Pkg.develop(url="/Users/ocots/Research/logiciels/dev/control-toolbox/CTFlows")
6+
#Pkg.add("CTParser")
7+
#Pkg.add("CTModels")
8+
#Pkg.add("CTBase")
9+
#Pkg.add("OrdinaryDiffEq")
10+
#Pkg.add("Plots")
11+
12+
using CTBase
13+
using CTModels
14+
import CTParser: CTParser, @def
15+
import CTFlows: CTFlows, Flow, *
16+
using OrdinaryDiffEq
17+
using Plots
18+
19+
t0=0
20+
tf=1
21+
x0=[0, 1]
22+
l = 1/9
23+
@def ocp begin
24+
t [ t0, tf ], time
25+
x R², state
26+
u R, control
27+
x(t0) == x0
28+
x(tf) == [0, -1]
29+
x₁(t) l, (x_con)
30+
(t) == [x₂(t), u(t)]
31+
0.5(u(t)^2) min
32+
end
33+
34+
t1 = 3l
35+
t2 = 1 - 3l
36+
p0 = [-18, -6]
37+
38+
fs = Flow(ocp,
39+
(x, p) -> p[2] # control along regular arc
40+
)
41+
fc = Flow(ocp,
42+
(x, p) -> 0, # control along boundary arc
43+
(x, u) -> l-x[1], # state constraint
44+
(x, p) -> 0 # Lagrange multiplier
45+
)
46+
47+
ν = 18 # jump value of p1 at t1 and t2
48+
49+
f = fs * (t1, [ν, 0], fc) * (t2, [ν, 0], fs)
50+
51+
xf, pf = f(t0, x0, p0, tf) # xf should be [0, -1]
52+
53+
flow_sol = f((t0, tf), x0, p0)
54+
55+
plot(flow_sol)

0 commit comments

Comments
 (0)