Deterministic and stochastic optimal control and inverse problems. (2021)