Abstract: An algorithm for training a multiagent control system for an electrical-engineering facility of an oil- and gas-production enterprise with distributed generation has been developed using simulation tools of the RastrWin3 and LabVIEW software packages. The main purpose of the learning algorithm is to provide self-tuning of a multiagent control system in the case in which the system topology and/or principles of interaction between elements change. To assess the operability of the algorithm, a model of the electrical-engineering facility of the Southern Dome of the Yurchuk deposit (Perm krai) has been developed. The multiagent control system is designed to maintain energy balance and enables creating a virtual environment (a digital twin of the electrical-engineering facility of the deposit), which simulates scenarios for training agents. The multiagent control system models the current situations as a Markov process and finds steering scenarios that provide minimal deviations from normal energy-balance indicators. If the operation mode is modeled without using reinforcement learning during the test interval, the energy balance in some scenarios goes beyond the established limits of adequacy. © 2022, Allerton Press, Inc.