We consider stationary consensus protocols for networks of dynamic agents with fixed topologies. At each time instant, each agent knows only its and its neighbors' state, but must reach consensus on a group decision value that is function of all the agents' initial state. We show that the agents can reach consensus if the value of such a function is time-invariant when computed over the agents' state trajectories. We use this basic result to introduce a non-linear protocol design rule allowing consensus on a quite general set of values. Such a set includes, e.g., any generalized mean of order p of the agents' initial states. As a second contribution we show that our protocol design is the solution of individual optimizations performed by th...