The deregulated energy environment, among other effects, has favored a gradual transition from centralized power generation to distributed generation sources connected at the medium voltage or low voltage side of the distribution network. Interconnection of small, modular generations and energy storages of low or medium voltage distribution systems forms a new type of power system, which called the micro grid (MG). This paper has developed a methodology of performing the optimal unit sizing for distributed energy resources in MG. The methodology aims at finding the configuration, among a set of systems components, which meets the desired system reliability requirements, with the minimum cost of energy (COE). Other than solar and wind energies, in this study the biogas power plant and the use of urban waste for producing electricity power are considered. The size of biogas power plant is calculated according to available municipal waste. The micro grid system is connected to the utility and can sale its extra produced power to utility. In first step, accurate mathematical models for characterizing standalone photovoltaic module, wind generator, biogas plant, and battery bank are proposed. In second step, based on a breeding particle swarm optimization algorithm, one optimal sizing method is developed to calculate the optimum system configuration that can achieve the customers required loss of power supply probability with a minimum COE. By this methodology, we can analyze MG