In this study, a microgrid scheme encompassing photovoltaic panels, an energy storage system, and a diesel generator as a backup supply source is designed, and the optimal placement for installation is suggested. The main purpose of this microgrid is to meet the intrinsic demand without being supplied by the upstream network. Thus, the main objective in the design of the microgrid is to minimize the operational cost of microgrid’s sources subject to satisfy the loads by these sources. Therefore, the considered problem in this study is to determine the optimal size and placement for generation sources simultaneously for a microgrid with the objectives of minimization of cost of generation resources along with mitigation of power losses. In order to deal with uncertainties of PV generation and load forecasting, the lognormal distribution model and Gaussian process quantile regression (GPQR) approaches are employed. In order to solve the optimization problem, the lightning attachment procedure optimization (LAPO) and artificial bee colony (ABC) methods are employed, and the results are compared. The results imply the more effectiveness and priority of the LAPO approach in comparison with ABC in convergence speed and the accuracy of solution-finding.