Algorithms and architectures for self-calibration of engines