Dynamic task allocation in multi-agent systems