A resource allocation strategy based on the improved Marine Predators Algorithm and KM algorithm is proposed to address the interference problem generated by spectrum multiplex in the coexistence scenario of Train to Train (T2T) communication and Train to Ground (T2G) communication in urban rail transit system while ensuring the user communication quality. First, the throughput optimization model under multiple constraints is developed and decomposed into two sub-problems of optimal power allocation and Channel Multiplex matching. Second, considering the problems of premature convergence and easy falling into the local optimum of the original MPA algorithm, a reverse learning strategy is used to optimize the initial population, improve the step size parameter and introduce the search balance parameter to improve the performance of the algorithm, and allocate optimize transmission power for T2T users and T2G users. Finally, the KM algorithm is used to find the best Channel Multiplex combination. Simulation results show that this algorithm improves the overall system throughput by 5.9% and 7.1% compared with Marine Predators Algorithm and Gray wolf optimization algorithm, significantly improving overall system communication performance.