  This paper considers the problem of designing a continuous-time dynamical
system that solves a constrained nonlinear optimization problem and makes the
feasible set forward invariant and asymptotically stable. The invariance of the
feasible set makes the dynamics anytime, when viewed as an algorithm, meaning
it returns a feasible solution regardless of when it is terminated. Our
approach augments the gradient flow of the objective function with inputs
defined by the constraint functions, treats the feasible set as a safe set, and
synthesizes a safe feedback controller using techniques from the theory of
control barrier functions. The resulting closed-loop system, termed safe
gradient flow, can be viewed as a primal-dual flow, where the state corresponds
to the primal variables and the inputs correspond to the dual ones. We provide
a detailed suite of conditions based on constraint qualification under which
(both isolated and nonisolated) local minimizers are stable with respect to the
feasible set and the whole state space. Comparisons with other continuous-time
methods for optimization in a simple example illustrate the advantages of the
safe gradient flow.
