In addition to serving as a stopping criterion, |∇C| � reliably indicates when the algorithm is stalled, which is resolved by random restart. Our stopping criteria require that the previous three iterations have |∇C| � < 10 -9 and have C(𝐩𝐩) within 10% of the lowest C(𝐩𝐩) encountered in all previous iterations, which provides some moderate protection against local minima. Regardless, we show that local minima are virtually nonexistent for three-level systems, so the second stopping criterion is somewhat moot. If an iteration does not meet stopping criteria, then the program checks for a stall. Our stalling criteria require that the last three iterations have less than 1% deviation in |∇C| � and less than 1% deviation in C(𝐩𝐩). The program also triggers a stall if 𝛁𝛁𝛁𝛁𝛁𝛁 is singular, or nearly singular. If no stall is detected, then the program continues to the next iteration.