The current energy system is changing, mainly due to the rise of global energy consumption and the depletion of fossil energy sources. Regarding the electric power system, such changes constitute a significant challenge to the electricity grids and call for the development of smart grids. The smart grid is capable of monitoring individual energy consumption, integrating renewable energy, and supporting twoway communication between the grid operators and the customers. Moreover, to meet the requirement of the Paris Agreement, which predicts that the world needs to reduce 1170 giga tons of the cumulative CO 2 emissions between 2015 and 2100, promoting electric vehicles (EVs) and installing renewable energy resources are two main trends in policy making to reduce our dependency on fossil fuel resources. With more and more installation of renewable energy resources, uncertainties associated with renewable energy generation should be addressed when operating the smart grid. That is, weather conditions may influence renewable energy production, and therefore the controllability of that production is not the same as the conventional power generators for the grid operator. Other than the uncertainties associated with renewable energy generation, the maintenance of the generators raises a new challenge to the operator as the renewable energy generators are usually placed at locations with hazardous environments.Apart from the operator side, customers on the traditional power grid can install renewable energy resources in their households (e.g., solar panels on the rooftop). Therefore, customers can be separated into two categories in the smart grid, namely consumers and prosumers. The consumers only consume energy, and the prosumers can both consume and produce energy. The renewable energy production of the prosumers may be larger than their own consumption, and therefore they may want to sell their energy surplus. However, the price of selling energy to the external market is lower than the spot price in the external market. Therefore, peer-to-peer (P2P) energy trading is a much more attractive alternative than selling surplus generation in the external market. The electricity prices in the external market are generated in real time so that both the consumers and the prosumers also need to consider the uncertainty related to electricity prices to form the best strategies. By doing so, the consumers can obtain the minimum electricity costs, and the iii iv Chapter 0 prosumers can increase their revenue.Another method for reducing CO 2 emissions is to promote EVs. However, charging a huge number of EVs simultaneously may cause a sudden increase in energy consumption, and therefore the charging tasks of EVs must be controlled to avoid consuming a considerable amount of energy from the power grid in a short time. Although energy production from renewable energy resources can relieve this situation, the deployment of renewable energy sources cannot satisfy the surge for more energy from an increasing number of EVs. To this end...