The future smart grid is expected to be an interconnected network of small-scale and self-contained microgrids, in addition to a large-scale electric power backbone. By utilizing microsources, such as renewable energy sources and combined heat and power plants, microgrids can supply electrical and heat loads in local areas in an economic and environment friendly way. To better adopt the intermittent and weather-dependent renewable power generation, energy storage devices, such as batteries, heat buffers and plug-in electric vehicles (PEVs) with vehicle-to-grid systems can be integrated in microgrids. However, significant technical challenges arise in the planning, operation and control of microgrids, due to the randomness in renewable power generation, the buffering effect of energy storage devices and the high mobility of PEVs. The two-way communication functionalities of the future smart grid provide an opportunity to address these challenges, by offering the communication links for microgrid status information collection. However, how to utilize stochastic modeling and optimization tools for efficient, reliable and economic planning, operation and control of microgrids remains an open issue. In this paper, we investigate the key features of microgrids and provide a comprehensive literature survey on the stochastic modeling and optimization tools for a microgrid. Future research directions are also identified.