Optimality is typically defined by some form of predefined (or learned) performance or cost metric.
E.g., an optimal walking controller of a biped could minimize costs defined as the speed of walking, the amount of deviations from a resting center of gravity pose and the consumed total torques.
For non-linear systems, most learning approaches (policy gradient methods, sampling methods or stochastic search algorithms) will converge to a local optima. Still one talks about an optimal controller wrt. the objective function. In most non-linear systems the global optima (there could be multiple) are unknown and can not be computed analytically.
Dear @Ahmad, " It is well known that Pontryagin’s maximum principle furnishes necessary conditions for the optimality of the control of a dynamic system. In the present work sufficient conditions for the optimality of the control of a nonlinear system with state and control variable constraints and with fixed initial and terminal times are given. These conditions are essentially Pontryagin’s necessary conditions for the same problem, plus some convexity, negativity and strict negativity conditions. The present sufficient conditions subsume the recent results of Lee, wherein sufficient conditions for the optimality of a system, linear in the state variables, were given..."