I am relatively new to this topic. I understand the basics of optimization of control systems using a cost function and constraints and solve it as a minimization or maximization problem. I also understand that the cost function should be expressed as a function of parameters that I can change or control [for optimal output]. All the examples i have gone through in the theory take a simplistic control system like an inverted pendulum and come up with cost function for example as a function of initial position based on simple physics equations.
My question here is how can this be done for complex control systems like a Braking control systems in a vehicle. If braking distance is considered as a performance metric to be optimized to be as minimum as possible. How to come up with a cost function for this as a function of some input parameter? Is there a formal mathematical way of doing it?