This work investigates a control system for HCCI engines, where thermal energy from exhaust gas recirculation (EGR) and compression work in the supercharger are either recycled or rejected as needed. HCCI engine operation is analyzed with a detailed chemical kinetics code, HCT (Hydrodynamics, Chemistry and Transport), that has been extensively modified for application to engines. HCT is linked to an optimizer that determines the operating conditions that result in maximum brake thermal efficiency, while meeting the restrictions of low NOx and peak cylinder pressure. The results show the values of the operating conditions that yield optimum efficiency as a function of torque and RPM. For zero torque (idle), the optimizer determines operating conditions that result in minimum fuel consumption. The optimizer is also used for determining the maximum torque that can be obtained within the operating restrictions of NOx and peak cylinder pressure. The results show that a thermally controlled HCCI engine can successfully operate over a wide range of conditions at high efficiency and low emissions.