A controller for controlling a combined heat and power (CHP) system which can include one or more CHP units, can comprise a high level optimizer and one or more low level optimizers. The high level optimizer can be configured to optimize a total cost of producing heating, cooling, and electric power, by allocating total heating, cooling, and/or electric power setpoints one or more CHP unit types, based on the fuel price, CHP unit operational constraints, and/or heating, cooling, and/or electric power demand. The low level optimizer can be configured to allocate cooling, heating, and/or electric power setpoints to individual CHP units, based on the high level allocation to CHP unit types.
 The disclosure described herein was made during the course of or in the performance of work under U.S. Government Contract No. 4000009518(17) awarded by the Department of Energy.