To improve accuracy of learning of a model function by taking engine speed into consideration in a device controlling ignition timing so as not to cause knocking by using a model function, namely, a self-ignition prediction model, and predicting self-ignition of in-cylinder unburnt gas from a detection value and an estimated value of each parameter.
An estimated value of an in-cylinder unburnt gas temperature is calculated on the basis of an operating condition of the engine, and the model function is corrected per each engine speed area on the basis of the calculated in-cylinder unburnt gas temperature. Since correction of the model function is carried out per each engine speed area, accuracy of learning of the model function can be improved.
Kazuo Abe