A heuristic design method for loop invariant template