Stabilizing anderson mixing for accelerated optimization