Effective waste heat recovery is a key solution toward meeting the increasingly stringent fuel economy and CO2 emission standards. In this paper, the cogeneration of electricity and freshwater was devised to recover the waste heat of a Diesel engine. The dual-pressure Kalina cycle and the humidification-dehumidification desalination system were used for power generation and freshwater production through exhaust gas energy and jacket water energy, respectively. In addition, energy, exergy, exergoeconomic, and economic analyses were applied for modeling the proposed system. The optimum performance of the system was determined by applying the multi-objective genetic algorithm. A parametric analysis was also performed to assess the effect of various parameters on the system's performance. The feasibility of the plant for investment was studied using the net present value (NPV) and payback period concepts. Based on the findings, the maximum exergy destruction rate was obtained for the condenser with a value of 39.88 kW. Moreover, the payback period and NPV values were calculated to be 7.4 years and 165814 $ for the electricity price of 0.09 $/kWh. For the ηex-NPV-SUCP optimization scenario, the optimum values were obtained to be ηex=34.85%, NPV=0.260 $M, SUCP=51.33 $/GJ, W˙net=83.55 kW, m˙fw=0.115 kg/s, and PP=5.67 years.