Maximum power point tracking (MPPT) is an algorithm implemented in photovoltaic (PV) inverters to continuously adjust the impedance seen by the solar array to keep the PV system operating at, or close to, the peak power point of the PV panel under varying conditions, like changing. Maximum power point tracking (MPPT) is an algorithm implemented in photovoltaic (PV) inverters to continuously adjust the impedance seen by the solar array to keep the PV system operating at, or close to, the peak power point of the PV panel under varying conditions, like changing. Maximum power point tracking (MPPT) is an algorithm implemented in photovoltaic (PV) inverters to continuously adjust the impedance seen by the solar array to keep the PV system operating at, or close to, the peak power point of the PV panel under varying conditions, like changing solar irradiance. Grid-connected PV inverters (GCPI) are key components that enable photovoltaic (PV) power generation to interface with the grid. Their control performance directly influences system stability and grid connection quality. In order to enhance the support capability of photovoltaic inverters for new energy microgrid systems, grid-forming control technology has attracted widespread attention, with Virtual Synchronous Generator (VSG) emerging as a research frontier. This paper integrates hybrid energy storage systems. This paper introduces an innovative real-time intelligent optimization algorithm designed to minimize voltage harmonics in a multilevel inverter.