Dynamic Task Allocation in Robot Swarms with Limited Buffer and Energy Constraints