In the context of the energy transition, research on the creation of integrated energy systems and their control is an actual task. They combine a significant share of renewable energy sources, contribute to the overall efficiency of the system, and enable active consumers to participate in the energy supply process. At the same time, in connection with the growing capacity of distributed energy sources, new problems arise related to the operation of distribution networks and difficulties in adapting the operation of active consumers in the centralized energy system. Active consumers can regulate their energy consumption by distributing the load between centralized and distributed energy sources, and as a result, they can provide flexibility, maneuverability in the operation of the system and increase the efficiency of its redundancy. To organize the work of active consumers in an integrated energy system, a multiagent approach is used. This approach is widely used by researchers to solve various practical tasks. Allows us to represent active consumers in the form of agents with an individual behavior algorithm and organize their interaction with the energy system to ensure optimal energy supply. The proposed mathematical model for finding the optimal composition of generating capacity takes into account the structural organization of centralized and distributed energy sources, as well as the participation of active consumers in the process of energy supply. Modeling of an integrated energy system and carrying out a computational experiment based on multiagent technologies are performed in the AnyLogic software environment.