Modern diesel engines are typically equipped with variable geometry turbo-compressor, exhaust gas recirculation (EGR) system, common rail injection system, and post-treatment devices in order to increase their power while respecting the emissions standards. Consequently, the control of diesel engines has become a difficult task involving five to ten control variables that interact with each other and that are highly nonlinear. Actually, the control schemes of the engines are all based on static lookup tables identified on test-benches; the values of the control variables are interpolated using these tables and then, they are corrected, online, by using the control techniques in order to obtain better engine's response under dynamic conditions. In this paper, we are interested in developing a mathematical optimization process that search for the optimal control schemes of the diesel engines under static and dynamic conditions. First, we suggest modeling a turbocharged diesel engine and its opacity using the mean value model which requires limited experiments; the model's simulations are in excellent agreement with the experimental data. Then the created model is integrated in a dynamic optimization process based on the Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm. The optimization results show the reduction of the opacity while enhancing the engine's effective power. Finally, we proposed a practical control technique based on the neural networks in order to apply these control schemes online to the engine. The neural controller is integrated into the engine's simulations and is used to control the engine in real time on the European transient cycle (ETC). The results confirm the validity of the neural controller.Index Terms-Diesel engines, dynamic optimization process, mean value model, optimal control and neural networks.