This research project is modelling a future electricity grid, regional or microgrid, with a high penetration of power electronic connected (PEC) devices, distributed and utility scale. PEC connected devices include renewable energy (wind and solar) generators, battery energy storage systems, electric vehicles and electrical loads. We apply reactive and predictive control techniques to optimise the operation of the power system while maintaining security and reliability of supply. Optimising the operation of this stochastic network involves time series analysis to estimate the distribution of supply-side (wind and solar power) and demand-side (received load) random variables.