1. A method for energy management, comprising: receiving, by electronics in a microgrid, parameters from energy management system components; generating a stochastic model for electric vehicle (EV) operation as mobile energy storage (MES) for optimal planning, operation, and control purposes; solving an optimization problem for optimal planning, operation, and control purposes; controlling operation of EVs according to the optimization model to lower operating cost and emissions; controlling operation of EVs according to the optimization model to ensure a predetermined level of reliability; and modeling the EVs for optimal planning, operation, and control using an MES energy balance equation: e mes , t , s = ( 1 - Φ mes ) ⁢ e mes , t - 1 , s + τ ⁡ ( p mes , t , s chg ⁢ η mes chg - p mes , t , s dch η mes dch ) + E mes , t , s conn - E mes , t , s disc where E mes,ts conn and E mes,ts disc represent stochastic energy level of EVs connected to and disconnected from at time t in scenario s, respectively and wherein energy storage levels of EVs are limited by minimum and maximum available capacities of the EVs at each time interval in each scenario, E mes,ts and Ē mes,ts respectively, as follows: 
 SOC mes,s Ē mes,ts ≦e mes,ts ≦ SOC mes,s Ē mes,ts where minimum and maximum available capacities of the EVs are calculated using following equations: 
 Ē mes,ts =( Ē mes,t− 1,s +Ē mes,ts conn − Ē mes,ts disc ) 
 E mes,ts =( Ē mes,t− 1,s +Ē mes,ts conn − Ē mes,ts conn ).