The optimized layout of electric vehicle (EV) chargers is not only crucial for users' convenience but also a key element in urban sustainable development, energy transition, and the promotion of new energy vehicles. In order to provide a basis for the problem of localization and capacity determination of chargers and compare the merits of several mainstream algorithms, this paper first establishes an optimization model with the objective of minimizing the total investment cost of all the chargers and the constraint of meeting the charging demands of all electric vehicles. Optimizations were performed using genetic algorithm (GA), surrogate optimization algorithm (SOA), and mixed integer linear programming (MILP) algorithm, respectively. In the case of using MILP, the original nonlinear optimization problem was transformed into a linear problem. In the planning of city-level EV chargers, MILP took 14182.57 s to calculate the minimum cost of 34.62 million yuan. After retaining only 10% of the original data amount, SOA took 87651.34 s to calculate the minimum cost of 3.01 million yuan. The results indicate that GA is prone to falling into local optima and is not suitable for large-scale optimization problems. SOA, on the other hand, requires significant memory consumption, so the issue of memory usage needs to be carefully considered when using it directly. Although MILP is only applicable to linear programming problems, it has the advantages of lower memory usage and higher reliability if the problem can be transformed into a linear one.