A method was developed and demonstrated for real time optimization of building CHP systems on the basis of overall system primary energy input. The method uses models of the component load dependent operating characteristics matched to specific electrical and thermal load combinations. The proposed method substantially reduces the size of the search space and associated computational burden. The objective function was determined for the range of possible operating conditions. This allows the optimal prime mover part load ratio and allocation of thermal energy to be determined. The method was demonstrated for a sample daily electrical and thermal load variation, and the real time optimal operating conditions were determined using a search method.