The focus is on the optimal design and energy management of stationary and onboard energy storage systems in urban rail transportation. I aim to reduce energy consumption and costs using algorithms, thereby contributing to improved sustainability. Additionally, by incorporating hybrid energy storage systems, other renewable energies, and AI, the research promotes efficient energy use and explores the design of railway systems with minimal environmental impact.