# An Event-Driven Agent-Based Simulation Model for Industrial Processes
## 3 Agent-Based Model  
The overall aim of the developed MAS is to support and facilitate the transformation of traditional process systems, following the scheme reported in Figure 1, into smart factories, which are capable of handling real-time unexpected changes of the production by exploiting communication and intelligent behaviors. The following objectives were considered:  
* To transform the product into an intelligent module, able to store and handle its state with updated real-time information. * To exchange information between machines, products, warehouses, and the other actors of the system. * To provide intelligent routing of the products by optimizing the use of the production machines and maintaining high levels of product quality. * To automatically reallocate products that lose compliancy with their original target specifications, by, thus, improving productivity and reducing waste of material as well as completion time of all customer orders. * To promptly react to abrupt changes in the production process, such as machines faults. The developed MAS is based on an event-driven approach in order to efficiently react and respond to on-line events. For this reason, the architectural model used for the implementation of the agents is inspired by the actor model [19], a computational entity with reactive behavior that allows immediate action in response to a message. According to this model, the agents can modify their states but cannot affect the states of the other agents directly--only through messages exchange. Furthermore, the communication is asynchronous. Within the adopted model, an agent receives both messages from other agents and external signals from the environment. The external signals are the operations of the production process (according to the synthetic description provided in Section 2) that are turned into messages. The following main agents are involved in the MAS (see Figure 2):  
* **Product Agents** are responsible for storing and handling all the information related to the products along the entire production chain, such as current process parameters and production steps. * **Process/Machine Agents** handle the production lines of the plant. They manage the information related to the machines' settings, the number of the products to be processed, the scheduling of the products, etc. They can also suspend and reactivate the products whenever the production lines are full. * **Warehouse Agents** manage the warehouses of the plant by moving products from one place to another within the warehouses and towards the machines. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Operation** & **Operation Code** & **Affected Process** \\ \hline Assigning a product to a machine scheduling & 1 & M1, M2, M3, M4 \\ \hline Moving a product within a warehouse & 2 & WH1, WH2, WH3, WH4 \\ \hline Loading a product into a machine’s buffer & 3 & WH1, WH2, WH3, WH4, M1, M2, M3, M4 \\ \hline Working a product on a machine 1 & 4 & M1, M2, M3, M4 \\ \hline Loading a product to a delivery truck & 5 & WH4, D \\ \hline Delivering a product & 6 & D \\ \hline \hline \end{tabular}  
* 1 Stocking a semi-finished product into the subsequent warehouse is an operation accomplished automatically after finishing the processing.  
\end{table} 
Table 1: Process operations. * **Virtual Product Allocator (VPA) Agent** is a supervisor that acts like a broker agent but with an enhanced knowledge. The aim of the VPA is to manage the rerouting of the products if one of the production machines suffers a fault or is subject to maintenance operations. Another feature of the VPA is the reallocation of products that are no more compliant with a customer order, i.e., products that no longer satisfy all the requirements of the customer they were originally devoted to. * **Delivery Agent** handles the dispatching of the products. Its aim is to load products on trucks and to ship them to customers. * **Customer Order Agents** are responsible for the information about production orders.