Energy is one of the most important pillars in any production system. Recent studies show that with increasing energy consumption in manufacturing industries, energy efficiency is one of the most important challenges in factories. On the other hand, reducing energy consumption may increase delays in the delivery of production orders. For this reason, in this paper, a new mathematical model is presented to optimize the workshop flow with the aim of reducing energy consumption, reducing completion time and reducing latency. In this mathematical model, the limitations of using machines and determining the speed level for each machine are considered. In order to validate the mathematical model, a numerical problem is designed and the results of its optimization are examined and analyzed. Also, the relationship between energy consumption, completion time and delay time has been studied and analyzed, as well as the effect of machine speed on each of the objectives of the mathematical model. © 2021 KIIE.