A reconfiguration algorithm for distributed problem solving