One of the important factors in the discussion of power transmission is filling the capacity of network lines, which limits the transmission of power and increases the locational marginal price (LMP) in the network. Today, one of the techniques for resolving congestion and reducing LMP is to install DG units in the network, taking into account two factors: place and optimal size of DG based on operating costs and network constraints, all of which depend on the awareness of the capacity of network lines. In this article, in the first step, using the GA-GSF algorithm, identifying the network's weaknesses such as the lines that have reached their maximum capacity, and then by considering three terms and two scenarios condition of the buses connected to the filled lines will be discussed and we review and extract the best places for installing DG on the network. Then, considering the cost of operating DG and applying it to the objective function of the problem, by positively denoting DG profit and reducing line congestion, the optimization problem is solved by GA-GSF algorithm, and finally, the algorithm output including place and optimal size of DG unit in the network is minimized by line congestion and LMP, and DG installation is economically justified. Finally, the proposed algorithm was tested on the IEEE 14-BUS network for seven different DG types, and the results were such that out of these seven DGs, three DGs were able to reduce the total capacity of the network lines to less than the full capacity of the lines and the price of LMP has been raised to the price of UMP, and the other four DGs have managed to lower the price of LMP compared to their cost function.