This paper presents adaptive bacterial foraging optimization (ABFO) algorithm to optimize the planning of passive power filters (PPFs) and distributed generations (DGs) in distribution system with presence of heavy nonlinear load simultaneously. The amount of nonlinear load is assumed to be serious which enforced the system planner to utilize the PPFS. Also the power loss minimization, reliability and voltage profile improvement, and other benefits encouraged the planner to employ the DGs.Some of DG technologies, such as wind generators and solar cells are based on power electronic devices and inverter implementation. Connection of this type of DGs to system produces harmonic. Therefore the utilization of PPFs among existent capacitor busses for harmonic compensation is inevitable. The objective is to minimize the power loss, the total harmonic distortion (THD) and the investment cost of PPFs and DGs simultaneously. Constraints include the voltage limits and the limit candidate buses for PPFs and DGs installation. The harmonic levels of system are obtained by current injections method and the load flow is solved by the iterative method of power sum, which is suitable for the accuracy requirements of this type of study. It is shown that through an economical planning of PPFs and DGs, the total voltage harmonic distortion and active power loss could be minimized simultaneously.