The safe gradient flow: a system-theoretic approach to anytime constrained optimization.