The algorithm terminates when either a maximum number of generations has been produced , or a satisfactory fitness level has been reached for the population .
Commonly , the algorithm terminates when either a maximum number of generations has been produced , or a satisfactory fitness level has been reached for the population .