Skip to content

Commit b85af0f

Browse files
committed
Simplify initial guess in tutorial-mam by inlining helper functions
1 parent 8947c29 commit b85af0f

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

docs/src/tutorial-mam.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# [Minimal Action Method using Optimal Control](@id tutorial-mam)
22

3+
```@meta
4+
Draft = false
5+
```
6+
37
The Minimal Action Method (MAM) is a numerical technique for finding the most probable transition pathway between stable states in stochastic dynamical systems. It achieves this by minimizing an action functional that represents the path's deviation from the deterministic dynamics, effectively identifying the path of least resistance through the system's landscape.
48

59
This tutorial demonstrates how to implement MAM as an optimal control problem, using the classical Maier-Stein model as a benchmark example.
@@ -17,7 +21,7 @@ using Plots, Printf
1721
We aim to find the most probable transition path between two stable states of a stochastic dynamical system. For a system with deterministic dynamics $f(x)$ and small noise, the transition path minimizes the action functional:
1822

1923
```math
20-
S[x(\cdot), u(\cdot)] = \int_0^T \|u(t) - f(x(t))\|^2 \, dt
24+
S[x(\cdot), u(\cdot)] = \int_0^T \|u(t) - f(x(t))\|^2 \, \mathrm{d}t
2125
```
2226

2327
subject to the path dynamics:
@@ -72,17 +76,10 @@ We provide an initial guess for the path using a simple interpolation with the `
7276
# Time horizon
7377
T = 50
7478
75-
# Helper functions for initial state guess
76-
L(t) = -(1 - t/T) + t/T # Linear interpolation from -1 to 1
77-
P(t) = 0.3*(-L(t)^2 + 1) # Parabolic arc (approximates saddle crossing)
78-
7979
init = @init ocp(T) begin
80-
# Linear interpolation for x₁
81-
x₁(t) := L(t)
82-
# Parabolic guess for x₂
83-
x₂(t) := P(t)
84-
# Control from vector field
85-
u(t) := f(L(t), P(t))
80+
x₁(t) := -(1 - t/T) + t/T # Linear interpolation from -1 to 1
81+
x₂(t) := 0.3*(-x₁(t)^2 + 1) # Parabolic arc (approximates saddle crossing)
82+
u(t) := f(x₁(t), x₂(t)) # Control from vector field
8683
end
8784
nothing # hide
8885
```

0 commit comments

Comments
 (0)