Real-time minimization power losses by driven primary regulation in islanded microgrids