Stav dette: Optimization and Control in Energy Management: Mathematical Modeling and Simulation