The bare bones particle swarm optimization algorithm is wildly used in different areas. However, this algorithm may suffer from premature convergence by getting trapped in a local optimum when dealing with multimodal functions. To solve this problem, a dynamic allocation bare bones particle swarm optimization (DABBPSO) algorithm is proposed in this work. Particles are divided into two groups before evaluation according to their personal best position. One group is named as main group (MG) and the other one is called the ancillary group (AG). The MG focuses on digging and trying to find the optimal point in the current local optimum. Conversely, the AG aims at exploring the research area and giving the whole swarm more chances to escape from the local optimum. The two groups work together to find the global optimal in the search area. Also, the DABBPSO is applied to a set of well-designed experiments and a set of 0–1 knapsack problems. Finally, the experimental results confirm the optimization ability of the proposed algorithm.