# Predictive Scheduling with Markov Chains and ARIMA Models
## 3 Production Scheduling under Technological Machine Failure Constraint
### Prediction of Failure and Machine Repair Times
Let \(\ \{x_{t}\}_{0\leq t\leq n}\) be the realization of Markov chain, where \(n_{i}=\#\{t:x_{t}=s_{i},\ 0\leq t\leq n\}\) is the number of moments for which the system was in \(s_{i}\) state, \(1\leq i\leq k\) and \(\sum_{i=1}^{k}n_{i}=n\). The value \(n_{ij}=\#\{t:x_{t}=s_{i},x_{t+1}=s_{j},\ 0\leq t\leq n-1\}\) represents the number of transitions from the state \(s_{i}\) to the state \(s_{j}\) for \(1\leq i,j\leq k\) and \(\sum_{j=1}^{k}n_{ij}=n_{i}\). We calculate the estimator of transition probability from \(s_{i}\) state to \(s_{j}\) state as \(\hat{p}_{ij}=\frac{n_{ij}}{n_{i}}\) for \(1\leq i,j\leq k\). In this work, the goodness of fit test is used to verify [PERSON] property \(\chi^{2}\)[40; 41]. At the significance level \(\alpha\in(0,1)\), we create a working hypothesis: \(H_{0}:P(X_{t}=x|X_{t-1}=y,\ X_{t-2}=z)=P(X_{t}=x|X_{t-1}=y)\) (the chain \(\ \{X_{t}\}_{t\in N}\) meets [PERSON] property) and an alternative hypothesis: \(H_{1}:P(X_{t}=x|X_{t-1}=y,\ X_{t-2}=z)\
eq P(X_{t}=x|X_{t-1}=y)\) (the chain \(\ \{X_{t}\}_{t\in N}\) does not meet [PERSON] property), where \(x,y,z\in S\). To verify the hypothesis \(H_{0}\), we calculate the test statistics:  
\[\chi^{2}_{e}={\sum}_{i=1}^{k}\sum{\sum}_{j=1}^{k}\sum{\sum}_{v=1}^{k}\frac{ \Big{(}n_{ijv}-n_{ij}\hat{p}_{jv}\Big{)}^{2}}{n_{ij}\hat{p}_{jv}}, \tag{11}\]  
which has a \(\chi^{2}\) distribution with \(k^{3}\) degrees of freedom and \(n_{ijv}=\#\{t:x_{t}=s_{i},x_{t+1}=s_{j},x_{t+2}=s_{v},\ 0\leq t\leq n-2\}\) is the number of transitions from state \(s_{i}\) to state \(s_{j}\) and next to state \(s_{v}\) for \(1\leq i,j,v\leq k\). The critical value is a quantile of order \(1-\alpha\) for \(\chi^{2}\) distribution with \(k^{3}\) degrees of freedom. We denote as \(\chi^{2}\Big{(}1-\alpha,k^{3}\Big{)}\). If \(\chi^{2}_{e}<\chi^{2}\Big{(}1-\alpha,k^{3}\Big{)}\), then at the significance level \(\alpha\), there are no grounds for rejecting the working hypothesis \(H_{0}\). So, we can assume that the chain \(\{X_{t}\}_{t\in N}\) meets Markov property. When \(\chi^{2}_{e}\geq\chi^{2}\Big{(}1-\alpha,k^{3}\Big{)}\), then at the significance level \(\alpha\) we reject the working hypothesis \(H_{0}\) in favor of the alternative hypothesis. Thus, the chain \(\ \{X_{t}\}_{t\in N}\) does not meet Markov property. An ARIMA model, which usually correlates historical values in a time series, is applied to forecast the repair time. The behavior of the considered time series can be predicted (i.e., forecast with appropriate probability) based on current observation and historical data (dataset). Let \(\ \{rt_{t}\}_{t\in N}\) denote the sequence of times needed to repair a plant. Because the times needed do remove the failures can take only positive values, the variance-stabilizing transformation  
\[\varepsilon_{t}=ln(rt_{t}) \tag{12}\]  
can be applied. The series \(\{\epsilon_{t}\}_{t\in N}\) is identified using \(ARIMA(p,r,q)\) models, \(p,r,\ q\in N\) (auto-regressive integrated moving average) [42; 43; 44; 45]. In this paper, the logarithm of repair time is modelled as follows:  
\[\Delta^{r}\epsilon_{t}=\alpha_{0}+\alpha_{1}\ \Delta^{r}\epsilon_{t-1}+\ldots+ \alpha_{p}\Delta^{r}\epsilon_{t-p}+\epsilon_{t}-\theta_{1}\epsilon_{t-1}- \ldots-\theta_{q}\epsilon_{t-q} \tag{13}\]  
where \(\{\epsilon_{t}\}_{t\in N}\) is a sequence of independent random variables with distribution \(N\Big{(}0,\ \sigma^{2}\Big{)}\). To estimate the integration degree, Augmented Dickey-Fuller (ADF) and the Kwiatkowski-Phillips-Schmidt-Shin (KPSS) [42; 46; 47] tests are applied. The Markov chains and ARIMA models are implemented to determine the values of elements of sets \(FT_{MI}\) and \(TB_{MI}\). The analysis of historical machine failure data leads to determining important failure parameters, which can subsequently help establish buffer time periods in the predictive production scheduling method.