Butterfly optimization algorithm (BOA) is a relatively novel optimization technique for solving function optimization as well as real world applications. However, the paramount challenge in BOA is that it is prone to stagnation in local optima. The purpose of this study is to balance the exploration and exploitation abilities of BOA when two new strategies are introduced. The dynamic inertia weight based on Logistic model as the first strategy is introduced to modify the position updating equation. Another strategy is the opposition-based learning. A new variant of BOA called BBOA based on these two strategies is proposed. Ten widely used benchmark test functions and 30 complex benchmarks from CEC 2014 are selected to verify the effectiveness of BBOA. The used benchmark problems are composed of unimodal, multimodal, rotated, shifted, hybrid and composite functions. The experimental results and analysis show that the proposed BBOA has better exploration ability than the conventional BOA when solving different characteristics functions. Finally, BBOA is applied to solve three real-world engineering applications and sixteen feature selection problems. The results demonstrate that BBOA can outperform other competitors in terms of the accuracy of solution on constrained engineering design and feature selection problems.