exupero's blog
RSSApps

Penny game work in progress

In the previous post I created a basic simulation of a manufacturing line. We ran the line for 100 iterations and looked at the total output. Total output gives us an indication of the line's revenue. For us, the line's output was:

(def steps
  (simulate initial-state update-state 100
    (fn [roll]
      (repeatedly 7 roll))))
(total-output steps)
290

But a manufacturing line also has expenses, among them its material input:

(defn total-input [steps]
  (transduce
    (map #(-> % :incoming (or 0)))
    + steps))
(total-input steps)
337

The difference between the number of pennies that have gone into the line and the number of pennies that have come out is a result of how many pennies are currently being worked on by the line. We can see how much work in progress there is for each step. At the beginning, there are 24 pennies in progress:

(defn work-in-progress [step]
  (reduce + (step :stations)))
(work-in-progress (first steps))
24

At the end, however, there are quite a few more:

(work-in-progress (last steps))
71

If we graph the amount of work in progress for each step, we can see it growing:

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

Work in progress is another expense faced by a manufacturing line; we need somewhere to store all that material, as well as people and equipment to move it around. Thus, if we want to optimize our line, we should not only maximize output but minimize work in progress. We'll experiment with more productive stations in the next post.