Distributed stochastic thermal energy management in smart thermal grids