Focusing on the freight-train dominant electrical railway power system (ERPS) mixed with ac-dc and ac-dc-ac locomotives (its power factorε[0.70,0.84]), this paper proposes a power factor-oriented railway power flow controller (RPFC) for the power quality improvement of ERPS. The comprehensive relationship of the primary power factor, converter capacity, and the two-phase load currents is built in this paper. Besides, as the main contribution of this paper, the optimal compensating strategy that suited the random fluctuated two-phase loads is analyzed and designed based on a real traction substation, for the purposes of satisfying the power quality standard, enhancing RPFC's control flexibility, and decreasing converter's capacity. Finally, ...