The Goldratt Dice Game with Python Mesa ...

The Goldratt Dice Game with Python Mesa library

May 06, 2024

Introduction: Exploring the Theory of Constraints through Simulation

The Theory of Constraints (ToC) is a management paradigm that focuses on identifying the most significant limiting factor (i.e., constraint) that stands in the way of achieving a goal and systematically improving that constraint until it is no longer the limiting factor. Developed by Dr. Eliyahu M. Goldratt in his seminal book The Goal, ToC has revolutionized how organizations approach process improvement and management decisions. By simplifying complex systems and focusing on the constraints that truly affect performance, ToC helps organizations enhance throughput while reducing operational expenses and inventory levels.

The Goldratt Dice Game, a simulation rooted in these principles, serves as an educational tool that illustrates the dynamic nature of constraints within a production system. Using the dice game, individuals can visualize how variations in process outputs can lead to significant fluctuations in system performance. This simulation not only reinforces the fundamental concepts of ToC but also provides a hands-on experience in managing and optimizing workflows. The upcoming article will dive into a Python-based implementation of this game using the Mesa library, showcasing how even simple simulated environments can mimic real-world operational challenges and highlight the impact of strategic decisions on overall system efficiency.

Simulation Overview: Dynamics of the Goldratt Dice Game

The Goldratt Dice Game simulation provides a practical framework for understanding the flow of operations in a manufacturing or production system. At the heart of this simulation are five agents, labeled from A to E, each representing a stage in the production process. These agents interact within a controlled environment to demonstrate how variability and capacity constraints impact overall system performance.

Each agent in the simulation is defined by two primary attributes: capacity and variability. The capacity of an agent denotes the maximum number of units it can produce per turn, while variability introduces an element of unpredictability, simulating real-world fluctuations in production rates. For instance, if an agent has a capacity of 10 units with a variability of 3, it means that in any given cycle, the actual output can range anywhere from 7 to 13 units, depending on random factors.

The interaction between agents is sequential, where each agent's output becomes the input for the next. This setup highlights the cascading effect of variability across the production line. For example, if Agent B cannot process all items received from Agent A due to its capacity limits or variability, it creates a backlog, affecting the throughput of the entire system.

This simulation framework is designed to mimic real-life production challenges and provides a visual and quantitative analysis of how constraints within a system can lead to significant operational inefficiencies. Through this simulation, stakeholders can learn to identify and strategize around such constraints to optimize workflow and enhance productivity.

Code Walkthrough: Understanding the Goldratt Dice Game Simulation

The Python-based implementation of the Goldratt Dice Game utilizes the Mesa agent-based modeling framework to simulate a production process influenced by constraints and variability. This section provides a clear breakdown of the simulation's code, focusing on its key components and their roles in the simulation.

Agent Definition and Initialization

The ProductionAgent class represents the agents (A through E) in the simulation. Each agent is initialized with a capacity and a variability, which determine the range of production outcomes for each step of the simulation. Agents also maintain a buffer to hold processed items, simulating the inventory at each stage:

 

Production Logic

The step method in the ProductionAgent class defines the production logic for each agent. If the agent is the first in the sequence (Agent A), it simply adds its production output to its buffer. Subsequent agents draw their input from the buffer of the preceding agent, simulating the flow of materials through the production line:

Data Collection and Visualization

The ProductionModel class collects and visualizes data on the production process. The DataCollector object gathers data on buffer sizes and throughput, which can be visualized using Mesa’s built-in modules. This helps in understanding the dynamics of the system and the impact of constraints:

 

Running the Simulation

Finally, the simulation environment is set up with visualization components like CanvasGrid and ChartModule, and model parameters such as agent capacity and variability are configured using sliders. This setup allows users to interact with the simulation and observe the effects of different configurations on system performance:

Simulating the Open Loop system

Let’s begin with simulating the simple open-loop system, use the file GDGame.py.
Each work center A B C D E produces accordingly to its own turn capability, if there are excess elements because the following workcenter is unable to consume the amount the excess is stored into a seemingly infinite work in progress (WIP) buffer. It should be noted that in the real code the WIP has a limit of 1000 elements for each agent but for our target simulation duration of around 300 turns this is equivalent to infinite.

In the default settings all work centers have the same average capacity 10 and variability 3. Below the result of 1 run up to 305 steps.

 

There is already a significant insight, the variability can create huge variations in the total inventory, here in orange. Be really aware this is a proxy for the time it takes for an order to get out of production. Furthermore, in principle you don’t know where inventory is accumulating.  Can you imagine the people screaming at piles of work in progress inventory while some others are empty. In 305 steps we generated 2978 parts to sell.
As expected, this reflects in the significant variability of throughput even when averaged out with a moving average of 10 turns.

 

 

Simulating the Kanban wip limited system

Let's continue by simulating the Kanban WIP-limited system using the file GDGamekanbanwiplim.py
The idea here is to significantly limit the work in progress (WIP) by selecting a WIP buffer size that is approximately three to five times the variability of each step. The idea is that the WIP buffer should be big enough to absorb variability and small enough to ensure total inventory buildup is below a reasonable value. If we keep the same settings as before we have capacity = 10 and variability = 3 for all agents. We could set a buffer limit of 12 (4x the variability) or more prudently 15 (5x the variability).

Limiting the wip has clearly the notable effect to avoid inventory build up, as you notice, still we are paying a price because without a clear triggering system and protection mechanism there are instances in which our production stalled and we essentially left orders out of the system, we somehow consciously decided to give up some sales for the sake of better service time, and better sales cycle because less latency in the system, less inventory, means cash spent in input material is converted faster in new cash through sales.

Conversely, we could choose to invest more in certain work centers, in exchange for greater throughput, and concentrate variability and protection at one point—the constraint. Without changing the file, if we put A B D E to 12 and we make the buffer B (upstream to C constraint at 10 ) much bigger, 30, we should be able to concentrate protection and make the management of the wip easier.  We keep the other buffer only 3 times the variability thus 9.

The pace stability has improved; we are consistently between 8 and 9. Most of the inventory is concentrated in B as expected, yet despite having increased the capacity of all steps to 12, except for C, we are seeing fewer sales. Effectively we are still burning some holes in the protection buffer, this means the protection is not adequate, or better we are not using it adequately.

Why are we burning hole in the B buffer? because C is too fast. We never allowed to build up protection in first place. We need to change slightly the behaviour of our agents, C needs to wait for a while to let the buffer build up to a reasonable level, say 15, and A needs to work to keep the buffer at a safe level, say above the half buffer threshold.  If we do so we are effectively creating a buffer rope mechanism and we are letting the buffer create some protection amount. We are getting to DBR.

Simulating the DBR system

Let’s continue with simulating the DBR system, use the file GDGame_DBR.py.

The agent behavior has been modified as follow.

A slows down a little (.9) when Buffer B is higher than 50%. This is to avoid excessive buildup of buffer A. and concentrate protection and management at buffer B the one that is effectively protecting the constraint.

C agent start working only when we see enough protection at buffer at the beginning, ie 50% full. This way we avoid to burn holes in the buffer at the very beginning.

 

In this scenario with all agents at 12 capacity except C at 10 and all buffer at 15 (12+3) except B at 30 we get the following behavior

The buffer is limited at B and is never higher than 28. And we don’t see significant holes.

Production in 305 steps is 3022 with a theoretical target of 3050. But with respect to the open loop case there is definitely better cash cycle and easier management as we only need to check one buffer by design.  This final version of he code somehow hardcode some behaviour to avoid cluttering too much the GUI but you will be able to download the code and modify it if you wish.

 

Summary table

 

Modifications for Kanban and DBR Implementations

Both Kanban and Drum-Buffer-Rope (DBR) are implemented in the simulation to control and mitigate the issues identified in the open-loop version, such as inventory buildup and variability impacts. The primary modification in both systems involves introducing mechanisms to limit Work-In-Progress (WIP) and manage the flow through the system more effectively.

Kanban Implementation:

  • WIP Limits: Each agent (or production stage) has a defined WIP limit, which prevents it from accepting more work if it would cause the buffer to exceed this limit. This ensures that production is only triggered by demand from downstream, adhering to the pull-based system that is central to Kanban philosophy.

Drum-Buffer-Rope Implementation:

  • Drum: The rate of production is set by the "drum," which is the slowest or most critical resource in the process, dictating the pace for the entire system.

  • Buffer: Buffers are strategically placed before the drum to ensure it always has work to do, preventing downtime and accommodating variability.

  • Rope: The rope mechanism synchronizes the upstream activities with the drum, ensuring that production does not outpace what the drum can handle, effectively limiting work-in-progress upstream of the critical resource.

Impact of Modifications on System Performance

Both Kanban and DBR aim to enhance the predictability and stability of service times, which are often compromised in systems with high variability and no constraints on WIP. By controlling WIP, both systems ensure that service times become more predictable and stable, which are significant benefits for any production system.

Kanban:

  • Service Time Stability: By enforcing WIP limits at each stage, Kanban ensures that no single point in the production line becomes a bottleneck due to excessive inventory. This control leads to more stable service times and reduces the likelihood of inventory buildup, which can tie up resources and space, potentially slowing down the entire production process.

  • Predictability: With WIP limits, the input to each stage is more predictable, which makes it easier to manage resources and schedule work. This predictability helps in maintaining consistent throughput, even when facing variability in production or demand.

Drum-Buffer-Rope:

  • Focused Attention on Constraints: DBR focuses managerial attention on the system's constraint (the drum), ensuring that it operates continuously without interruption. The buffer protects the drum from variability upstream, thus maintaining the flow and service time predictability.

  • Synchronization and Flow Management: The rope ensures that the entire system is synchronized with the pace of the drum, which helps in managing the flow of materials and information through the system. This synchronization not only limits excess inventory but also aligns the production rates across different stages, thereby improving the overall efficiency and responsiveness of the system.

In conclusion, both Kanban and DBR offer structured approaches to managing production systems, particularly in environments characterized by high variability. By implementing WIP limits and focusing on the synchronization of production activities, both methodologies help in reducing delays, minimizing inventory costs, and improving service time predictability, leading to more efficient and effective operations.

 

Insights and Opportunities from the Simulation

The Goldratt Dice Game simulation enhanced with Kanban and Drum-Buffer-Rope (DBR) methodologies has provided valuable insights into the dynamics of production systems under different operational constraints. Key learnings include the importance of managing variability and inventory buildup, which are critical challenges in many production environments. By implementing WIP limits through Kanban and synchronizing production flow with the DBR model, the simulation demonstrates how to achieve more predictable and stable service times, enhancing overall system efficiency.

Kanban emphasizes the pull-based system to control workflow, ensuring that production stages do not overproduce, thereby avoiding excessive inventory. On the other hand, DBR focuses on protecting the system's constraint to maximize flow and throughput, illustrating how targeted interventions can lead to significant improvements in production efficiency.

Readers are encouraged to experiment with the provided code to explore these concepts further. Modifying parameters such as capacity, variability, and WIP limits can help visualize how different settings impact the production process. Such experimentation can provide deeper insights into the practical application of these methodologies in various industrial contexts, offering a hands-on approach to learning and understanding the complexities of modern production systems. This hands-on experimentation is invaluable for grasping the nuanced impacts of operational strategies and for fostering a deeper understanding of continuous improvement practices in manufacturing and service operations.

Download and play

We encourage you to not only download and explore the provided simulation code but to actively engage with it. Experiment by adjusting the parameters such as capacity, variability, and WIP limits, and observe how these changes impact the production process. Share your findings, experiences, here on buy me a coffee. Your insights could help enhance the simulation and deepen our collective understanding of the Theory of Constraints in real-world scenarios. Let's collaborate to push the boundaries of what we can achieve with these tools and methodologies. For just 3 euros, not only will you gain access to the fully functional Python Mesa simulation code, but you'll also receive the PDF version of this article, ensuring you have all the background knowledge and practical resources at your fingertips. This one-time purchase grants you access to the source code of the simulation, allowing you to revisit and reuse the resources as needed for continuous learning, teaching or any other professional development you wish to explore.

useful links

Simulation code package for Goldratt Dice Game

Another application of python mesa Burning Forest model package

Dr. Alan Bernard Goldratt Dice Game video

Mesa Library Python

 

 

Ti piace questo post?

Offri un caffè a Filippo Persia

More from Filippo Persia