Given the resource-constrained and distributed nature of Wireless Sensor Network (WSN), collaboration is very necessary for task execution. However traditional collaborative methods can not be applied to WSN directly. In this paper, we focus on coalition-based method of multi-nodes collaboration (CMMC) which is performed to achieve a maximum utility through collaboration while minimizing the communication costs of collaboration. The cluster head selects different sets of execution nodes according to the information of cluster members and tasks in the method. Discrete Particle Swarm Optimization (D-PSO) is designed and adopted to address the coalition formation in WSN. To overcome the weakness of D-PSO we proposed Dynamic Discrete Particle Swarm Optimization (DD-PSO) which introduces random perturbation and widens the global searching ability. Also coalition utility function is designed to guide the evolution. At last, the simulation shows that DD-PSO has better performance than other algorithms and achieves a balance between local solving and global searching, also it can effectively reduce the communication overhead and balance network load.