Full text
Universidade do Minho Escola de Engenharia Departamento de Informática José Diogo Lago Viana Monitoring and Real-time Simulation of an Industrial Production Pipeline December 2020
Universidade do Minho Escola de Engenharia Departamento de Informática José Diogo Lago Viana Monitoring and Real-time Simulation of an Industrial Production Pipeline Master dissertation Master Degree in Integrated Master’s in Informatics Engineering Dissertation supervised by António Luís Sousa December 2020
COPYRIGHT NOTICE This is an academic work that can be used by third parties provided that internationally accepted rules and good practice concerning copyright and related rights are respected. Consequently, this work may be used in accordance with the license Creative Commons Attribution- NonCommercial 4.0International (CC BY-NC 4.0) — https://creativecommons.org/licenses/bync/4.0/. If one needs permission to make use of the work under conditions not foreseen in the indicated license, the author should be contacted through RepositóriUM of Universidade do Minho. i
ACKNOWLEDGMENTS To my friends and family. ii
STATEMENT OF INTEGRITY I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Code of Ethical Conduct of Universidade do Minho. Braga, 16th November 2020 iii
ABSTRACT There is a shortage of manufacturing management software solutions for businesses with various manual processes, and that offer a wide range of products. Existing solutions can become very expensive for small and medium-sized enterprises, and can discourage them to take the next step towards the 4th Industrial Revolution. This dissertation consists of joint work with Tipoprado, Artes Gráficas, to develop a package tracking and production performance analysis platform. The company has a notable number of different clients and offers different types of services. This way, different packages may go through different paths on the production pipeline. Given this, to offer a more close and customized service, Tipoprado, wants to develop a package tracking platform. This tracking is not geographical (delivery case), but about the package location over the production pipeline, giving clients the possibility to consult, in real-time, the actual state of their orders. Apart from this, implementing this platform produces a significant level of data about packages and clients. One of the main goals is to treat, process and analyze this data, to improve production efficiency and be able to help the its managers make crucial decisions about the referred pipeline. Production planning and predictions on delivery dates is the ultimate goal. This dissertation studies and implements the tracking method that best applies to Tipoprado production pipeline, together with data analysis, and prediction options. The given platform will transport the company to a tech production vision, and kick start its journey through the fourth industrial revolution. It is also expected to increase customer engagement levels, which correlate with a higher number of sales. Keywords: Web Application, Web Development Architecture, Queuing Theory and Simulations, Production line iv
RESUMO Existe uma falta de soluções de software de gestão de manufatura para empresas com vários processos manuais, e que oferecem uma vasta gama de produtos. As soluções existentes podem-se tornar bastante dispendiosas para pequenas e médias empresas, e desencorajar as mesmas para dar o próximo passo em direção à 4aRevolução Industrial. Esta dissertação consiste num trabalho conjunto com Tipoprado, Artes Gráficas, para desenvolver uma plataforma de tracking de encomendas e análise de desempenho de produção. A empresa possui um número notável de clientes diferentes e oferece diferentes tipos de serviços. Dessa forma, encomendas diferentes podem seguir caminhos diferentes na linha de produção. Dado isso, para oferecer um serviço mais próximo e personalizado, a Tipoprado, deseja desenvolver uma plataforma de tracking de encomendas. Esse tracking não é geográfico (caso de entrega), mas sobre a localização da encomenda no pipeline de produção, oferecendo aos clientes a possibilidade de consultar, em tempo real, o estado atual dos seus pedidos. Além disso, a implementação desta plataforma produz um nível significativo de dados sobre encomendas e clientes. Um dos principais objetivos é tratar, processar e analisar esses dados, melhorar a eficiência da produção e ajudar os responsáveis da empresa a tomar decisões cruciais sobre o referido pipeline. O planeamento da produção e as previsões nas datas de entrega é o objetivo final. Esta dissertação estuda e implementa o método de tracking que melhor se aplica à linha de produção da Tipoprado, junto com a análise de dados e opções de previsão. A plataforma fornecida transportará a empresa para uma visão de produção tecnológica e iniciará sua jornada na quarta revolução industrial. Também é esperado que aumente os níveis de envolvimento do cliente, que se correlacionam com um número maior de vendas. Palavras-chave: Aplicação Web, Arquiteturas de desenvolvimento Web, Teoria de Filas e Simulações, Linha de Produção v
CONTENTS 1 introduction 1 2stateoftheart 3 2.1Related Products 5 2.1.1DHL - Tracking System 5 2.1.2HiveTracker 6 2.1.3Productoo 7 2.2Tracking Methods 8 2.3Queuing Theory and Predictions on a production pipeline 10 2.4Technologies 14 2.4.1Web Development Architectures 15 2.4.2Web Development Languages/Frameworks 16 2.5Summary 18 3 the problem and its challenges 21 3.1Proposed Approach - solution 23 3.1.1Solution Overview 23 3.1.2Simulation Algorithm for predicting delivery dates (Sub-module) 24 4 development 28 4.1Decisions 28 4.2Implementation 29 4.2.1Database and API 29 4.2.2Critical Zone and Websockets for real-time interactions 32 4.2.3Statistics and Metrics for production analysis 37 4.2.4Delivery dates - Simulation 42 4.3Outcomes and Summary 53 5 case study /experiments 56 5.1Experiment setup 56 5.2Results 57 5.3Discussion and Summary 62 6 conclusion and future work 63 6.1Conclusions 63 6.2Prospect for future work 64 a support material 72 a.1Other relevant Frontend pages 72 vi
contents vii a.2Email Examples 79
4 Many experts are suggesting that this revolution will benefit the rich much more than the poor, especially as low-skill, low-wage jobs disappear in favour of automation. Schwab said in his book, "The changes are so profound that, from the perspective of human history, there has never been a time of greater promise or potential peril. My concern, however, is that decision-makers are too often caught in traditional, linear (and non-disruptive) thinking or too absorbed by immediate concerns to think strategically about the forces of disruption and innovation shaping our future." As referred in the quote below, and the present state of change, industries are in current demand for optimisation of their services, and to reach this, they need to go digital and tech-oriented. "Around the world, and in practically every sector, manufacturing facilities are undergoing a major transformation. Digitisation is changing the way we process materials and make products, and data is becoming the golden key that can open a door to technological possibilities with the power to completely reshape manufacturing. The traditional manufacturing model is evolving into what is referred to as a "smart factory" or Factory 4.0– a connected system that links machinery, personnel, maintenance activity, and analytics for a completely integrated approach to factory management." - Seebo,"How factory 4.0is transforming production" [58],. On the other hand, one of Tipoprado’s objectives is to increase customer engagement by allowing them to be "involved" with their package orders through the whole process. Firstly, what is customer engagement? It is all about interactions between the customer and the brand. That simple. Why is it important? Finding ways to engage with customers in between purchases/orders strengthens their emotional connection to the brand, helping retain them while sustainably growing the business. Figure 1: Customer engagement process. [1] In fact, a study by Hall and Partners’ “Engager”, described by MaryLou Costa in Marketing- Week [ 34 ] shows that up to 2 3 of a brand’s profits may rely on effective customer engagement. Another customer engagement study by Ray Wang of Constellation Research [ 46 ], in 2016, found that ". . . companies who have improved engagement increase cross-sell by 22%, drive up-sell revenue from 13% to 51%, and also increase order sizes from 5% to 85%."
2.1. Related Products 5 With these values in mind, it’s easy to see that there is a direct correlation between how engaged customers are and how profitable the business is. Being said, the reasons and objectives that drive Tipoprado to adopt this new model are valid and relevant. Introducing the path to the rest of this dissertation, the act of tracking a package inside a production line, requires some sort of system (automatic or not) that registers each process/state. So in this chapter, the goal is to search for related products on the market, analyse their tracking systems, methods, and conclusions retrieved automatically by the respective software. A comparing review between predictions through Queueing Theory, Machine Learning (ML) or Simulation Algorithms is also pretended. 2.1related products 2.1.1DHL - Tracking System As it was mentioned in the introduction, the first related product to be talked about is from the delivery giant DHL 1 . After a quick analysis on this platform we conclude that it is a Web Application, accessible by everyone on every system with access to the internet and a browser. It also has a homepage where any client can manually search for their packages by a unique code, received previously. Due to this platform’s main features (package tracking) are only accessible to clients that have "active" packages, the rest of this description is based on previous use and public examples made available by DHL itself. One of the key features of this tracking system is that clients do not need to register on the platform. This results in a simple use and less "bureaucracy" that most users don’t want to experience, just to know the location of a package. When a client places an order for a product that is shipped and registered under DHL, he is notified (generally by email) with a unique reference code to the respective package. With this code, only known by the client, he can search for the package and check its state. In this platform, there is no relation between client/package, so, if someone has more than one package registered, it has to check for them separately. Using some of the examples present in this page 2 , we can check some of the "core" features of the platform. A client can view the package destination, description, and the full history/process through the company system. 1https://www.dhlparcel.pt/en/private-customers/receiving-a-parcel/track-and-trace.html 2https://www.logistics.dhl/pt-en/home/tracking/id-labels.html
2.1. Related Products 6 Viewing the same example page again is possible to conclude that the tracking method used to register each state, is barcode-based. 2.1.2HiveTracker This product is still a geographical tracking just like the previous one (it offers real-time product supply chain monitoring at item level from End to End (E2E).) But, it provides new management possibilities, making it similar to one of the main goals of Tipoprado - statistics and other efficiency-related problems. There is not much available about this product, but in HiveTracker’s website 3 , are described some of the main features and the goals of the platform. The main objective is to "Bring light to the dark spots of the supply chain", to improve efficiency, margins, and sales. Regardless of having a different application, the ultimate purpose is the same as production line tracking for optimisation. According to HiveTracker the benefits of real-time item-level monitoring include; faster release of the product, cost-saving, increased customer satisfaction, the possibility of immediate intervention, unrivalled compliance management, real-time loss or fraud detection, real-time customer behaviour insights and maximised stock control. HiveTracker’s provides a Platform as a Service (PaaS) for data visualisation and reporting combined with prescriptive analytics means visibility, agility and unprecedented maximisation of a company (client) supply chain. Some interesting and related features found on the website: • All products identified, authenticated and monitored in real-time throughout their life; •Control and analysis of Product Flows from production to end consumer; • Real-time monitoring and tracking, anywhere, anytime, fully autonomous with no external human action; • Reports produced from measured data gives the image of the situation without any interpretation; • Prescriptive analytics-based reports provided by business intelligence and machine learning indicate in real-time alerts, corrections and predictions of the supply chain for each transport. Opposing to DHL system, HiveTracker uses a set of small connected sensors (size of a 2Euro coin), that measure, log and transmit in real time: global position, temperature, humidity, light exposure and other customized data. Concluding, this is a more Industry 4.0 (Internet of Things (IoT))oriented solution. 3https://www.hivetracker.io/
2.1. Related Products 7 2.1.3Productoo Provides solutions for a complete digital transformation of production and maintenance planning, execution, tracking, and reporting. Comparing it with the previously presented products, Productoo has the most similar use case (a production line). According to their website 4 ,Productoo main goal is to drive company’s Return on Investment (ROI) and boost performance. To do so, they offer a series of different products, such as Maintenance Control, Production Control, and Factory Cockpit. Some of the main advantages of using their products are: •creating paperless environments for better traceability; •improving Overall Equipment Effectiveness (OEE) by 10-30%; •optimising planning to meet current demand (demand-driven strategy); •reducing lead time and changeovers; •spending less time reporting, making better decisions faster. Focusing more on Production Control,Productoo offers: •production planning and scheduling; • connection to third party Enterprise Resource Planning (ERP),Manufacturing Execution System (MES) and OEE software; •production tracking, live dashboards of the production line and report generation. It has also available some success cases using this product, as can be seen in one example in Figure 2. The analysis of this case and other examples proves the concept and validates that the process of tracking and monitoring a production a line, has positive impacts on the company efficiency, enabling it to have a ROI shortly. According to specifications, their products are modular and are cloud-based (Web and Mobile Applications). For Maintenance Control, the tracking method of the inventory/machinery is barcode readers, however for Production Control, it uses MES connectors and operates with the real manufacturing data. This solution is less error-prone and more accurate than manual input or barcode readers. Still, it is necessary for the machinery used to be "high tech", and compatible (more common in highly robotised systems that only produce one kind of material/product, as seen in the example above - automotive company). 4https://www.productoo.com/
2.2. Tracking Methods 8 Figure 2:Productoo - Production Control success story example. [42] 2.2tracking methods As it was lightly introduced before, there are various methods to track assets. In this case, assets correspond to the packages (orders) inside the production pipeline. So, we will explore some possibilities and its viability, such as IoT sensors, Radio Frequency Identification (RFID) and barcodes. The following table, presented by Hardcat, represents a quick comparison between the four methods. Tag Type Asset value ($) Tag cost Advantage Disadvantage Barcode Low Low Minimal cost No tracking ability RFID Medium - High Medium - High Basic tracking Tracking at certain points only GPS High Medium - High Real-time tracking Only outside buildings/cover WIFI High Medium - High Real-time tracking Only outside buildings/cover Table 1: Asset tag types and applications. [18] The use of GPS or WIFI sensors will be discarded right away since its applications are for high-value assets, and mainly for outside (great distance) tracking. With RFID we achieve the same goal with probably fewer costs, for inside monitoring. RFID is possibly a viable option because of the following characteristics:
2.2. Tracking Methods 9 •Tags are cheaper to purchase; •Readers are more powerful with longer read range; •Fixed and hand-held readers are cheaper to purchase; •Tags are less sensitive concerning surface placement. Comparing it with barcodes, many tags can be scanned at once, and the scanner only needs to be within the range of the tag to read it. Also, RFID is faster, more durable and more accurate than barcodes. Nevertheless, RFID asset management is not a matter of one size fits all. Its tags and readers depend upon the environment, asset types and the outcome required. On the other hand, barcode labels are a valuable and viable choice for businesses looking to improve efficiency and reduce overheads. Both cost-effective and reliable, barcodes have the following characteristics: •Barcodes reduce the possibility of human error; •A barcode scan is fast and reliable; •Barcodes are inexpensive to design and print; •Barcodes are extremely versatile and user-friendly. For Tipoprado, an asset/package can, possibly, be seen as a whole paper sheet pallet or a final product pallet. Pallets can be easily tracked. However, due to production methods, a pallet does not necessarily identify a package. Analysing Figure 3that represents how a package is processed through most pipeline places is understandable that a pile of sheets is picked from one pallet, processed and placed on a new pallet on the other side. This is necessary, because every machinery consumes (raw or not) individual paper sheets on one side, and delivers them on the other. That way, a pallet never follows through a package full "life cycle". Figure 3:Tipoprado’s production method.
2.3. Queuing Theory and Predictions on a production pipeline 10 As pallets cannot identify a package, the only way to do it would be through every single sheet that is processed. Still, this is not possible due to extreme costs marking each one. Example: an order of 10000 A5books, needs a minimum of 40000 sheets. A printer machine, like the ones owned by Tipoprado, can easily print 5000 sheets/hour. That way, it would be necessary for someone/something to mark each sheet, faster than the printing rate, to not waste valuable time. Also, a single sheet has varying values, depending on quality; nevertheless, it still has a low value, relative to the cost of marking it. According to the company responsible, for each package/order placed, it is printed a "description" page that accompanies the respective package for the full path on the pipeline. This page is managed by their ERP and has a barcode referring the package unique number (like a Universal Product Code (UPC)). For this reason, RFID is not a viable option for Tipoprado, making the use of barcodes the best solution for this case. Barcodes can be 1D,2D(Figure 4). These types depend on product/asset size and data requirements. [36] Figure 4:1D vs 2D barcodes. [44] 1Dbarcodes are typically used for identifying items or assets that are associated with variable information that resides in a database. A good example is an item marked with a UPC code that is linked to frequently changing information in a pricing database. 2Dbarcodes can be used to mark very small items. In some cases, these types of codes have been directly etched into auto parts or aeroplane components, or even tiny surgical instruments. While 1Dbarcodes were traditionally scanned with laser scanning technology, 2D codes require an imager (which can scan both 1D and 2D codes). The cost of imaging scanners has fallen so that they are now price competitive with laser scanners. 2.3queuing theory and predictions on a production pipeline Queuing theory studies the process/act of waiting lines, and it enables the mathematical analysis of several related processes, including arrivals at the queue, waiting in the queue, and being served by the server. Queues are basic to both external and internal business
2.3. Queuing Theory and Predictions on a production pipeline 11 processes, which include staffing, scheduling and inventory levels. For this reason, businesses often utilise queuing theory as a competitive advantage. The problem in almost every queuing situation is a trade-off decision. A manager must decide on the added cost of providing a more efficient/quick service (add more checkout places, more staff, etc.) against the inherent cost of waiting in line. If employees spend too much time manually entering data on a platform, a business manager could compare the price of investing in barcode scanners against the benefits of increased productivity. Likewise, if customers are unhappy because of late delivery dates, the business managers could analyse the cost of hiring more staff relative to the value of possibly increasing revenues and ensuring the retainment of customers. Those are the kind of conclusions/decisions that the platform aims to help Tipoprado in its production pipeline. To modulate a queuing system is necessary to know these major components: 1. How packages arrive; 2. How packages are serviced. Arrivals are divided into two types: •Constant: the same period between successive arrivals (i.e., machine-controlled); • Variable: random arrival distributions, which is a much more common form of arrival. Servicing consists of the line(s) and the available number of servers for that subsystem. To modulate a queue servicing, is necessary to consider, the line length (number of items waiting), number of lines (number of servers) and the queue discipline. An essential feature of the waiting structure is the time the customer spends "inside" the server, also seen as service time. It can also be referred to as the service rate: the number of items that server will process per period (i.e., ten packages per hour). Another crucial point on a servicing subsystem is to know the line structure or the overall system. By that, we need to identify if the respective line is single or multi channel and single or multi phase. The simplest type is the single-channel, single-phase, where there is only one channel for arriving customers and one phase of the service system. An example is the checkout counter at a supermarket, only one step and customers coming only from inside it (the supermarket). On the other side, we have multi-channel, multi-phase. Tipoprado’s case is this one, but we will enter in more details later. Some of the performance measures that can be answered by assessing and improving a production line, through the use of Queuing Theory, include: •Utilization factor; (r) •Number of packages in system; (Ls)
2.3. Queuing Theory and Predictions on a production pipeline 12 •Number of packages in queue; (Lq) •Time spent in queue; (Wq) •Time spent in system; (Ws) •Service times; •Efficiency of each workstation. Yet, such measures can be calculated with the data collected from the tracking on the production pipeline, so there’s no direct need to use Little’s Law. (L=lW)[31] Like it was introduced before, one of the requirements set by Tipoprado is the possibility to predict delivery dates for each package. At the moment ML is the most popular method to make all sorts of predictions. Nonetheless, it raises doubts about being the one that best applies here. Queuing Theory models try to estimate the behaviour of a queue system given several assumptions. This reveals a big flaw of these models: they only produce valid results if the queue follows the assumed distributions of inter-arrival and servicing times. Josefin Stintzing and Frederik Norrman made a study about the use of data from queue systems to provide a prediction with artificial neural networks [ 62 ]. During this study, we observe the results obtained and how they got to them, using ML algorithms. They compare these results with the real data that the network was trained on, and with results using Queuing Theory methods. One of their conclusions shows that while Queuing Theory may tell/respond to more specific problems about queue systems, given that the assumptions above are known and approximate, ML algorithms, such as the ones used, can give what rate customers arrive and how long to serve them. Yet, they tell nothing on how to use that information. This way, if we can accurately modulate the production pipeline into one queuing system (arrival and servicing rates that follow a known distribution), and assuming a "steady-state" system, is possible to give an approximation of "total time inside the system" (delivery date) using Little’s Law, referenced above. However, since Tipoprado is looking for a "dynamic" prediction (not "steady-state"), this problem is not First Come First Served (FCFS). Also, company managers are not sure about arrival distribution, meaning that the use of Queuing Theory may not produce an accurate result. Due to high variety of services that the company provides, a package may take different paths inside the production line, depending on what type of processing it needs. This way, two packages that leave a Server X and a Server Y can "race for service" in Server Z. Checking Figure 5this is evidenced by green , red , yellow and orange packages. Each one has a defined path and being, apparently, in different stages, they can meet in S4 and/or S5.
2.3. Queuing Theory and Predictions on a production pipeline 13 This queue state is in constant shifting with different packages arriving at different places with different future paths, making the system a multi-channel/multi-phase one. Figure 5: Package flow inside production line example. So, it is also possible, to develop a simulation algorithm and have a dynamic prediction, with the actual state of the company in mind (real number of packages in each queue and processing times). This way, packages coming from different workstations to the same queue would interfere with each other’s waiting/total times. There are two different types of simulation, Discrete Event Simulation (DES) and Continuos Simulation (CS). DES models the operation of a system as a (discrete) sequence of events in time [ 35 ], having two approach possibilities: •Next-event Time Progression: it is assumed that there are no changes in the system between consecutive events. Thus, the simulation time can jump to the start time of the next event; •Fixed-increment Time Progression: where time is incremented at a fixed rate and the simulation state is updated according to the events happening in that time slice. Both forms of DES contrast with CS in which the system state is changed continuously over time, based on a set of differential equations defining the rates of change of state variables. [9] This way, to create a DES (which is the one we need), it is necessary to keep track of: •State: a set of variables that represent the properties of the system to be studied. The state evolution over time can be mathematically represented by a step function whose value can change whenever an event occurs;
2.5. Summary 20 Elixir was chosen because it is a language that runs on the Erlang Virtual Machine (VM). This way, it has all of the benefits of the battle-proven system, and it is possible to use the existing Erlang libraries with no performance penalty. Another strong point for Elixir is concurrency, which, in most languages, is a bit of a pain, not only beeing dangerous and hard to achieve synchronisation. In Elixir it is effortless to create a new process, and it performs very well. It is a core feature of the platform and does not require a separate library. Note that Erlang/Elixir processes are not native processes; they are much more lightweight and are scheduled by the Erlang BEAM virtual machine. [13] Phoenix [ 40 ] is the most popular web framework for Elixir right now. One great feature is the real-time capabilities with channels between Javascript on the client and Elixir on any of the servers in the cluster. Every single visitor to a website can have its process on the server and its real-time connection, achieving a sort of "hybrid" platform. This enables some possibilities that are not present in other common web frameworks. Virtual DOM in ReactJS makes user experience better and developer’s work faster. With this, it updates even minimalist changes applied by the user but does not affect other parts of the interface. (Check reconciliation in ReactJS documentation, What is the Virtual DOM? [ 48 ]). Managing updates is easy for developers because all ReactJS components are isolated, and a change in one doesn’t affect others. This allows for reusing components that do not produce changes in and off themselves to make programming more precise, ergonomic, and comfortable for developers. It is an open-source library developed by Facebook and in constant update. At the moment, ReactJS is in 3rd place of Github’s most stared repositories, with over 141k stars [ 16 ]. And more than 1300 open-source contributors are working with the library.
3 THE PROBLEM AND ITS CHALLENGES After all the research endured for the "State of the Art" Chapter, it’s necessary to describe the problem and requirements imposed by Tipoprado. Some questions (business requirements) were already explained/addressed before, such as: •Client interactions; •Production methods; •Pipeline characteristics. About the specific tasks that the platform must respond to, some meetings were arranged with the company responsible in a first approach phase. The refined requirements were separated in different categories (user requirements), to improve development efficiency. Users: •Admin: has access to all CRUD1operations and extra features; •Employee: has limited access to CRUD operations and limited to the main features of the platform; •Client: only has access to public information such as own packages, and related. (no registered account necessary) Employee Features: •Register new packages/orders in the platform; •View, edit and delete packages; •Register/Complete/Pause/Resume a package state inside the production line; •Mark packages as concluded; 1Create, Read, Update, Delete [33] 21
22 • Consult a "production calendar" with package delivery dates, and automatic predicted dates. Client Features: •Consult own orders status/history; •Answer a satisfaction survey after package conclusion. Admin Features: •All Employee features; • Consult Statistics/Performance measures about the production pipeline and other business sensitive data; •Consult reviews given by clients about their orders; •Platform settings: –User management (add/remove employee accounts); –Pipeline management (add/edit places of the production line); – Client satisfaction survey question management (add/edit questions of the automatic package survey). Concerning how the system must behave to fulfil the company’s expectations (system requirements), we got the following: • Clients must receive an email when a package is registered or concluded. This email needs to forward them to the package public information page on the platform, or to a satisfaction survey; • Package state management inside the pipeline must be ready for manual and barcode scanners input. (This process has to be simple and as much little time consuming as possible). As for the statistics that will be calculated and shown to Admin user, consists of a set of performance measures used in queuing theory and other metrics that Tipoprado requested. Composing the following list: •Time evolution of the number of registered packages;
3.1. Proposed Approach - solution 23 •Time evolution of the number of completed packages; •Time evolution of percentage of on time package deliveries; •Overall percentage of on time package deliveries; •Number of packages active in a place (workstation); •Number of packages stopped after being active in a place (workstation); •Heatmap of number of packages passing on a place; •Mean service time by place; •Mean waiting time by place Xto place Y; •Place OEE; •Time evolution of client rating reviews. The final goal of this data treatment is to be able to generate automatic reports analysing each one of these measures and inform, as simple as possible, Tipoprado’s responsible about positive or negative evolution, according to the previously selected time counterpart. 3.1proposed approach -solution 3.1.1Solution Overview Collecting and analysing all information about the desired platform an architecture scheme is necessary to complete the development roadmap. As said before, this web application will be divided into different modules initially (frontend and backend). This allows an easy affix of separate services such as a Simple Mail Transfer Protocol (SMTP) [ 29 ] Server for email delivery, or a possible IoT [52] solution in the future (also referenced above). Since the production pipeline status (adding and completing packages on a workstation), is the "critic zone" with constant data flowing through frontend and backend, websockets [ 21 ] will be used. The use of websockets enables an almost "real-time" feel, ensuring that every endpoint (computer of the company) has the same visual state. The rest of the information will be passed with HTTP requests through a REST API. This way, an unauthenticated user (Tipoprado’s end client), can not use websockets through the frontend module.
3.1. Proposed Approach - solution 24 Figure 7: Solution overview scheme. ATipoprado’s employee, authenticated user, can add new information by manual input or barcode scanners. Also, can interact with backend module through HTTP or websockets (for pipeline information). In Figure 7, we see the different entities that will use the platform inside the squared boxes. The round boxes represent the various modules that compose the application. 3.1.2Simulation Algorithm for predicting delivery dates (Sub-module) Considering all the requirements and the architecture defined, the simulation sub-module will constitute the "the cherry on top of the cake", and it deserves a preview of the algorithms/techniques that will be used. As it was referenced in the State of the Art, the algorithm used will be based in Figure 6. This way, it is necessary to define: • how data used in the simulation will be retrieved (list of packages and places/workstations that compose the pipeline); •how the simulation engine will keep track of events and data updates To give the best user experience, each time a user consults the integrated calendar, it should have an overall idea if packages are predicted to be delivered on time or not, and the respective predicted date. This means that this information will be asked for, fairly frequently, corroborating Figure 7and the necessity for this to be a separate sub-module.
3.1. Proposed Approach - solution 25 With the possibility of a separate component from the API, instead of calculating each time an HTTP request is received, a simulation will run periodically (starting with a 1hour period) and update the respective database table. Given that a package has a defined path, and it may vary, each workstation also has a different number of "items" to process, receiving from one and delivering to another workstation. It can also be the starting or finishing point of a package. So, we can think of a workstation as an individual actor inside of the simulation engine. (Figure 8). Figure 8: A pipeline workstation inputs and outputs. Continuing with the same thought, we identify some Actor Model [ 20 ] programming characteristics. In response to a message it receives, an actor can: •make local decisions; •create more actors; •send more messages; •determine how to respond to the received message. Actors may modify their private state, but can only affect each other indirectly through messaging. An actor is also a light-weight entity unlike Operating System (OS) processes or threads, and was introduced in 1973 by Carl Hewitt. [20] One of the selling points of Elixir is its support for concurrency. The concurrency model relies on Actors . So, implementing the initial idea, where each workstation is an actor part of the simulation, should not be a problem with the selected language for backend development. After a small research, we can verify that actor-based programming is present in some simulation problems, and that constitutes a viable solution for this platform. Citybound is a city building game that uses microscopic models to vividly simulate the organism of a city arising from the interactions of millions of individuals. This simulation engine is based on actors and message passing. It is implemented in Rust [ 55 ]. According to Anselm Eickhoff, creator and developer of Citybound, the main inspiration for his approach was his previous experience with Erlang.[4] Having this into consideration, the first take on a pseudo algorithm can be the following:
3.1. Proposed Approach - solution 26 1. Periodically, an Actor is spawned. This will be the Simulation Manager and is responsible for spawning an Actor for each workstation that composes the pipeline; 2. Each of these actors will collect the list of packages in their queue, and order it by the delivery date. Announcing to the manager when the next event will occur. The next event is calculated by the processing time of the first package in queue; 3. When the manager gets all announcements, orders them, and advances clock time to the next event, warning the respective actor where the event will occur; 4. Actor receives a message from the manager and completes "event" (package processed). If the package is concluded, it will update the database value for expected delivery time. Else, it will send a message with the package to the next workstation (actor). It also warns the manager, that needs to wait for a next event update from itself and the next workstation; 5. The intervening workstation actor will recalculate the next event time and announce it to simulation manager (null in case that there is no package in the queue), to continue the simulation; 6. The simulation stops when the manager doesn’t have more "next events". Now, we can formulate a more fine-grained approach to this algorithm. The pseudo-algorithm bellow, represents the flow of interactions in an imperative approach, with functions receiveMessage() and sendMessage() as being blocking functions. However, this is just a method to better explain how the simulation will work. As said, the actual implementation will be Actor Model based, transforming this algorithm in a distributed and asynchronous one, and that’s why some of the announcements are needed (intended to keep message order between all actors). This can be seen as a simple sequential consistency problem [ 30 ]. We must ensure that the Manager only fast forwards the clock when it has all the updated values from the actors affected by the previous event, keeping "timed events" from overlapping. The existence of a centralised actor (simulation manager) simplifies this problem and potentially increases efficiency due to less metadata and extra messages in a peer-to-peer case. The portions of code (logic) that will be executed separately from the simulation manager are outlined by "actor pexecution" blocks.
3.1. Proposed Approach - solution 27 Data: SimMan as the Simulation Manager begin PList getWorkstations() for p2PList do spawnActor(p) actor pexecution PackList getPackagesInQueue(p) orderByDeliveryDate(PackList) nextEvent getNextEvent(PackList) sendMessage(SimMan,nextEvent) end end while 9p/2receivedEventList &nextEvent receiveMessage() do insertOrdered(receivedEventList,nextEvent) end while receivedEventList 6=[]do {p,time} popHead(receivedEventList) sendMessage(p,time) actor pexecution newUpdate receiveMessage() if isFromManager(newUpdate) then package popHead(PackList) if isCompleted(package) then updateDBDeliveryTime(clockTime) sendMessage(SimMan,[]) else m getNextWorkstation(pack) sendMessage(SimMan,[p,m]) sendMessage(m,pack) end else insertOrdered(PackList,newUpdate) end nextEvent getNextEvent(PackList) sendMessage(SimMan,nextEvent) end affectedList receiveMessage() for p2affectedList do nextEvent receiveMessage() insertOrdered(receivedEventList,nextEvent) end end terminateSimulationActors() end
4 DEVELOPMENT 4.1decisions Starting the development phase, it is important to make a summary of the technology decisions, previously referenced. Regarding Backend, Elixir is the selected language, together with Phoenix to develop a REST API, and we already went through their great advantages. To simplify development and smooth the process, we will also use Ecto [ 10 ]. It is a database wrapper and query generator for Elixir.Ecto provides a standardised API and a set of abstractions for talking to all the different kinds of databases so that Elixir developers can query whatever database they’re using by employing similar constructs. As for Frontend, since component development/design is not the goal of this dissertation, the use of Semantic-UI [ 59 ], together with React, takes an important role. It offers a declarative API, controlled components [ 47 ], and other features. Looking to the list of components offered by Semantic-UI is visible that data visualization components, such as plots and charts are missing. Like it was explained, data analysis by the company managers simply and intuitively is a key feature of the whole platform. This way, after some research, the React-vis [ 49 ] library was chosen. Developed by Uber,React-vis is React-friendly, high-level, customizable and expressive. Recalling the tracking method (barcode readers), to update each package state inside the production line, it is crucial to say that one of its main benefits, is that it allows the user to scan barcodes into any application as if the data was being keyed in by the user. It means, that a common barcode reader works like a keyboard. Just scan a barcode and the data will appear wherever the cursor is placed. This way, it’s not necessary for any extra library/software to support this feature. 28
4.2. Implementation 29 4.2implementation 4.2.1Database and API Firstly, given the requirements stated in Chapter 3, the database conceptual model, and consequently, the logical model was developed, which resulted in the following Figure 9. Figure 9: Database Logic Model. Some important notes on the database: •User: The User table is only to represent authenticated users (admins and employees). Public users, such as Tipoprado’s end clients, do not need authentication to consult their packages. Only required unique code, generated through Base 64 encoding of number (sent by email only to Package’s owner_email); •Package: quantity and path can be null . The path attribute is the expected path that the package will undergo in the production line. Used mainly for Simulation purposes. It was chosen to not make them required after talking with Tipoprado’s employees who felt this could be too time-consuming and don’t have a direct impact in the package tracking flow. The Path table serves only to store frequent or favourite
4.2. Implementation 36 1socketRequestInfo() { 2this.channel = this.socket.channel(’pipeline:lobby’,{token: localStorage.getItem(’token’)}); 3this.channel.join(); 4this.channel.on(’unauthorized’,this.handleUnauthorized); 5this.channel.onError(this.handleErrorChannel); 6this.registerSocketMessages(); 7this.channel.push(’full_pipeline’,null); 8} In Figure 10, it is visible the main layout for this page. The design is a continuous development together with Tipoprado’s employees, to enable an easy registering and manipulation of package states. Spending the least time possible with inserting new data, was the main concern with this page. For every action performed, or "event message" there is a confirmation modal, to guaranty some sort of a second step and reducing mistakes caused by neglect. The backend also deals with possible errors that may pass through frontend verification. Figure 10: Production Line page for package tracking.
4.2. Implementation 37 4.2.3Statistics and Metrics for production analysis All statistics and metrics, described in Chapter 3, were implemented, however, we will only look in detail to the two most complex and interesting. Final results of every statistics page can be found in Figures 25,26,27 and 28 of Other relevant Frontend pages. •Mean waiting time in queue This statistic demonstrates the mean time a package stays in a queue before starting a given process (enter a new workstation). Due to the fact of variability of products, packages waiting in a workstation queue, can have different predecessing paths (Figure 5). So, it is necessary to take into account all the possible combinations: a!b,fora,b2Workstation_List (1) To calculate this, it is necessary to get all packages registered between the filter dates and their state list. Each state of the list represents when a package entered and left a given workstation. This way, if we travel through this list and calculate the time passed after a package left a Workstation A and started the next process (Workstation B), we get the time difference of two workstations for a package (time spent in queue workstationA! workstationB). Doing this for all the packages, we obtain all the possible path combinations that exist in the company’s production pipeline. In the following code snippet, it is visible the function that produces the list of time queue’s time of a given package state list. •previous is a tuple that is composed by the workstation order number and the timestamp of when it ended processing in that place; •next will be previous in the next recursive call. The edge case where the time difference is less than zero is taken into account, because sometimes, due to production characteristics, a package could start being processed in a workstation before being completed finished in the previous one. This would generate a negative number, and produce wrong results in the long run.
4.2. Implementation 38 1defp queue_time_diff([], _previous, times), do:times 2defp queue_time_diff([state | tail], previous, times) do 3next = {state.place.order, state.timestamp_end} 4time_diff = 5Timex.diff(state.timestamp_start, elem(previous, 1), :seconds) /3600 6time_diff = if time_diff < 0 do 0.0001 else time_diff end 7queue_time_diff( 8tail, 9next, 10 [{elem(previous, 0), state.place.order, time_diff}|times] 11 ) 12 end The function above is tail-call recursive. Tail-recursive functions are considered better than non-tail-recursive functions as tail-recursion can be optimized by the compiler. The idea used by compilers to optimize tail-recursive functions is simple since the recursive call is the last statement, there is nothing left to do in the current function, so saving the current function’s stack frame is of no use. This way, guaranteeing that a stack overflow will never occur. The output is then grouped by workstation and the mean values are calculated and the resulting output is a list of tuples { previous_workstation , next_workstation , mean_waiting_time }. On the frontend side, the data received is transformed into a matrix like the one below. M= 0 B B B B @ ab... n aq aa qab ... qan bq ba qbb ... qbn ... ... ... ... nq na qnb ... qnn 1 C C C C A Where: qaa =mean_waiting_time(a>a) qab =mean_waiting_time(a>b) qnn =mean_waiting_time(n>n) The first argument of mean_waiting_time represents the previous workstation and the second argument, the next one.
4.2. Implementation 39 To represent this information, as mentioned at the beginning of this chapter, React-vis was used and the Heatmap Series the type of plot selected. Figure 11: Heatmap for mean times in the production line queues. The color ranges are the following: [green;yellow]=]0; max ⇤0.45] ]yellow;red]=]max ⇤0.45; max ⇤0.95] ]red,red]=]max ⇤0.95; max] These values represented are in hours and truncated to one decimal case. •Workstation OEE (Overall Equipment Effectiveness) To best understand what this plot shows, it is necessary to know what OEE is. It is the gold standard for measuring manufacturing productivity and measuring it is a manufacturing best practice. OEE is calculated as a combination of three different metrics. •Availability (A): takes into account unplanned and planned stops. A score of 100% means the process is always running during the planned production time; •Performance (P): takes into account slow cycles and small stops. A score of 100% means that when the process is running it is running as fast as possible; •Quality (Q): takes into account defects. A score of 100% means there are no Defects (only Good Parts are being produced).
4.2. Implementation 40 This way OEE =A⇤P⇤Q , and a score of 100% means the workstation is manufacturing only good parts, as fast as possible, with no stop time. Due to production methods and some platform limitations, the number of defects is not counted and stored. This way, we will only use A⇤P. The first step is to calculate the availability of a workstation. For this, we need to get the expected production time and the real production time for the selected date period. • The expected production time is the sum of all business hours (shifts defined by the admin in the platform settings) for the selected period; • The real production time is the sum of all package states that were active in that workstation during the same period. After having the two, since the workstation might have more that one server, and therefore should be producing total_time ⇤n_servers we multiply the total time by the number of servers and then obtain the relation of real/expected. 1def utilization_factor(min_date, max_date) do 2total_production = total_production_time(min_date, max_date) 3 4Stats.real_time_place(min_date, max_date) 5|> Enum.map(fn x-> 6{elem(x, 1), elem(x, 0), calc_work_time(elem(x, 2)), elem(x, 4)} 7end) 8|> Enum.map(fn x-> real_expected_relation(x, total) end) 9end 10 11 defp real_expected_relation({id, name, real, n_servers},total)do 12 if total * n_servers != 0 do 13 {id, name, real / (total * n_servers)} 14 else 15 {id, name, 0} 16 end 17 end In the end, we get a list of tuples identifying each workstation and with respective relation of availability. As for the performance metrics calculation, a workstation performance is given by:
4.2. Implementation 41 real_debit =(quantity_prod/prod_time)/n_servers performance =real_debit/expected_debit The real_debit is calculated as an aggregation of all the n servers that the workstation offers, and the expected debit is defined by the platform admin as the expected quantity produced per hour per server. However, there are some special cases where there isn’t an expected debit defined. This is due to the fact that some workstations represent manual and non-countable production rates since there are a lot of variables that influence this number. So, the platform admin can leave the expected debit for that workstation as unquantifiable . When this occurs, the approximate debit is calculated with the number of packages processed inside that time period and the expected debit is the mean time duration of a package being processed in that respect workstation. Note that this is not an "official alternative", this is just a way to best approximate the OEE metric for such variate production methods of this industry that can’t be automated or countable. approximate_debit =(n_packages/prod_time)/n_servers expected_debit =mean_time_duration(workstation_id) performance =approximate_debit/expected_debit In the end, in a very similar way of the availability metric, we get a list of tuples with the same composition. This allows easy workstation grouping and calculation of the final OEE values. On the frontend side, this time the Bar Series was the selected type of plot provided by React-vis, and the final result can be seen below in Figure 12. Figure 12: Vertical bar plot for availability, performance and workstation OEE.
4.2. Implementation 42 4.2.4Delivery dates - Simulation Remembering Chapter 3and Figure 8together with the suggested algorithm, the first step for this implementation was to create the base structure of actors that intervene in the simulation. Therefore, it starts with the creation of the simulation manager and workstation actors. Both simulation manager and workstations are GenServers1 . They are lightweight processes that can execute code, keep states and send messages to others, asynchronously. SimMan (the simulation manager) starts with the following state, defined in the Sim- Man.start_link/0 function: 1pids:active_places, 2clock:Timex.now(), 3events:[], 4awaiting:[] Where: •pids : is a map which the keys are the company’s workstation ids, and the values are the pids returned when an actor is started with GenServer; •clock : will synchronise all workstation actors and keep track of each timestamp when a package advances in the simulation; •events : the list of events (packages’ new states) that each workstation actor will "report" to the simulation manager. The simulation ends when this list is empty. However, starting empty, the verification is post-initialization; •awaiting : together with clock has the purpose to synchronise all of the simulation processes. It’s a list of workstations ids that the manager is awaiting answer from. While this list is not different from empty, the simulation will not advance; Also when calling GenServer.start_link/3 , the option name is passed as an argument. This will register the manager process under the name of SimMan , and other processes (workstation actors) will be able to send messages to the manager through the registered name, without knowing its pid. After the simulation manager and all of the workstation processes are started, the manager sends each workstation 3messages with the following contents: 1https://hexdocs.pm/elixir/GenServer.html
4.2. Implementation 43 1. Info about other workstation pids . Before, a workstation process only knows about itself, but to implement the algorithm described before, it has to know the others also. It was chosen to not register named processes for the workstations, so it is necessary to pass the extra data structure (pids map) between all of them; 2. Each workstation will receive its own mean processing time of a package, calculated by the manager previously. This is needed to give an approximation of an event timestamp for packages that don’t possess info about quantities or workstations that don’t have quantifiable output performance. (This was referenced before in Workstation OEE); 3. Active packages at the moment, in any state of processing (not started yet or mid processing). The complete list is sent to all workstation processes, and then each one will filter the packages that will start/are active in their own place. The best solution here would be that each process access the database and retrieve only the respective packages. But having about 15 processes (for this case) consulting the database, plus normal users, would most likely exceed the maximum number of database connections available in the plan that will be used in Heroku (20)[ 19 ] when deployed. Causing some delays and/or unexpected errors. So, this way all the work is done in memory with only one process (simulation manager) accessing the database. With the Erlang and GenServer characteristics, a process has a First In First Out (FIFO) "mailbox", ensuring the ordering of the messages received by each workstation. To calculate the mean processing time for each workstation, are used the same functions described in the OEE plot. Reusing code/functions simplifies all of this process. The third message, active packages in the production line is the one to focus now. As it was referenced before at the beginning of this chapter, the same way quantity is not required when registering a new package in the platform, the production path it will go through can also be nil . This creates the following problem: "How to simulate all factory production if we don’t know packages will be processed?". The answer to this question is to obtain an approximate path for packages that don’t have one defined. After some inquiries with the company’s responsible and employees, to discover the best way to approximate those paths, the following pattern was discovered: Recurring clients order packages with the same processing path most of the times. So if Client A requests a book/magazine, most likely, next time will order something similar but with different contents. However, processing methods remain the same. This way, tracing a pattern of each client associated with a package will give us an approximated path for all those packages that don’t have one defined and are entering
4.2. Implementation 44 the simulation. Verifying this with some plots when in production would be interesting. Though, that won’t be done for now. 1defp send_active_packages(pids) do 2packages = Models.list_all_active_packages() 3grouped = Enum.group_by(packages, & !is_nil(&1.path)) 4 5approximate_paths = approximate_paths(packages) 6with_path = Enum.map(grouped.true,&filter_rest_places/1) 7 8without_path = 9Enum.map(grouped.false, 10 &filter_rest_places(&1,approximate_paths)) 11 12 total = with_path ++ without_path 13 #for packages that don’t have enough info (path or client history) 14 filtered = Enum.reject(total, & is_nil/1) 15 Enum.each(pids, 16 fn {_place, pid}-> send(pid, {:packages,filtered})end) 17 end In the code snippet above, we start from obtaining all active packages at the moment (packages that are completed), and then separate them in two different groups: the ones with path defined ( grouped.true ) and the ones without path ( grouped.false ). To trace a client pattern and approximate a path for a package the following flow is done: Figure 13: Calculate approximate paths by Client flow. After calculating every approximate paths for every client with active packages (function approximate_paths/1 ), all paths are filtered. In other words, the simulation will take into account previous states that have already been processed, removing the past ones from the full defined path.
4.2. Implementation 45 Figure 14: Filtering paths for simulation. The awaiting list in the simulation manager state is set with all the workstation ids. This way, for the simulation to proceed, the manager has to receive a response from every workstation process, indicating the next event to simulate or nil in case there are no packages in that workstation at the moment. On the workstation process side (SimPlace), each process starts with the following state: 1self_info:{name, id, order, debit, servers} 2pids:%{}, 3clocks:[], 4events:[], 5mean_time:0 Where, •self_info : is a tuple with the information that identifies that workstation process. Every process has its own information since there is only one process for each workstation; •pids: info about the other workstation’s pids; •clocks : each workstation process has a list of clocks .A clock will identify the timestamp for the next events, and a process has as many clocks as the number of servers. With this approach, we can easily simulate various packages being processed in the same workstation, synchronously;
4.2. Implementation 52 The recursive call, subtracts the remaining hours of the current shift are to hours , like the processing time was complete, passing timestamp also. 1def total_hours_for_work(timestamp, hours) do 2rest_of_shift = rest_hours_shift(timestamp) 3 4if rest_of_shift >= hours do 5Timex.shift(timestamp, seconds:hours) 6else 7next_shift = get_next_shift(timestamp) 8new_hour = next_shift.timestamp_start.hour 9new_minute = next_shift.timestamp_start.minute 10 11 update_shift_day(timestamp, next_shift) 12 |> Timex.set(hour:new_hour, minute:new_minute) 13 |> Timex.shift(seconds:-timezone_offset()) 14 |> total_hours_for_work(hours - rest_of_shift) 15 end 16 end With this, all of the simulation engine development is now detailed and explained. •Scheduling hourly simulations Since simulations need to run every hour, it is necessary to implement/use a scheduler that can handle that. For that, Quantum 2 was the solution chosen. With this package we can define recurring tasks as they were cronjobs. For example, the configuration for it to run the hourly simulation: 1config :pipe,Pipe.Scheduler, 2overlap:false, 3jobs:[ 4delivery_simulation:[ 5schedule:"0****", 6task:{Pipe.RecurringTasks, :delivery_simulation,[]} 7] 8] 2https://hexdocs.pm/quantum/readme.html#content
4.3. Outcomes and Summary 53 It is easy to understand that is possible to add more jobs to the list, completly independent from each other. The crontab format is minute, hour, day of month, month and day of week, being possible to also use second in special cases. The configuration above runs the function delivery_simulation() of the Pipe.RecurringTasks module every hour. Not running during nights or weekends could also be a good approach, and save some resources during that time. Despite being simple to configure, it was decided to run at every hour. The function that is called every time, is as simple as starting the simulation manager ( SimMan ), and the rest we have already detailed. The duration of the simulation is logged for debug and future analysis purposes. 1def delivery_simulation do 2time = 3fn -> SimMan.start_link() end 4|> :timer.tc() 5|> elem(0) 6|> Kernel./(1_000_000) 7 8Logger.info("Simulation Duration: #{time}s") 9end On the Pipe.Application module Pipe.Scheduler was added to the children list that will passed as argument to Supervisor.start_link(children, opts) . This means that the scheduler has the Application as supervisor and it will be restarted if some error occurs. 4.3outcomes and summary After implementing and developing all proposed features, (pages and features not referenced in this chapter can be found in Support Material Other relevant Frontend pages), some conclusions can be retrieved and analysed. One of the major goals was to develop a platform that could be modular and with the capability to add new features in the future. This was made possible by a separation of the backend and frontend, which can be developed and modified in parallel. Integration with external platforms such as the email server, database or deployment are generic and don’t depend directly on the ones that are currently used. On the other hand, heavier requests to the API were optimized through data processing whenever possible. These optimizations don’t reflect directly on response times but on preventing some associated problems with functional programming such as stack overflows. This problem was addressed previously in this chapter with the use of tail-recursive calls, but
4.3. Outcomes and Summary 54 sometimes streams were also used to process data. Due to their laziness, streams are useful when working with large (or even infinite) collections. Functions in the Stream module work in linear time. This means that the time it takes to operate grows at the same rate as the length of the list, just like the homologous eager versions found in the Enum module. All of the points presented here contribute to a lightweight code with fast response times and low memory usage (even with the hourly simulations) with the value normally bellow 80MB for the complete backend application. Figure 18: Memory distribution of backend application. Some other metrics will be referenced in the next chapter, as part of the case study analysis. The selected distributed approach for the delivery simulations account also for low memory usage, since Erlang processes are very lightweight, and fast calculation times for some relevant numbers of active packages inside the production line. Choosing a distributed approach for the delivery simulation, can introduce some extra complexity and errors to the codebase. Nevertheless, the Erlang philosophy of "let it crash" was used here. Since every SimPlace is started with a link 3 to SimMan , when one of these processes crashes, the link to SimMan is broken and the simulation manager process will also stop, propagating to the rest of workstation processes, halting every single process related to the simulation. Erlang has a limit of simultaneously alive Erlang processes of 32768,by default. But this limit can be raised to at most 268435456 processes [ 14 ]. So, in the worst-case scenario, memory leaks with badly terminated/blocked simulation processes need about 32768/(n+1) hours until memory shortage. n being the number of workstations of the pipeline plus 1for the simulation manager, giving plenty of time to resolve the problem before the system becomes completely unusable. This is a valid approach since the simulation runs every hour and the process that manages this scheduling is independent of the simulation ones. It is also supervised by the Application and if something very wrong happens, the scheduler is restarted. Users will still have the possibilty to consult the last updated prediction value until the next simulation runs. Some extra problems not accounted in the proposed algorithm for the simulation engine, due to the distributed approach, add more complexity to the platform and the engine itself. 3https://hexdocs.pm/elixir/GenServer.html#start_link/3
4.3. Outcomes and Summary 55 For this, and as it is known in other distributed projects, the extra complexity in the code can introduce aditional challenges on future changes or understanding of why some things are done like that. There are, also, some limitations such as not being able to count defected products and use a more "automatic", less error-prone, tracking method. Integration with the company’s ERP is also a problem. Office employees need to register the order twice (on the ERP on and this platform). Nonetheless, the current one used by Tipoprado does not offer a cloud version and also doesn’t provide a public API for integration.
5 CASE STUDY / EXPERIMENTS As expected, the case study for this dissertation is the implementation of the platform in Tipoprado’s production line. In this Chapter, we will explaine and detaile the following: •how the platform was put into use; •the impact of using the platform by the company’s employees; •the impact of the platform in the production line; •the impact of the platform with customer engagement and relationship. 5.1experiment setup The platform was deployed on Heroku 1 that simplifies a lot of the process. The server used has 512MB of Random-access memory (RAM) and 10 process types. For database PostgreSQL 2 was the selected one, and the database used in production has a limit of 20 simultaneous connections. As for mail server, Mailgun 3 is the solution opted and offers a lot features to analyse email delivery and user interaction that will have a major role in the final conclusions of the platform. Note that these options can be changed with small configuration changes, and the developed platform is not bound to use any of them in particular. Started collecting some initial data in September 2019, with a limited prototype of the platform. The goal was to obtain the most data as early as possible, so in the end, could be possible to analyse the evolution with as much information as possible. The configuration for the production line set by Tipoprado’s managers, has a total of 13 workstations with a total of 16 computers spread across the office and production floor, 1https://www.heroku.com/home 2https://www.postgresql.org/ 3https://www.mailgun.com/ 56
5.2. Results 57 using the platform (excluding external clients accessing it). 4of those computers have a barcode reader to introduce data more quickly and less error-prone than manual input. 5.2results Before starting reviewing the real impact in the company, we will examine how the business clients adhered to this new platform and method of communication/engagement. For this, let’s scrutinize email information given by Mailgun, where it is possible to see how many emails were sent and how the receivers (end clients) interacted with them. The whole period from which we have data (raging from 1September 2019 to 30 September 2020), was broken into quarters and the values are presented in Table 5. Sep-Dec (2019) Jan-Mar (2020) Apr-Jun (2020) Jul-Sep (2020) Sent 2616 2177 1166 1735 Delivered 99%99%100%99% Opened 227%240%231%186% Clicked 66%45%37%33% Table 5: Email delivery statistics by quarter. Analysing Table 5we can conclude that there was a big adhesion by end clients and the emails sent, with emails being opened more than once (as the rates above 100% show), and a mean of about 50% of them being clicked. By clicking an email, as defined in the Table 5, it means that the client clicked in a button or link that redirected him/her to the web application. A client can click in a link to consult the package current state or to answer a satisfaction survey, however, these two types of clicks are not distinguished here. Lower values after the second quarter can be mostly explained by the COVID-19 pandemic that affected the company’s production in about 70% during March, April and May, with slow recovery after June. With less production, fewer packages were registered and consequently fewer emails sent, and clients were less interactive. Clients can also consult and access the platform directly from the link provided, after accessing the first time or searching for the package using the provided unique code, in the application homepage. Although looking at the logs these two methods were not very used compared to simply clicking buttons in emails. Taking a look at the data produced by the platform and also using some of the developed plots together with a company’s employees survey, to support conclusions, let’s analyse some of the following topics:
5.2. Results 58 •Customer engagement and satisfaction As part of customer engagement, according to Tipoprado’s managers, during the year previous to start using the platform, (September 2018 to September 2019) about 50 reviews were received from end clients. And these were personally requested to them. Since the beginning they received 141, resulting in a 282% increase compared to the homologous period. Observing Table 6we can check on the evolution of the mean ratings received from clients. In these satisfaction surveys, clients were questioned about price, quality, and delivery schedule, and others, in a 1-5rating. Sep-Dec (2019) Jan-Mar (2020) Apr-Jun (2020) Jul-Sep (2020) Overall Rating 4.53 4.40 4.45 4.67 Table 6: Mean customer reviews rating by quarter. Just looking at the previous table we can’t conclude if the platform had any positive impact on those specific topics since the variations are small. Also, we don’t possess meaningful answers before the platform implementation, to compare these results with. Through this automatic survey end clients were also enquired about what they thought about this tracking platform, and 4.8is the mean rating. •Packages delivered on time Another key value to present here in the results topic is how the percentage of packages delivered on time evolved through the year. Similarly to the customer reviews, these values are analysed by quarter. Observing the next table, although we don’t have relevant data for the first quarter, there is a clear positive evolution of the percentage of packages delivered on time. Sep-Dec (2019) Jan-Mar (2020) Apr-Jun (2020) Jul-Sep (2020) Delivered on time — 53%88%96% Table 7: Percentage of packages delivered on time by quarter. At first sight, this can be correlated with higher levels of organization within the company and production. However, the reduced number of new orders during the global pandemics from March to June might have a major role here. It is expected that with more information, scrutinized next, will be possible to have a more concrete explanation.
5.2. Results 59 •Performance and Efficiency (OEE) These metrics were one of the mentioned in the implementation Chapter and have a direct relation with how a production line performs. The objective is to maximize the OEE, as OEE =A⇤P (in this case), and observing Table 8there is a clear negative evolution through the year. Sep-Dec (2019) Jan-Mar (2020) Apr-Jun (2020) Jul-Sep (2020) Availability 68%56%36%40% Performance — 108%109%108% OEE — 61%40%46% Table 8: Company’s workstations overall availability and performance by quarter. Again, we don’t have sufficient data to calculate Performance and OEE for the first 3months, but the noticeable decrease can be easily explained by the reduced values of Availability, caused by the pandemics. Workstations had less active time, but Performance kept stable and slightly above expected values through that period. Note that as there are many manual processes, expected performance values (maximum debit) were approximated by the company’s managers. These values can be adjusted in the platform. •Queue waiting times The other measure referenced in the implementation Chapter was the waiting time in queue for a package to start being processed in a certain workstation. When a company can reduce these "dead times", it’s a great step towards increased production levels. In order to keep it simple and easy to understand the values presented in the matrix provided by the platform’s plots page, were treated as a whole, instead of a A!B one. After this, the following approximations were achieved: Sep-Dec (2019) Jan-Mar (2020) Apr-Jun (2020) Jul-Sep (2020) Waiting Time (days) 3.7 2.2 1.7 1.35 Table 9: Average waiting times by packages stopped in a queue, by quarter. •Production pattern and bottlenecks Being able to identify a production pattern and bottleneck is also a good achievement of this platform. Looking at Figure 19, which represents a heat-map of where packages pass trough their production processes, and it is easy to understand the workstations that are more required and the ones that might compensate in investing more or not.
5.2. Results 60 Figure 19: Heat-map of packages in each workstation. Figure 19 is complemented by 20. In the figure bellow, red bars represent packages that have left that workstation and are waiting in line to start the next process, and blue represent the ones that are active at that moment in each workstation. The first column, as the name states, are the ones that haven’t been picked up yet. Here, the first 3workstations present a clear bottleneck with about 80% of packages accumulating in this area. Figure 19 confirms this, as these workstations are the most required ones. Figure 20: Number of packages at each workstation (paused and active). Note: both Figure 19 and 20 are screenshots from the platform implemented at Tipoprado.
5.2. Results 61 •Delivery dates simulation Looking at the delivery dates simulation it’s not possible to access the proximity of the expected values provided by the simulation engine. These predictions are dynamic and changing every hour, as said before, so the values at one moment are merely indicative to Tipoprado’s managers and employees. The analysis that can be made is on how the engine behaves in a real-world situation, and with values provided by logs, we get an average of 0,00384975s with a total of about 160 packages being simulated through the 13 different workstations, on the day measured (04/08/2020). Meaning that these simulations are almost instantaneous and with almost none to little effect on the platform’s overall performance. •Employees impact and opinions Since Tipoprado’s employees have great implications if the validity of the platform developed, it was decided to enquire all of them on its impact on the business. A total of 20 workers were part of an anonymous survey, with six questions to rate 1-5. These were the following: •P1: The use of this platform had a positive impact on the general organization of the company; •P2: The use of this platform had a positive impact on the production and efficiency of the company; •P3:The use of this platform had a positive impact on the relationship with clients; •P4: The extra time spent on registering data in the platform makes up in the long run; •P5:The ease of use of the platform; •P6:Overall analysis of the platform. Below, the average value of the answers provided enables to retrieve a fairly positive opinion on the platform by the people that are using it every day, for the last year (since September 2019). P1P2P3P4P5P6 Average 4 3.9 3.744.5 4.2 Table 10: Employees overall opinion on the platform. Analysing P3 in particular, since it’s based on the employees’ idea of how this platform impacted end clients, with the values provided by email information and the overall rating of the platform answered by these clients, it is safe to say that one of the major goals of this dissertation was accomplished.
bibliography 68 [42] Productoo. Boost your factory performance with Productoo. https://www.slideshare. net/PavlaDolealov1/boost-your-factoryperformance8roidrivers . Accessed: 2019-10-17. page 14. [43] Python. About. https://www.python.org/about/. Accessed: 2020-10-26. [44] QRcodesHowTo.com. 2d Barcode versus 1d Barcode. http://www.qrcodeshowto.com/ what-is-a-qr-code/2d-barcode-versus-1d-barcode-with-pictures/ . Accessed: 2019-10-17. [45] R. Fielding, UC Irvine, J. Gettys, Compaq/W3C, J. Mogul, Compaq, H. Frystyk, W3C/MIT, L. Masinter, Xerox, P. Leach, Microsoft, T. Berners-Lee . Hypertext Transfer Protocol – HTTP/1.1.https://www.ietf.org/rfc/rfc2616.txt,1999. [46] Ray Wang. Why Live Engagement Marketing Supercharges Event Marketing.2016. [47] React. Controlled Components. https://reactjs.org/docs/forms.html# controlled-components. Accessed: 2019-01-02. [48] React Docs. Virtual DOM and Internals. https://reactjs.org/docs/faq-internals. html. Accessed: 2020-01-02. [49] React-vis. React visualization library. https://uber.github.io/react-vis/ . Accessed: 2019-01-14. [50] ReactJS. React - A JavaScript library for building user interfaces. https://reactjs. org/. Accessed: 2020-10-25. [51] Red Hat. What is an API? https://www.redhat.com/en/topics/api/ what-are-application-programming-interfaces. Accessed: 2020-10-25. [52] Rouse, Margaret. internet of things (iot). [53] Roy Thomas Fielding. Architectural Styles and the Design of Network-based Software Architectures. pages 76–105,2000. [54] Ruby on Rails. Imagine what you could build if you learned Ruby on Rails. . . . https: //rubyonrails.org/. Accessed: 2020-10-25. [55] Rust. Learn Rust. https://www.rust-lang.org/learn. Accessed: 2020-10-24. [56] Vladimir Rykov and Dmitry Kozyrev. On Sensitivity of Steady-State Probabilities of a Cold Redundant System to the Shapes of Life and Repair Time Distributions of Its Elements.2018. [57] Klaus Schwab. The Fourth Industrial Revolution. Currency, 2017. ISBN-10:9781524758868.
bibliography 69 [58] Seebo. How Factory 4.0is transforming production. https://www.seebo.com/ factory-4-0. Accessed: 2019-10-14. [59] Semantic-UI. Semantic-UI React. https://react.semantic-ui.com/ . Accessed: 2019- 01-10. [60] Spring. Why Spring? https://spring.io/why-spring. Accessed: 2020-10-26. [61] Steve Burbeck. Applications Programming in Smalltalk-80(TM): How to use Model- View-Controller (MVC). https://web.archive.org/web/20120729161926/http:// st-www.cs.illinois.edu/users/smarch/st-docs/mvc.html ,1992. Accessed: 2020- 10-25. [62] Josefin Stintzing and Frederik Norrman. Prediction of queuing behaviour through the use of artificial neural networks.2017. [63] Marc Ingo Wolter, Anke Mönnig, Markus Hummel, Christian Schneemann, Enzo Weber, Gerd Zika, Robert Helmrich, Tobias Maier, and Caroline Neuber-Pohl. Industrie 4.0und die Folgen für Arbeitsmarkt und Wirtschaft.2015. ISSN 2195-2655.
GLOSSARY API Application Programming Interface. 15,19,23,25,28,30–32,53,55 CS Continuos Simulation. 13,14 DES Discrete Event Simulation. 13,14,18 DOM Document Object Model. 18,20 E2EEnd to End. 6 ERP Enterprise Resource Planning. 7,10,19,55,64 FCFS First Come First Served. 12 FIFO First In First Out. 43 HTTP Hypertext Transfer Protocol. 15,23–25 IoT Internet of Things. 6,8,19,23,63 JWT JSON Web Token. 31–33,35 MES Manufacturing Execution System. 7,19,64 ML Machine Learning. 5,12,18 MVC Model-View-Controller. 15 MVPs Minimum Viable Products. 15 MVVM Model-View-View-Model. 15 OEE Overall Equipment Effectiveness. 7,23,39,41,43,59 OS Operating System. 25 PaaS Platform as a Service. 6 RAM Random-access memory. 56 REST Representational State Transfer. 19,23,28,30 RFID Radio Frequency Identification. 8–10 ROI Return on Investment. 7 SMTP Simple Mail Transfer Protocol. 23 SOA Service-Oriented Architecture. 15 UIs User Interfaces. 17 70
Glossary 71 UPC Universal Product Code. 10 UTC Universal Time Coordinated. 51 VM Virtual Machine. 20
A SUPPORT MATERIAL a.1other relevant frontend pages Figure 21: Package list page. Quick view information or click to open detailed page. 72
A.1. Other relevant Frontend pages 73 Figure 22: New package page. Figure 23: Calendar with weekly view for delivery dates.
A.1. Other relevant Frontend pages 74 Figure 24: Package public view page. Information available to the end client. Figure 25: Number of package statistics page.
A.1. Other relevant Frontend pages 75 Figure 26: Workstation statistics page.
A.1. Other relevant Frontend pages 76 Figure 27: Waiting time in queue statistics page.
A.1. Other relevant Frontend pages 77 Figure 28: Ratings received from end clients page.