The solution of an optimal control problem requires the satisfaction of differential equations subject to initial as well as final conditions. Except when the equations are linear and the objective functional is simple enough, an analytical solution is impossible. This is the reality of most of the problems for which optimal controls can only be determined using numerical methods.
In this chapter, we introduce the gradient and penalty function methods, which are quite effective in solving a wide range of optimal control problems. Given initial guesses, these methods help in determining the local optimum (i.e., minimum or maximum) of the objective functional of a problem. We cannot discount the possibility of having a number of local optima in an optimal control problem. To strengthen the globality of the optimum, we need to apply these methods with several initial guesses and compare the resulting optima. Note that finding the maximum in a problem is equivalent to finding the minimum of the negative of the objective functional.