exupero's blog
RSSApps

Productivity improvements in the penny game

In the previous post we looked at how our basic manufacturing line accumulated work in progress, which increases expenses. A first reaction to fixing this is to increase productivity. We can represent that in our simulated manufacturing line by increasing the value of dice rolls. Productivity improvements don't usually improve every station on a manufacturing line, so let's see what happens when we increase the productivity of all but one station:

(defn more-efficient [rolls]
  (map-indexed
    (fn [i roll]
      (if (= i 4)
        roll
        (max 4 roll)))
    rolls))

The fourth station will continue to operate as it did in the previous simulation, but the other stations will always process at least 4 pennies, and sometimes 5 or 6:

(more-efficient (repeat 7 1))
(4 4 4 4 1 4 4)
(more-efficient (repeat 7 5))
(5 5 5 5 5 5 5)

(In this case, an index of 4 does indeed represent the fourth station, since the zeroth value in the list represents what's incoming to the first station.)

Let's run the simulation with our improvements:

(def improved-steps
  (simulate initial-state update-state 100
    (fn [roll]
      (more-efficient (repeatedly 7 roll)))))

Here are the outputs of both scenarios:

Output
Original290
Improved336

The productivity improvements have increased the output. Unfortunately, they've also increased the input:

InputOutput
Original337290
Improved440336

The amount of work in progress has actually gotten substantially worse:

Work in progressStep 10Step 20Step 30Step 40Step 50Step 60Step 70Step 80Step 90Step 1000265278104130

If we look at the final state of the simulation, we can see where the problem is:

(-> improved-steps last :stations)
(4 15 4 100 2 3)

The station that didn't improve has a lengthy backlog. The manufacturing line as a whole is only as productive as its slowest station, an fact from which we get the name "theory of constraints".

Work in progress has increased because the first station is producing more for all those after it, but pennies pile up at the station that doesn't produce as much. If we want to reduce the amount of work in progress, we'll have to limit how many pennies are let into the line.