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.

Friday, 18 November 2016

My Open University Proposed Project

I am signed up for TM470 - The Computing and IT project. This starts in January but before then I have to have a proposal for a project which will take 30 weeks to carry out and result in a 10,000 word report. It must be associated with at least one of the Level 3 (Honours level) course that have been followed and it has to be technology related. I spent some time a couple of years ago working on an idea for a freight car routing system. I managed to get a very thin prototype working which had the following constraints:
  • Capable of handling a small railroad
  • Very limited in its routing options
  • Minimal user interface (web based)
It did, however, prove that the idea was feasible. Now, I have to take it to a new level of operation. Well, in fact, I only have to design the project and report on the design. It would be good to have a prototype of the tablet front end and of the routing generator (which is the most complex part of the project). I can't get away with stating that I know that there are other issues that affect car selection and routing as I will be expected to have carried out a thorough analysis of the issues and choices which should be reflected in the design. Anyway, here is what I proposed along with a second post that expanded on the problem domain. Please note that this is written for an audience that a) doesn't know anything about railways and probably isn't interested and b) is based in the UK so doesn't know anything about US railroads - including the terminology that is obvious to us. The background description is purposefully brief so please ignore any obvious "facts" that have been missed.

Freight Car Routing On US Outline Model Railroads

Project Background

US manufacturers etc. are traditionally connected to a “railroad” by local sidings similar to container shipment delivery by road, now. Individual US industries, within towns/cities would be connected to the railroad by their own siding (maybe shared with others) and receiving/sending goods by “freight car”. These sidings would be sited within two “Division” yards. The railroad runs “Way Freights”  between Division yards that are given lists of cars to deliver from the main freight yard to various industries and collect cars from those industries when ready. Freight cars are sourced from other industries on the same railroad or from other railroad systems by an “interchange”.
Additionally, there will be freight trains that move cars between division points. The software will also have to provide for the make up of these.
The proposed system would hold a schedule of all trains and be able to prompt for the next train to be run against that schedule. The railroad will, possibly, run passenger trains within its schedule (even if managed by an outside agency such as Amtrak). The system should allow for these

Model World

  • Requirement to run trains realistically
  • Problem of generating random but sensible outcomes. Becomes harder as the size of the railroad increases. Some (many) model railroads in the USA can exceed 60’x40’ (18m x 13m) so the problem can be of great complexity.
  • Requires  a well-designed workable user interface during operation.

Problem Outline

Designing a multi-user software design for Model Railroad Car Routing

  • Creating the background scenario – available rolling stock – industry destinations – track and train capacities – frequency of service within a database.
  • Creating a rules based software engine design that incorporates random elements to allocate freight cars to locomotives/trains/industries.
  • Able to deal with small railroads as well as large.
  • Creating a flexible user interface for data uploading of railroad stock and industry data for each user.
  • Creating an easy-to-use tablet based touch interface for using the system during railroad operation.


Project to be an Object Oriented software solution providing

User front end (tablet/phone based) – iOS Swift or Android

REST back end server – “Smalltalk/Seaside” based (my in-depth language)

Fast, simple database – likely to be a Key/Value NoSQL – possibly Riak KV

Deliverable to be design and implementation plan ready for coding.


Railroad – US name for a railwayFreight Car – US name for a railway goods wagonDivision – One part of a railroad. Railroads normally comprise of a number of divisions – normally crew and/or engine change points.Way Freight – A Goods train that comprises wagons for delivery at various industry locations along a part of the railroad between home depots. It also collects wagons that have been processed – either loaded or empty – loaded for onward delivery – empty for return to the goods yard.Interchange – A point on a railroad where two companies connect and thus can exchange freight cars for onward delivery – either to a location within the accepting railroad or for onward transmission to a ”foreign” road.Foreign – US railroads are all privately owned. There are approximately 700 railroads, all of which connect to one or more other roads. A foreign road is any other road than the one currently holding a “car”.Car – short name for any railroad rolling stock – hence freight car – passenger car, etc.

Amtrak - Wikepedia -
Smalltalk – Wikepedia -
Seaside – Wikepedia -
Riak KV – Basho -


As some misunderstood what the central problem was, I expanded on the routing generator as follows:

The complexity is actually from the routing issues:
  • A track can only take a loco, a caboose (brake van) and a maximum number of freight cars (depending upon the train type selected).
  • An appropriate loco and, maybe a caboose, must be available (modern trains do not require a caboose).
  • Each freight car needs a destination.
  • The destination has a maximum car limit as well.
  • The destination maybe has a/some cars there already.
  • Industries have car types and loading/unloading times that need to be observed.
  • Some of the cars at the destination may be ready to be moved.
  • If we move them, is there now space for a new car
  • A car, when selected, may have the following:
    * a new destination (possible if the car is loaded or empty)
    * released back into the free pool (if empty and own road)
    * moved off the system towards its home road (if a foreign owned car).
  • and round we go again!
and so on...
It really doesn't matter if there are 5, 10, or 50 possible locations as the 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. 
The smart part of the router will be coping with a possibly large number of cars in the pool. I have some statistics that show 250 cars available for use on a model railroad!
I will keep you informed as this progresses.

Wednesday, 16 November 2016

Scenery and - now - ballast!

We are seeing some action at last. I bought a great spray can from the local Hobbycraft shop. I used this to put a better base colour down. I then did some more work with plaster - and some more paint. I bought a Woodlands Scenics (WS) sprayer and scenic glue. This glue is pre-thinned and contains a wetting agent so it works straight out of the bottle. I know that I could dilute some PVA and add Fairy Liquid (as advised on the MRH forum) but I only have a small railroad and this is very convenient.

I popped into Scograil (our local model railway shop) to get a bottle of WS Fine Grass. Shaking this on and spraying the glue worked perfectly. Out came the trees that I have had stored away for about 5 years and I ended up with something that I am pleased about.

The unfinished building is a Carolina Craftsman Kit - Grizz's Hidden Gems. Not sure what type of industry it is going to be. I am going to make a stone base for it to get it up to rail level. It is an interesting kit. As the cover page says - "Our ZIP-Kits include limited instructions). Limited is the word. Lots of wood strips and nothing to show how to put it together. So, what you get is some laser cut walls, some Tichy Train windows and doors plus some corrugated material for the roof. Apart from that, you are on your own!

The trees on the outside of the track provide nice cover for the curve round the back of the hill. I intend to make a post and rail fence along the front of the hill, overlooking the rail yard, and put some cows grazing there.

I am in the process of putting down some ballast. I bought one of these ballast layers - my one is by a company called"Proses", in Turkey, but it is the same one that Bachmann sell. My ballast is quite fine and it shoots out so I am putting as much effort into doing it as I would if I was just shaking it out directly. 

The ballast is mixed 1:7 with DeLuxe Materials Ballast Magic. This comes with a little spray gun which you fill with water and some washing up liquid. Lay the ballast down and spray it. Job done!

I am amazed that I am getting on with it so well.

I am starting a new Open University course in January. It is a ICT project course that requires me to build a project and make a final report. Seems easy but first you have to have a project that can take 30 weeks to build up to a 10,000 word report! I have decided to expand on my car routing prototype. I will post up the proposal in my next blog entry.