## 4 Web System for the Optimization of Manufacturing and Distribution of Materials
### Recommender System for the Effective Assignment of Requests and Optimization of Delivery Times  
The core of the web system includes a recommender subsystem that aims at automatically assigning requests and optimizing manufacturing and delivery times. The main goal is to reduce the time between a request and its delivery to a maximum of two days. The algorithm takes into account the current workload of the collaborators (fabrication units) and tries to find an optimal planning in which the times are minimized. Each time a person or institution orders one or several 3D parts, a request is generated into the system. A request \(r\) is defined as the tuple \((p,ni,d,pr)\), i.e., \(r=(p,ni,d,pr)\), where \(p\) is the priority of the request, \(ni\) is the number of items requested (or 3D parts), \(d\) is the date of request and \(pr\) is the place of request. The priority is established according to the type of applicant and will take values in the range [1; 2; 3; 4; 5], with five being the highest priority. Table 3 summarizes the association between priorities and the different sectors. The system has a finite set of fabrication units, \(FU=\{fu_{1},fu_{2},\dots,fu_{n}\}\). That is, places where 3D parts are made (homes or laboratories). A fabrication unit \(j\) denoted as \(fu_{j}\) is defined as the pair \((pr,pc)\), i.e., \(fu_{j}=(pr,pc)\), where \(pr\) is the place where is located the fabrication unit and \(pc\) is its production capacity. The concept of production capacity captures how many items are being produced over an hour. Each fabrication unit has one or more 3D printers, each with different features and production capacity. Production capacity of the unit will be calculated as:  
\[pc=\sum_{i=0}^{k}n\cdot pc_{i} \tag{1}\] \begin{table}
\begin{tabular}{c c} \hline \hline
**Sector** & **Priority** \\ \hline Healthcare System & 5 \\ Law enforcement & 4 \\ Public bodies & 3 \\ Social Services & 2 \\ Others & 1 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Association of priorities to the sectors. where \(pc_{i}\) is the production capacity of the 3D printer, of which the type is \(i\) and \(n\) is the number of them available in the unit. The \(pc_{i}\) value is the number of items that an \(i\) type printer can produce per hour. On the other hand, \(L\) is a list of ordered requests according to the following criterion:  
\[r_{i}>r_{j}\text{ iff }(pr_{i}>pr_{j})\text{ OR }((pr_{i}=pr_{j})\text{ AND }(ni_{i}>ni_{j})\text{ AND }(d_{i}>d_{j}))\]  
To make the assignment of the first request \(r_{i}\) of the list \(L\) to one fabrication unit, the following steps are done:  
1. Calculate the estimated manufacturing time of the requested items in \(r_{i}\) for each available fabrication unit \(fu_{j}\). The estimated time is noted as \(t_{ji}\), and the distance between the place of manufacture and the point where the request is made, it is noted as \(d_{ji}\). The value \(t_{ji}\) is calculated as:  
\[t_{ji}=\frac{ni_{r_{i}}}{pc_{fu_{j}}} \tag{2}\]  
where \(ni_{r_{i}}\) is the number of items of the request \(r_{i}\) and \(pc_{fu_{j}}\) is the production capacity of the fabrication unit \(fu_{j}\). 2. Calculate for each fabrication unit \(fu_{j}\) available and its suitability for the request, it will be noted as \(S_{ji}\) and calculated as:  
\[S_{ji}=\frac{t_{ji}}{max\{t_{ji}\}}\times\alpha+\frac{d_{ji}}{max\{d_{ji}\}}\times\beta \tag{3}\]  
where \(\alpha\) and \(\beta\) are two parameters used to weight the importance of each of the factors affecting the calculation (manufacturing time and distance). We set them to \(\alpha=0.4\) and \(\beta=0.6\) to penalize the cost of transport more than completion time. In other words, it was more important for us to deal with the request early than the effort it might take to send them to the destination. Parameters \(\alpha\) and \(\beta\) meet the following restrictions: (1) \(\alpha\), \(\beta\in[0,1]\) and (2) \(\alpha+\beta=1\). 3.