Sunday, 27 November 2016

University Project Part 2

The core of the project is the random engine.

The complexity is actually from the routing issues:

  • Each freight car has a destination.
  • The destination has a maximum car limit as well.
  • The destination maybe had a/some car/s there already.
  • Each car has a destination has a loading/unloading time*
  • Some of these may be ready to be collected.
  • If we collect them on this train, could this generate a demand for a replacement car
  • and round we go again!

Determine the next train

  • Select all of the possible cars in the yard that are available to be shipped (excluding empties).
  • Select all of the cars on the route that are ready to be collected (either because they are empty or are now loaded - and have been at their current location for sufficient time (see * above)
  • Use a randomiser to provide a list of cars up to the defined maximum car number for the train (it is possible that the number of cars is less than the maximum, but that is OK). 
  • Assess the cars to be collected on route (remembering that empty cars can be skipped if required)
  • Assess the effect of these collections against the train length at each pickup/drop off location.
  • If the number exceeds the maximum train length, re-assess the list until everything is OK.
  • Once the train is  defined, calculate the weight of the train and allocate sufficient head end power.
  • If sufficient power is not available, reduce the length of the train accordingly - use the randomiser once more to decide on the final make up.

Complex Routing

The other interesting thing is that some cars have a complex routing requirement. let us take an example from the Pacific Fruit Express (PFE) back then when they used refrigerator cars that were chilled with block ice.  Let us say that the PFE storage yard is somewhere north of Los Angeles, CA. It might go as follows:
  1. The car is sitting on a storage track
  2. It needs icing at the Ice House
  3. It is then shipped to the appropriate fruit packing company (maybe there are 3 with sidings on our division so it could be any one of three.
  4. It is loaded (1 day)
  5. It is collected and shipped to its destination
  6. It is returned to the storage track for cleaning and awaiting the next time.
This is further complicated because these three fictitious fruit packers send their fruit to different destinations
  1. Ships to Oregon so their cars go north and transfer to other railroads
  2. Ships to Chicago so their cars go east and transfer to other railroads
  3. Ships to San Francisco so theirs stay on the home road
and so on...

Train Length

Initially, train length is determind by the number of cars that shuld be routed - taking into consideration that each and every industry has a frequency of cars attached. This means that it is possible for a train that is allocated a length of 10 cars may only be allocated 2 or 15. below the defined train limit, there is no issue but if the number is above then the randomiser will allocate cars to be dropped. 

However, the ultimate limit is set by the train length. This, in itself, is set by a few factors - the power of the loco, the weight of each car and also, because it may meet other trains en-route (most US railroads are single track), the length of a siding that it can get into to get out of the way. The power of the loco isn't that important as you can always connect a second (or even third or fourth) loco. It is the siding length that is the ultimate limiter consequently, the maximum train length is one of the attributes of the train itself. This may differ by train type. If the train is a local/way freight then the limit is the shortest siding at locations along the route. If it is a through freight then the limit would be any siding on the main line. Passing sidings are not necessarily at a town or industry along the route but just may be on the main line for efficiency's sake.


In American terminology what we in the UK call a siding as named a "spur". A siding, in US terminology, is a length of track parallel (usually)to the main track and connected at each end by a point (US - switch). This provides a "hole" for one train to go into thus getting out of the way of a, second, oncoming train. This is not something that we see often in the UK as very little of our routes (apart from a few branch lines) are single track.
This will be a fun bit of code to plan and implement.

1 comment:

Meadow55 said...

I had a go at this a number of years ago; and am about to have another go at it now (I was heavily sidetracked by major work commitments, which is why it was untouched for so long). My attempt at that time was called MOPS, which was a variation on TOPS (the BR operations system that was bought from Southern Pacific way back when). I wrote the original version in Python; I'm intending to write the new version in Lazarus (a Delphi clone).

The critical thing is, of course, the data design. I did have a lot of feedback, at the time, from a Southern Pacific group which did feed into the design. It wasn't a straightforward Car-and-Waybill system - I had taken it a little further than that.

MOPS can be found at there might be snippets you can use from the User Guide eg on generating routes, creating meaningful industries rather than random generation, etc.

Very best of luck to you on this!