According to the characteristics of the microgrid with wind/PV/Battery energy sources, following the random variation of natural factor, the scheduling strategy is proposed in grid-connected mode, which aims at maximizing the utilization of wind and solar energy. Then the model of unit commitment with the objective of minimizing the total operating cost is also proposed, considering different constraint conditions, including power balance constraint, generation capacity constraint, operating constraints of the battery, interactive power constraint between the microgrid and the large power grid. This model is solved by improved electromagnetism-like mechanism. The simulation results verify the correctness and efficiency of the proposed model and algorithm.