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.

Saturday, 15 October 2016

Starting to build some structures and lay down the scenery

I am always amazed how quickly time goes by when trying to maintain a regular blog! It is now nearly three months since I said anything about the Sunset and North Eastern so here goes.

The track is down and wired up. I dropped the idea of the LED displays in the end because I don't have easy access to the underneath of the railroad now that it is all one big long board. It can be lifted but it is awkward so now that the wiring is done and working, I will leave it as it is.

A reminder: The baseboard is made from 5mm art foam board. The track is all Peco code 83 and has mostly #6 electrofrog points which are all powered by Cobalt Digital point motors. The whole thing is controlled by an NCE Powercab unit. There is a powered USB cable that runs round the room to my iMac which runs JMRI (of course). This then runs the WiThrottle server so that I can control the railroad from my iPad although I tend to use the JMRI panel for the points.

I was looking at having some vinyl back-scenes printed but the cost was a bit more than I liked. I had a brainwave and asked my friend Mark if he could paint some for me. He is an excellent modeller and artist.  He took on the challenge and painted the complete back drop on some spare foam board, all in oils. You can see the results in the images. These are excellent but are currently only placed rather than fixed. There was a "quid-pro-quo" in that I have agreed to design him a web site for his painting - he specialises in painting WWII aircraft and is very good. Once his web site is live I will post the URL - it is worth going there and looking.

I have cut up some polystyrene sheet and layered it as a base for the hills. This was then covered with plaster impregnated bandage and painted. I am in the middle of this and am trying to come up with a decent colour for the base of the scenery. So far, I have used burnt umber, then a white/umber mix. I finally found what I thought was a light brown paint in our local Hobbycraft store only to find out that it was actually gold. As I didn't have the light on when doing the painting on a recent morning, I didn't notice. Turn the light on and it shines! I am trying to find a nice acrylic paint at a reasonable price that will give the effect I want.

I am in the process of building up a laser cut wood craftsman kit from Blair Line - "Greene's Feed & Seed". This is going together very nicely. I intend to airbrush it so have left the window glass out. I will replace this using Microscale Krystal Klear which makes small window glass very easily.

Lastly, I felt that I needed another road loco and found a new Bachmann GP9 on Ebay that came complete with DCC (no sound unfortunately) at $80. I have now got my complete roster including all of the freight cars so I am ready to get going properly.

Anyway, here are a few photos to show you where I am.

Saturday, 16 July 2016

Wiring up the three boards

I originally made the baseboard in six parts using the standard length of the A1 foam board sheets but found that it was better to amalgamate the sheets so that there were only three boards. This kept the complication of switches over joins, etc. to a minimum.

Basic Wiring
I started work on the end nearest the window in the room as that had the simplest layout just the curve and two points. I am fitting the layout out with DCC Concepts Cobalt IP Digital point motors. These give a smooth change for the points and also have a built in feed for frog polarity and for point direction indicators.

First off, I lay out a power bus using copper tape (normally used to stop slugs climbing up plant pots!). I then run droppers down from all of the track positions that will need power and connect them to the appropriate bus.

Point Motors
Each point motor just gets mounted with a nice double side sticky pad (supplied with the motor). I then reinforce this with some foam board hot glued around to stop any twisting motion. Two wires are run from the motor to the power bus and the frog wire is run to the third position. That's each point wire!

The latest motors come with a sticky tab over one end of the motor connector board. This is to stop you putting the power leads into the switch positions. Evidently, this immediately kills the motor and markes it a dud.  This is NOT covered by DCC Concepts warranty. It is, however, carefully explained in the paperwork. I have 8 earlier motors from my previous layout and these do not have a sticker. Guess what? I did it to one of them. $23 later, I have a replacement and a new regime in place to ensure that I don't do it again.

2nd Caution
Make sure that all of your motors are wired up to the same polarity. This isn't as easy as you think. A motor can be mounted in both directions - just think of there being a front (with the point wire) and the back (clear). If you mount one so that it is in the opposite direction, the frog will get the wrong polarity and cause a short as you travel over it.

Thus, you have to ensure that the power feed is inserted in the correct orientation. 

Next, you have to ensure that you get the basic polarity right. Using my NCE controller, I have to enter 1 or 2 when changing the point. 1 and 2 are relative to the orientation so if you want 1 to be the straight route on all of your points, you have to get the feed wires the same for every point motor that faces one way and swap them for every point motor facing the other way. This becomes clearly evident when you read the next part of the blog.

Control Panel
Another nice thing about the Cobalt motors is that you can tap off them to drive LEDs. I have a full blog entry on how I did this. Check out HERE. If you read back from there, you will see all the trials and tribulations I had to get to where I am now with these point motors.

I have also connected a wire from the frog polarity connection through to my LED panel. Fortunately, when I made this, I did it on a breadboard so I can extend the LEDs - there were only 8 points on the last railroad and there are 13 on this one. As a test, I wired up point 8 to the old panel and found that it worked first time.

This is what the underside of the board looks like. As you can see, everything above the baseboard is connected to the two copper power busses and the frogs are connected to the panel with separate wires held down with clamps to the baseboard. Not as tidy as I would like but understandable, nonetheless.

To come back to the polarity of the power feed to the point, not only does it affect the 1 and 2 orientation from the NCE controller but it also affects the colours. Now I like to define a main on each point and like that to be Green on the panel. As the points are set up at the moment, I am getting a red on that so I have to swap over the feed to both points.

Saturday, 2 July 2016

S&NE Track nearly down.

I have laid the bulk of the track. I have found out that I am short of about 3 yards of straight so I have them on order.  In the meantime, I can get on with the wiring and fitting the point motors.

Here is where I am at the moment.

My normal technique is to lay down a DCC bus using self adhesive copper tape and then connect every thing on to the two strips. I am going to us choc block connectors between the boards as, once the wiring is finished, I am hoping not to have to disturb the boards again.

The last loco that I need to run a minimum service arrived the other day from those great guys at "Model Train Stuff". They have great stock and ship very quickly. Unfortunately, the postage from the US to the UK is very expensive - then I have to pay UK sales tax at 20% and a handling charge. Mind you, that is still cheaper than buying in the UK. I bought an MTH F-3A. This will handle the SNEs daily freights to and from New Haven/Boston. It will have to double up as a multitude of locos until I can afford to buy some more units! It will need a respray and some home made decals to get it ino SNE colours.

Wednesday, 22 June 2016

The S& N.E.s place in the world - and in my modelling room!

I have had some reactions to my plans for the new layout. This has caused me to restate the back story for the S&NE. Firstly, I decided to produce a better map, including the real B&M and New Haven.
Firstly, I have renamed Worcester to Sunset (just because I created this railroad name in 1970 for an N Scale layout I was building and it has stayed with me ever since!). As you can see, the B&M never came near Hartford and the New Haven had a long route east and north to get to Boston. The S&NE came into being because places along the actual route felt that they were missing out by not having a railroad. I have also assumed that, because the S&NE served Sunset, the two rail links from the B&M to the town (Worcester actually) were never built. I have left off any routes that aren't involved in this story (NH from New Haven to NY for instance)

Things went swimmingly until the Wall Street Crash. Up to that time, the S&NE ran regular freights and passenger trains from Hartford to Boston and did very well out of it. Following the crash, the passenger traffic fell of, leaving the railroad to finally close the line to passengers around 1933. The 2nd WW gave the freight traffic a big boost but the military personnel trains stayed on the New Haven/B&M route as they had the stock to carry the volumes.

This continued after the war until Budd produced their RDCs. The New Haven saw these as a way to provide a service directly to Boston so that their passengers didn't have to change at Springfield. They started out with three trains a day over the S&NE but slowly reduced it to 1 each way by the time we get to our scenario. You can read, in an earlier blog entry, how this affected the passenger facilities at Sunset.

As it provides a much quicker link between Boston and Hartford, the B&M runs a daily through freight in each direction. This also eliminates the need for switching at Springfield. It also runs a way freight through to Sunset. Both of these routes are headed up by a B&M RS-3.  The New Haven runs their RDC once a day to Boston. The S&NE runs a way freight each day in both directions and a through freight to Hartford.

This gives us the following trains:
B&M Through to Hartford (stops at Sunset for S&NE direct traffic to Hartford) (B&M RS-3).
B&M Return to Boston (stops at Sunset for S&NE direct traffic to Boston) (B&M RS-3).
B&M Way Freight to Sunset (B&M RS-3).
B&M Way Freight back to Boston (B&M RS-3).
S&NE Way Freight to Boston (SNE SW7).
S&NE Way Freight from Boston (SNE SW7).
S&NE Way Freight to Hartford (SNE SW7).
S&NE Way Freight from Hartford (SNE SW7).
S&NE Through Freight to Hartford  (SNE F3A).
S&NE Through Freight from Hartford  (SNE F3A).NH RDC from Hartford to Sunset and Boston (NH RDC)
NH RDC from Boston to Sunset and Hartford (NH RDC)

These, with the switching involved, provide a nice operating session for me.

Note: If I have the geography or the history wrong then I don't care. This story will do me.