Modelling what might have been in southeast BC and northwest Wasington

Roles and car specifications

Ok, so now we have a bunch of attributes that describe a car, but how do we use this when restaging cars? The things that will make use of all of this car attribute stuff are called “Roles”. A Role includes basic shipment information, but it also contains the entire life-cycle of a car from staging, on to the layout, and eventually back to staging. Some of the phases of that life-cycle have the car being moved empty for supply or return, so there really is no shipment for those parts, hence the new name “Role”. Roles now replace the earlier primitive shipment model that made too many assumptions and caused a lot of grief.

Every car in staging that is about to return on to the layout requires a role that governs all of the places that car will go. For every car being restaged, the program searches through all of the available roles to find those that are suitable for that car by considering all of its attributes. Roles contain a Car Specification that gets tested for a match to the car. A very simple example role might say that it wants a “Boxcar:40” and is silent on the other attributes, so they are considered as “don’t cares”, and only the Car Type and Nominal Length of the Car will be considered. In this case, every 40 foot box car waiting to be restaged would be a match.

This is all part of the process that we go through manually with paper Car Cards and Waybill systems during restaging, I just want to capture the essence of the process and automate it.

Roles usually specify a car type and a couple of the other attributes, but the process of matching cars to roles can get quite complex when we start to think about more subtle issues. What if a shipper can accept cars of different lengths, but not just any length, say 40 or 50 foot, but no longer. And how do we handle roles that apply only to specific individual cars and no others, even if they share the same attributes? A good example of this would be captive service between two industries. And of course there is the owner railroad, and reporting marks to consider. The combinations can grow to be quite complex in order to handle all of these special cases, but we still want the system to be easy to define for the much more common simple cases without becoming so complex that it is hard to understand.

This sounds like it is getting very complicated to set up the data, but please remember that all of these fields can be left blank or filled with just an asterisk (*) and they will not be considered during selection. Only a few of the fields will be routinely used, such as Car Type and Nominal Length. 

My solution is to use a series of “Specifications” that each contain a description of which car attributes are “acceptable” to the Role for that piece. The combination of all of these specs is referred to as the Car Specification. So, what is a specification? In simple terms it holds zero or more car attributes that can be matched to a specific car to see if they match or not. The whole notion of a “match” is non-trivial, as we must handle multiple acceptable values, an empty list that signifies that we don’t care about that particular car attribute, and cars that have empty attributes.

Some examples should help makes this clearer. Let’s consider a car’s nominal length. If an industry can accept only 40 foot cars due to loading dock spacing, that would be specified simply as “40”. If it can handle 40 or 50, but no other lengths, it would be specified as “40|50”, where the “|” (vertical bar) signifies “either”. A specification list can hold as many alternatives as needed. In this case, when the role is being considered for a particular car being restaged, it will be included as a possible candidate for any car with a length of 40 or 50 feet. Other actions will affect which role finally gets selected, but it first must be a candidate role that matches the car. The overall selection process does this matching for all non-empty specifications.

On the other hand, if we don’t care about the length of the car, for say a team track, then the specification becomes a simple asterisk, “*”, meaning “don’t care”, and the role will match any car length.

A more complete example would be for a Boxcar, 40 or 50 foot, Clean or High class, with 6 or 8 foot Doors, but we don’t care about a Subtype, or a Capacity. The car specification for this would be:


The complete specification will also include more don’t cares for the initials, number, and owner railroad, but these have not been added in yet.