## 3 Methodology--Mathematical Modelling and Heuristic Optimization Method
#### 3.1.2 Real-Time Logistics Resource Optimization  
The second phase of our approach includes a real-time routing and scheduling problem. Within the frame of this phase, the extended assignment and routing can be modified depending on the real-time information of matrix production systems and ERP. The decision variables of the real-time logistics resource optimization describe the decisions to be made. In this model it must be decided which new supply-demand by which AGV in which time is picked up. This decision represents an integrated assignment and scheduling problem. With this in mind, we define the following positions based on the results of extended logistics resource optimization describing the layout of the matrix production supply problem:  
* \(p_{s_{r\lambda}}^{x},p_{s_{\lambda}}^{y}\) is the x and y coordinate of the scheduled matrix cell \(s_{r\lambda}\) of scheduled route \(r\),
* \(p_{\phi}^{Px}\) and \(p_{\phi}^{Py}\) is the x and y coordinate of the pickup matrix cell of the new supply-demand \(\psi\),
* \(p_{\psi}^{Cx}\) and \(p_{\psi}^{Dy}\) is the x and y coordinate of the destination matrix cell of the new supply-demand \(\psi\). The objective function of the problem describes the minimization of the energy consumption of the whole in-plant supply process including scheduled routes (extended optimization) and new supply-demands (real-time optimization). \[EC=EC^{SR}+EC^{NSP}+EC^{NSD}\rightarrow\text{min.} \tag{20}\]  
where \(EC^{SR}\) is the energy consumption of scheduled supply-demands without any assigned new supply-demands, \(EC^{NSP}\) is the energy consumption of pickup route of new assigned and scheduledsupply-demand, and \(EC^{NSD}\) is the energy consumption of delivery route of new assigned and scheduled supply-demand. The first part of the objective function (20) includes the sum of energy consumption of scheduled supply-demands without assignment of new supply-demands, where the energy consumption is the function of positions of matrix cells for pickup and delivery, the loading of AGVs and the specific energy consumption, as written in (9). The second part of the objective function (20) includes the energy consumption of the pickup route of new assigned and scheduled supply-demand:  
\[EC^{NSP}=\sum_{r=1}^{r_{max}}\sum_{\psi=1}^{\psi_{max}}x_{rA\psi}^{P}\Big{(} \xi_{s_{rA-1}\psi}\Big{(}p_{s_{rA-1}}^{x},p_{s_{rA-1}}^{y},p_{\psi}^{x},p_{\psi }^{y}\Big{)}+\xi_{s_{rA}\psi}\Big{(}p_{s_{rA}}^{x},p_{s_{rA}}^{y},p_{\psi}^{x},p _{\psi}^{y}\Big{)}\Big{)}e_{r} \tag{21}\]  
where \(r_{max}\) is the total number of scheduled routes within the time frame, \(\psi_{max}\) is the number of new supply-demands within the time frame (in the case of real-time scheduling \(\psi_{max}=1\) because new supply-demands are scheduled real-time and they are not collected to be scheduled together), \(x_{rA\psi}^{P}\) is the assignment matrix of pickup matrix cells of new supply-demands to the scheduled routes. \(x_{rA\psi}^{P}\) takes value 1 if the new supply-demand \(\psi\) is assigned to route \(r\) following scheduled supply-demand \(\lambda\), otherwise 0. The third part of the objective function (20) includes the energy consumption of the delivery route of new assigned and scheduled supply-demand:  
\[EC^{NSD}=\sum_{r=1}^{r_{max}}\sum_{\psi=1}^{\psi_{max}}x_{rA\psi}^{D}\Big{(} \xi_{s_{rA-1}\psi}\Big{(}p_{s_{rA-1}}^{x},p_{s_{rA-1}}^{y},p_{\psi}^{x},p_{ \psi}^{y}\Big{)}+\xi_{s_{rA\psi}}\Big{(}p_{s_{rA}}^{x},p_{s_{rA}}^{y},p_{\psi} ^{x},p_{\psi}^{y}\Big{)}\Big{)}e_{r} \tag{22}\]  
where \(x_{rA\psi}^{D}\) is the assignment matrix of destination matrix cells of new supply-demands to the scheduled routes. \(x_{rA\psi}^{D}\) takes value 1 if the pickup matrix cell of the new supply-demand \(\psi\) is assigned to route r following scheduled supply-demand \(\lambda\), otherwise 0. The solutions of this integrated assignment and scheduling problem are limited by the following three constraints:  
_Constraint 4:_ The capacity of AGV is not to exceed after assignment of new supply-demand.