With the wide application of distributed generation technology, in order to maintain the stable and safe operation of the distribution network, this paper considers the uncertainty of power generation and a load of distributed energy storage. It takes the distribution network with distributed energy storage as the research object, models and analyzes the optimization problem, and studies the problem of DG configuration by using the reinforcement learning method. In the case of distributed grid connection, the voltage distribution change of the distribution network and the impact of network loss are analyzed. The line power flow of the distribution network is calculated by using the MATLAB platform as a platform, and the power flow calculation of the distribution network is simulated and analyzed by the MATLAB platform. The system loss is significantly reduced. The experimental results show that the system loss variance is 29.19. After adding energy storage, the loss variance is 14.77, which is reduced by 49.41%. According to the scheme, the voltage stability and operating loss of the system can be effectively improved.