#2844: made the constant optimization process stoppable, repeat 50 optimization steps until the result is unchanged.