You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/tutorial-free-times-final-initial.md
+15-8Lines changed: 15 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,23 @@
1
1
# [Free initial and final times](@id tutorial-free-times-final-initial)
2
2
3
+
```@meta
4
+
Draft = false
5
+
```
6
+
7
+
This tutorial is part of a series on optimal control problems with free time variables.
8
+
See also: [Free final time](@ref tutorial-free-times-final) and [Free initial time](@ref tutorial-free-times-initial).
9
+
3
10
In this tutorial, we consider an optimal control problem with the initial and final times as free variables, that is there are parts of the variable to be optimized. The required packages for the tutorial are:
We can now compare the direct numerical solution with this theoretical result:
118
125
119
-
```@examplemain-free-final
126
+
```@example free-final-time
120
127
tf = variable(sol)
121
128
u = control(sol)
122
129
p = costate(sol)
@@ -138,7 +145,7 @@ The numerical results match the theoretical solution almost exactly.
138
145
139
146
We now solve the same problem using an **indirect method** (shooting approach). We begin by defining the pseudo-Hamiltonian and the switching function.
140
147
141
-
```@examplemain-free-final
148
+
```@example free-final-time
142
149
# Pseudo-Hamiltonian
143
150
H(x, p, u) = p[1]*x[2] + p[2]*u
144
151
@@ -150,7 +157,7 @@ nothing # hide
150
157
151
158
Define the flows corresponding to the two control laws $u=+1$ and $u=-1$:
152
159
153
-
```@examplemain-free-final
160
+
```@example free-final-time
154
161
const u_pos = 1
155
162
const u_neg = -1
156
163
@@ -162,7 +169,7 @@ nothing # hide
162
169
163
170
The **shooting function** enforces the final and switching conditions:
164
171
165
-
```@examplemain-free-final
172
+
```@example free-final-time
166
173
function shoot!(s, p0, t1, tf)
167
174
x_t0 = x0
168
175
p_t0 = p0
@@ -183,7 +190,7 @@ nothing # hide
183
190
184
191
To help the nonlinear solver converge, we build a good initial guess from the direct solution:
Copy file name to clipboardExpand all lines: docs/src/tutorial-free-times-initial.md
+27-20Lines changed: 27 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,12 @@
1
1
# [Optimal control problem with free initial time](@id tutorial-free-times-initial)
2
2
3
+
```@meta
4
+
Draft = false
5
+
```
6
+
7
+
This tutorial is part of a series on optimal control problems with free time variables.
8
+
See also: [Free final time](@ref tutorial-free-times-final) and [Free initial and final times](@ref tutorial-free-times-final-initial).
9
+
3
10
In this tutorial, we study a **minimum-time optimal control problem with free initial time** $t_0$ (negative). The goal is to determine the latest possible starting time so that the system reaches a fixed final state at $t_f = 0$.
4
11
5
12
The system is the classic **double integrator**:
@@ -9,21 +16,21 @@ The system is the classic **double integrator**:
0 commit comments