Optimal air and fuel-path control of a diesel engine