Abstract The development of new energy sources is considered to be one of the important ways to solve the current energy shortage problem. Clean energy sources such as wind and light have attracted much attention. Still, the volatility and uncertainty of their output power create difficulties for the large-scale connection of the system to the power grid. Based on the microgrid system, this paper focuses on the energy optimization control problem of storage batteries and supercapacitors. A low-pass filter is used based on the charge state SOC expressed as a formula. The working state of the supercapacitor charge is divided into five regions, with each region having a corresponding reference value for output power correction. The capacity optimization model of the hybrid energy storage device is constructed, and the Gaussian variational quantum particle swarm algorithm (GM-QPSO) is used to optimize the capacity of the hybrid energy storage device. It is found that the capacity optimization method proposed in this paper not only improves the stability of the operation of the system but also ensures the overall economy of the system.