An optimization model for a large-scale energy management problem