Optimization of ignition advance angle and air fuel ratio of combustion engines