  In this paper, we develop a novel dynamic distributed optimal safe consensus
protocol to simultaneously achieve safety requirements and output optimal
consensus. Specifically, we construct a distributed projection optimization
algorithm with an expanding constraint set in the decision-making layer, while
we propose a reference tracking safety controller to ensure that each agent's
output remains within a shrinking safety set in the control layer.We also
establish the convergence and safety analysis of the closed-loop system using
the small-gain theorem and time-varying control barrier function (CBF) theory,
respectively. Besides, unlike previous works on distributed optimal consensus,
our approach does not require prior knowledge of the local objective or
gradient function and adopts a mild assumption on the dynamics of multiagent
systems (MASs) by using the transmission zeros condition.
