An Algorithm to Optimize Speed Profiles of the Metro Vehicles for Minimizing Energy Consumption