Global-to-Local Design for Self-Organized Task Allocation in Swarms