Various Smart Grid (SG) technologies and concepts are currently under investigation, driven by the goals of energy transition policies towards future sustainable, reliable and affordable electricity supply systems. This paper presents an approach for modeling the interaction between the Smart Grid and Building Energy Management Systems (SG-BEMS), using Multi Agent Systems control. The interaction consists of three layers: the smart building, the neighborhood, and the distribution grid. It enables the continuous bidirectional flow of energy and information between SG and BEMS. The proposed framework combines optimization techniques inspired by dynamic game theory and stochastic optimization algorithms. The goal of the optimization is to incr...