In this thesis a scenario-based two-stage stochastic programming model is proposed to solve a microgrid's tertiary control optimization problem taking into account some renewable energy resource s uncertainty as well uncertain energy deviation prices in the electricity market. Scenario generation methods for wind speed realizations are also studied. Results show that the introduction of stochastic programming represents an improvement over a deterministic model