This round, I have to implement a proper Decision Engine (DE). So far, there is a very simplistic DE. All it does is take the next train and allocate cars to the limit of the train. These cars could come from anywhere on the layout so each train is a fiction.
I now have to start getting a proper DE in place. To do this, we have to do some thinking about the real world and how trains are constructed. We are sure that we will have allocated locos because the schedule of trains should have been built to ensure this. In addition, should there be a need for a caboose, then this should always be in the correct position. If trains fail because of these issues then the train schedule should be amended. Two things that are under full control are loco and caboose placement.
So, we have to think what events create a train. First off, customers will place requests for collections. Secondly, shippers within the railroad will be sending loaded cars for destinations within the cover of the specific train. Should the train be created on staging, then cars can be generated from external sources and actioned from the cars held at the staging (or elsewhere). Everything else is dependent upon the outcome of this analysis. Thus, the DE has to track through every location that could source or require a car and assess any need. Once this analysis is done, there is, theoretically, a train. However, collecting cars from industries that have either been emptied or loaded will always be available but providing empty cars from the yard depends on what is available on site. Note: for the first pass at the full DE, requests for cars that cannot be executed because of the non-availability of empty cars will be discarded. A future expansion of the DE would need to keep the list of non-executed deliveries for allocation to the next available train.
*Next, the total length of allocated cars will be assessed against the permitted length of the train. Should this be exceeded, then a decision will need to be taken regarding cars to be dropped.*
Lastly, the available locomotive fleet will be assessed to provide suitable “front end” power.
This should result in a suitable train. However, should sufficient power not be available, then the processing would revert back to * to reduce the cars by an acceptable number.