Electrification of rural areas: Optimal microgrid energy management