Optimal Management Strategy of Energy Storage Systems for RES-based Microgrids