Abstract This paper presents the principles ot optimal dispatch of heat and electrical power, when the heat and power systems are connected by the cogeneration power plants. The cogeneration system with P units (condensing plants), Q units (boiler plants) and PQ units (cogeneration plants with extraction and back-pressure turbines) are considered. The conditions of optimality using Lagrangian function are presented. In addition to the combined optimization of heat and power the three subproblems are tackled. These subproblems consider the optimal dispatch in different market conditions. A computer program is developed and some practical results are presented.