This study introduces a method for energy reduction in freight train operations by integrating goal programming with the A* algorithm into the train simulator, NeTrainSim. The method optimizes a single train’s operations accounting for leading train interactions, terrain, and current and future track characteristics (speed limit, gradient, curvature). Locomotive notches represent throttle levels within a discrete tree search space, creating potential trajectories for a scanned lookahead distance. The computation and optimization of train movement are managed by a dual clock system - the primary simulation clock and the heuristic clock. The heuristic function estimates energy usage for different notch levels per time step, achieving energy-efficient operations. To validate this method, two case studies were conducted, mirroring train characteristics to empirical data and utilizing a train-following model. The model demonstrated substantial energy savings potential, achieving up to 25% energy savings with significant increases in travel time (70%). Using a multi-objective function (considering energy and travel time) a balance between energy savings and travel time increases can be achieved depending on the weight assigned to energy consumption. This research signifes the substantial potential of algorithmic optimization in freight train systems.