To optimize the fare of a high speed passenger railway line, passengers were divided into three groups according to their price sensitivities. The stochastic user equilibrium method was used to formulate an intermediate layer model for elastic demands to different types of transportation and a lower layer one for different transportation products within the railway, and a top layer model with the objective being to maximize railway income was built based on the intermediate and lower layer models. The intermediate and lower layer models were solved by the method of successive averages (MSA), and the whole three-level programming model was solved by a particle swarm optimization (PSO). The result of an example indicates that at the optimal price, a high speed passenger railway line will attract a larger proportion of travelers among different types of transportation and different transportation products within railway.