# Integration of Production Planning and Scheduling Based on RTN Representation under Uncertainties
## 2 Mathematical Model
### Scheduling Layer Model
#### 2.2.1 Deterministic Model  
1. Objective function:  
\[ \begin{array}{l}\text{min}Def_{r,k}-\sum\limits_{n\in N}d(r,n)\ ;k\in K\,r\in R ^{s}.\end{array}  \tag{20}\]  
The objective function is the minimization of the value of the difference between the task quantity assigned by the planning layer and the task quantity completed by the scheduling layer. The first part represents the reference task quantity assigned at the end of the planning period, and the second part represents the total final delivery of products completed by the scheduling layer within the planning period. 2. Resource balance constraints:  
\[ \begin{array}{l}E(r,n)=E(r,n-1)+\sum\limits_{i\in I_{r}}\Big{[}\mu_{ri}^{p} \cdot w(i,n-1)+\rho_{ri}^{p}\cdot b(i,n-1)\Big{]}+\sum\limits_{i\in I_{r}} \Big{[}\mu_{ri}^{c}\cdot w(i,n)+\rho_{ri}^{c}\cdot b(i,n)\Big{]};\\ r\in R\,n>1,n\in N.\end{array}  \tag{21}\]  
\[ \begin{array}{l}E(r,n)=E_{ini}+\sum\limits_{i\in I_{r}}\Big{[}\mu_{ri}^{c} \cdot w(i,n)+\rho_{ri}^{c}\cdot b(i,n)\Big{]};r\in R,n\text{=}1.\end{array}  \tag{22}\]  
Constraints (21) and (22) respectively represent resource balance constraints of subsequent event points and the initial event point. The amount of available resources at event \(n\ E(r,n)\) is equal to theamount of available resources at the previous event point \(E(r,n-1)\) plus the production amount of the previous event point, and the consumption of the current point. Moreover, in Constraints (21) and (22), \(\mu_{ri}^{c}\leq 0\), \(\rho_{ri}^{c}\leq 0\). 3. Capacity constraints:  
\[E_{r}^{\min}\leq E(r,n)\leq E_{r}^{\max}\ ;r\in R,\,n\in N. \tag{23}\]  
\[w(i,n)\cdot B_{i}^{\min}\leq b(i,n)\leq w(i,n)\cdot B_{i}^{\max};n\in N,i\in I _{r}. \tag{24}\]  
Constraint (23) represents that the availability of the resource status \(r\) at the event point \(n\) is limited between the resource upper limit \(E_{r}^{\max}\) and the resource lower limit \(E_{r}^{\min}\). For device resources, this constraint limits the appropriate number of device units; for material resources, this constraint limits the storage of material resources. In Constraint (24), \(B_{i}^{\max}\) is the upper limit of material handling amount and \(B_{i}^{\min}\) is the lower limit of material handling amount. When \(w(i,n)=1\), material handing amount \(b(i,n)\) of task \(i\) should be between the upper limit of material handling amount \(B_{i}^{\max}\) and the lower limit of material handling amount \(B_{i}^{\min}\); otherwise, when \(w(i,n)=0\), this constraint forces \(b(i,n)=0\). 4. Demand constraints:  
\[\sum_{n\in N}d(r,n)\leq Def_{r,k}\ ;k\in K\,\,r\in R^{s}. \tag{25}\]  
\[td(r,k)=Def_{r,k}-\sum_{n\in N}d(r,n)\ ;k\in K\,\,r\in R^{s}. \tag{26}\]  
Constraint (25) represents that the reference task quantity \(Def_{r,k}\) assigned by the planning layer within the specified period \(k\) shall be greater than or equal to the total product delivery quantity. In Constraint (26), the backlog order quantity of product \(td(r,k)\) of the scheduling layer should be equal to the difference between the reference task quantity \(Def_{r,k}\) of the planning layer and the final delivery quantity of the product, the backlog order quantity \(td(r,k)\) in the obtained optimization results of the scheduling layer is fed back to the next period of planning model as \(td_{i,k+1}\) in Constraint (5). When we first solve the planning layer, we treat \(td_{i,k}\) as \(0\) and get the first period of optimization result of the planning layer. By inputting this result into the scheduling layer, the optimization result of scheduling layer, optimized for the first time, will be obtained. The backlog order quantity \(td(r,k)\) in the obtained optimization results of the scheduling layer is fed back to the next period of planning model as \(td_{i,k+1}\). The final optimization results of planning layer and scheduling layer are obtained by iterative solution. \[td(r,k)=td_{i,k+1}. \tag{27}\]  
5.