Management of energy systems is one of the biggest challenges of our time. The daily demand for energy increases constantly for many reasons, including the worldwide spreading of the electrification/decarbonization of vehicles used for public and private transportation. Moreover, the wide use of renewable energies, also aimed at limiting polluting emissions, can create instability in the networks and uncertaintly in energy production. The current production sources and the current infrastructure for transmission and distribution are likely to soon become insufficient to cope with these changes. Decision makers will, thus, need efficient and effective tools aimed at helping them to optimize operational and strategic decisions to be taken in the short, medium, and long term. This course aims at providing the students with the background in mathematical optimization and data science needed to play a fundamental role in the decision-making processes in energy systems. The applications covered will be: production, transmission, distribution of energy; energy markets; renewable energies; smart grids. All these problems are challenging because they include technical, economic, political, and ethical issues. Among the methodological aspects, we will introduce the students to decomposition for large scale systems, linearization methods for nonlinear functions, quantile regression, bilevel and nonlinear optimization.