Reactive control strategies lack the flexibility necessary to optimize the operational costs of buildings and district systems. To overcome this limitation and to enable the transition to model predictive control strategies (MPC), the development of dedicated control platforms and models is required. Predictive models for district systems management should provide supply and demand side integrated modelling, high accuracy, generalization capacity and reduced computational times. However, traditionally available MPC solutions do not meet these requirements as simplified models offer short computational times but lack the required accuracy; detailed physics-based models provide satisfactory generalization but at the expense of high computational costs; and the generalization capacity of data models is constrained by the quality and availability of data. In contrast, metamodels developed through the combined use of physics-based models and machine learning techniques offer a powerful alternative at reduced computational cost. This paper describes an upgraded Integrated District Model concept developed through co-simulation coupling metamodels of buildings with a district heating infrastructure Modelica model. Furthermore, the process to produce the metamodels and optimization engine required to generate demand flexibility optimization functionalities for the buildings of the Stepa Stepanovic subnetwork (Belgrade) is depicted. Starting from the development of metamodels of instances of specific buildings (residential and educational use) the process was expanded to provide additional generalization to define, (1) a generic metamodel with the capacity to reproduce the behaviour of any instance of building of the residential typology, and (2) metamodels with generalization capacity in relation to operational settings. As part of this process the potential of several machine learning algorithms (e.g Support Vector Machines, etc) was evaluated including the latest ensemble boosting methods (e.g. Adaboost, Gradient Boosting and Extreme Gradient Boosting) with comparatively low use in the building simulation community. Finally, a virtual test bed consisting in metamodels coupled to an optimization engine based on genetic algorithms, was implemented, and compared to a traditional Physics-based model MPC solution (EnergyPlus-GENOPT), to evaluate the potential of the developed building level optimization functionalities. The metamodels and optimization engine were able to reproduce the optimized settings identified by the EnergyPlus-GENOPT MPC solution with cost savings potentials of 5–10%.