Microsoft's first crack at train simulator was quite groundbreaking for its time. They almost produced a follow on, but that development fell through. Their is the Trainz product, which is a decent attempt to "virtualize" your layout. I like the train shed, where you can view your rolling stock and engines...pretty nice. I, however, really like Train Simulator 2013, by a company I believe out of England. They have good NA representation in the product with routes out West and the northeast. They have some DLC content, such as the NS Heritage series and steam locomotives. If done right by the developer many routes have very decent scenarios, such as moving a cut of cars from one location to another and then ending up at this yard. Some scenarios are even timed. If your PC can handle it...the graphics are drop dead excellent.
Both Trainz and Train Simulator have editing tools allowing one to create a route and script in actions, such as computer controlled trains, and other factors. However I find the editors quite daunting. I don't have the time or desire to attempt a route myself but if that is your thing the tools are included.