Simulation and optimization of controlled multibody systems: Application to vehicle dynamics