Every CNG station includes two main parts: a compressor equipped with inter- and after-coolers and a fast filling process (FFP). In this study, both processes were simulated in a FORTRAN based computer program. To model the compression process of real natural gas, the polytropic work of a three-stage compressor was considered. Moreover, the FFP was modeled based on mass conservation and first law of thermodynamics for a non-adiabatic cylinder. Due to high operating pressure, AGA-8 equation of state (EOS) was utilized for accurate computation of necessary thermodynamic properties. Both applied models for compression and FFP were compared with the real data. In particular, the FFP model was evaluated using experimental data obtained from an operating compressed natural gas (CNG) station in Sanandaj, Iran. The comparison showed a good agreement between model and experimental data. In the last part of this paper, the best operating condition for attaining either the minimum energy consumption in compressors and coolers or the maximum final accumulated mass of gas within NGV cylinders was determined using particle swarm optimization (PSO) algorithm.