  Population protocols are a model of distributed computation intended for the
study of networks of independent computing agents with dynamic communication
structure. Each agent has a finite number of states, and communication
opportunities occur nondeterministically, allowing the agents involved to
change their states based on each other's states. Population protocols are
often studied in terms of reaching a consensus on whether the input
configuration satisfied some predicate.
  A desirable property of a computation model is modularity, the ability to
combine existing simpler computations in a straightforward way. In the present
paper we present a more general notion of functionality implemented by a
population protocol in terms of multisets of inputs and outputs. This notion
allows to design multiphase protocols as combinations of independently defined
phases. The additional generality also increases the range of behaviours that
can be captured in applications (e.g. maintaining the role distribution in a
fleet of servers).
  We show that composition of protocols can be performed in a uniform
mechanical way, and that the expressive power is essentially semilinear,
similar to the predicate expressive power in the original population protocol
setting.
