The energy management of microgrids involves optimizing the capacity configuration, which significantly impacts the economic and stable operation of microgrids. This paper presents a control strategy for microgrid operation that effectively manages distributed power sources and energy storage to optimize capacity configuration. A mathematical optimization model for microgrid energy management is established considering minimum annual cost and optimal scale constraints. The traditional Ant Lion Optimizer (ALO) is improved by using dynamic weight coefficients and chaotic mapping to enhance the diversity of the population and improve the convergence of the algorithm. This can effectively avoid local optimal solutions and premature problems, and improve the convergence speed and search ability of the ALO algorithm. Based on this control strategy and improved ALO algorithm, simulations and tests were conducted using actual data from an independent microgrid, resulting in the optimal solution for the microgrid capacity allocation model. The case study results validate the practicality of the proposed microgrid operation control strategy as well as the superiority of the improved ant colony optimization algorithm.