Optimal and Robust Control
BE3M35ORR + B3M35ORR + BE3M35ORCHomework problem assignment #7
Get a boat as far as possible
Find the optimal control policy getting a boat in a river stream as far as possible. The equations of motion of the boat in the river stream are
\begin{array}{rl}
\dot{x} &= \cos\theta + y, \\
\dot{y} &= \sin\theta.
\end{array}
\)
The boat is at time \(t=0\) located on a river bank (i.e. \([x(0),y(0)]=[0,0]\)). The only way how you can influence the motion of the boat is via commanding the angle \(\theta\).

Your goal is to get the boat as far possible along the x-axis during a fixed time interval [0,5].
Proceed as follows:
- Formulate the optimal control problem: design the final-time cost function \(\phi(\mathbf{x}(t_f), t_f)\) and the running cost function \(L(\mathbf{x}(t), \mathbf{u}(t), t)\). Both should be as simple as possble and yet they have to describe what you need to achieve. (Hint: you do not need both cost functions and a linear function will do.)
- Formulate the Hamiltonian.
- Calculate the first-order necessary conditions.
- Express the optimal control input from the stationarity condition. In this particular case, the optimal control input should be a function of costates only.
- Formulate the Two-point Boundary Value Problem (TP-BVP). This time, the boundary conditions are given by the initial condition for the state and final-time condition for the costate (have a look at the cheatsheet).
- If you choose wisely the cost function, the differential costate equation can be solved analytically. Otherwise, you can use a numerical solver for the TP-BVP.
- Substitute the costates to the optimal control input and simulate the system response.
Implement your solution as a function with the header of the following form:
function [ t_star, x_star, u_star ] = hw7_cvutID()
where cvutID is your KOS username, t_star is the time vector of the trajectory, x_star is the state trajectory and u_star is the control trajectory. You are free to choose the sampling of the time interval [0, 5]; in other words, time samples in t_star can be arbitrarily spaced.
You can submit only one m-file. If you need more functions, you can use nested functions (for details, see this).