Earthquake prediction and its optimization