# Beyond Kanban: POLCA-Constrained Scheduling for Job Shops
## 3 POLCA and the Enhanced Contraint Programming: A Basic Case
### The Proposed Methodology
#### 3.3.2 Simulation Model  
The simulation model is implemented using the SimPy discrete-event simulation library and is designed to replicate the real-time operational dynamics of the production system under study. The model is encapsulated within a dedicated Simulation class, which is instantiated with a SimPy environment, a list of the available workcenters, a parameter representing the number of available cards for each POLCA loop, and a dataset containing the production orders along with their scheduling details as generated by the Constraint Programming model. In the initialization phase of the Simulation class, each workcenter is represented as a SimPy PriorityResource with a capacity of one, ensuring that only a single job is processed on a given workcenter at any time. The workcenters are stored in a dictionary where the keys correspond to workcenter labels (e.g., \"WC_1\", \"WC_2\", etc.). In parallel, the POLCA mechanism is modeled by constructing a second dictionary where each key represents a unique ordered pair of distinct workcenters, concatenated into a string identifier (e.g., \"WC_1\"WC_2\"). Each of these keys maps to a PriorityResource whose capacity is set to the available cards, thereby enforcing a finite limit on the number of concurrent inter-workcenter transitions. This design explicitly models the POLCA card constraint, where the number of cards available for any given transition directly influences the flow of jobs between workcenters. The simulation model processes production orders in a dynamic manner. Orders are sorted based on their arrival times as specified in the dataset. For each order, the simulation waits for the appropriate interarrival time before instantiating an Order object. The Order object is responsible for managing the sequential execution of jobs, where each job must obtain access to its assigned workcenter and, when transitioning between workcenters, must secure the appropriate POLCA card. The process of securing a card is implemented by requesting access from the corresponding loop resource; if the request is granted, the card is assigned to the order, and a log entry is recorded. Conversely, upon the completion of the associated job, the card is released back to the loop resource. These card assignments and releases are carefully logged and monitored to capture the system's behavior under the imposed POLCA constraints. In addition to processing orders, the Simulation class includes an observation process that continuously monitors and records the availability of both workcenter and POLCA card resources at each unit of simulation time. This monitoring is achieved by appending the current state of each resource to time-series lists, which are later exported for detailed performance analysis. Key performance indicators, such as the total number of orders completed, the number of tardy orders, aggregate tardiness, and detailed logs of card assignments and workcenter utilization, are tracked throughout the simulation run. The simulation supports two operational modes: \"opt\" and \"sim\". In the \"opt\" mode, the simulation adheres to the start times and processing sequences provided by the precomputed schedule from the CP model. In the \"sim\" mode, jobs are dispatched based on real-time availability of resources and are queued according to the Earliest Due Date (EDD) rule. In this mode, the system continuously monitors workcenter availability and POLCA card status, dynamically adjusting the execution order of jobs in real time, in contrast to the predetermined sequence of the \"as planned\" mode. The simulation is executed over a predetermined time horizon \(1,\ldots,T\), after which the collected performance metrics and logs are exported. This integrated simulation framework, with its explicit modeling of workcenter capacities, POLCA card limitations, and dynamic order arrivals, provides a robust platform for evaluating the operational performance of the production system.