Based on the mutual coupling effect among the compressor, the air cooler and pipes in the system of natural gas pipeline, innovatively with the goal of minimum energy consumption, this paper established a combined operation optimization model of the air cooler and compressor through the optimization of the switching scheme of compressors and air coolers, which can greatly reduce the production energy consumption of the pipeline system. Moreover, when the air temperature is taken as an optimization variable, the most proper temperature to start the air cooler of each compressor station can be worked out to guide the optimized operation of the pipeline, which is of high value for promotion and application. The case analysis of west-east natural gas pipeline II showed that among genetic algorithm (GA), particle swarm optimization (PSO), and simulated annealing (SA) algorithm that are used to solve the optimization model, the genetic algorithm is the fastest, and the simulated annealing algorithm the slowest, but the optimization results of the simulated annealing algorithm is the best, in which the reduced production energy consumption accounted for 33.77%, testifying the practicability and creativity of the optimization model. INDEX TERMS Natural gas pipeline, air cooler, compressor, operation optimization, algorithm.