A combined cooling, heating and power generation (CCHP) system is modeled and optimized. The heat demand in this plant can provide by prime mover, backup boiler, and solar panels. Both the genetic algorithm (GA) and particle swarm optimization (PSO) are used to find the maximum of actual annual benefit (AAB) as an objective function. The design parameters or decision variables are capacity of prime mover, their number as well as their partial load (PL), backup boiler and storage tank heating capacity, the number of solar panels, types of electrical and absorption chiller as well as the electric cooling ratio. Both genetic and PSO algorithms are converged with maximum 0.6% difference. As a result, a diesel engine with nominal power of 350 kW combined with 255 solar panels is selected in the optimum situation. In addition, the optimization results show that the advantage of absorption chiller than the electrical chiller due to the extra availability of heat by the prime mover at the warm season in residential area. Finally, the effect of electric cooling ratio, number of solar panels and solar panels investment cost on objective function are investigated and results are reported.