Distributed microgrid network is the major trend of future smart grid, which contains various kinds of renewable power generation centers and a small group of energy users. In the distributed power system, each microgrid acts as a "prosumer" (producer and consumer) and maximizes its own social welfare. In addition, different microgrids can interact among each other through trading over a marketplace. In this paper, two models are introduced for microgrids to deal with the welfare maximization problems. In the first model, a microgrid is considered as a closed economy group and decides the optimal power generation distribution in terms of time. In the second model, each microgrid can trade with its neighborhoods and thus achieve a welfare increase from making use of its comparative advantage on power generation during a certain period of time. For each model, an efficient solution is presented. Experimental result shows the accuracy and efficiency of our presented solutions.