An electric vehicle (EV) charging method which considers the EVs heterogeneity, taking into account the absence of any information about future arrivals and departures, and of the amount of time any charging will take. The method further considers both switch on and off possibilities and not an arbitrarily small minimum charging power. In order to achieve all these objectives, the invention defines novel metrics and uses them to construct a dedicated optimization problem. As the charging power is discontinuous, the minimum charging power not being arbitrarily small, the optimization problem is mixed integer by nature. Further, because the mixed-integer optimization is difficult to perform in real-time, the invention proposes a heuristic for reducing the number of integer variables, thus reducing the complexity of the problem.