Modelling, optimization and control of energy systems