# Model Predictive Control for Flexible Job Shop Scheduling in Industry 4.0 +
## 3 Model Generation
### Generation of the Discrete Time Petri Net Model
This is surely not desired but in the problem described in Section 2 there is no external driver prohibiting this solution. In the same sense, extending an existing feasible input trajectory \(u(\cdot|k)\) by a new predicted input \(u(N-1|k+1)=0\) in the candidate trajectory for the next time step used in the proof of Lemma 3 does not plan to start any new task in the last step of the prediction. As explained in Section 2.2, there is a production related objective that requires taking some action due to its economic motivation. This objective needs to be formulated in the form of a cost function \(c(x,u)\) depending on the state \(x\) and the input \(u\). In the sequel we will investigate properties of such a cost function, which we assume to be known and given, that allow to adjust the prediction horizon \(N\) such that the production problem controlled with the MPC is guaranteed to be completed. In this process we exploit the hierarchical nature of the production problem that is composed of jobs, which themselves are composed of tasks. We first provide a sufficient condition for the completion of a single operation, i.e., a single task of a single job. The arguments in the proof of the completion of an operation motivate the formulation of a more efficient MPC scheme. Finally, we provide a condition for the completion of a job and finally of the whole production problem for both MPC schemes. ### Completion of An Operation

Our goal is to achieve optimal performance of the system in closed loop through applying MPC. For a flexible manufacturing system (FMS), the first and most important goal is to produce the requested products. In the formulation of the production problem in Section 2, this means the completion of all the tasks of all jobs. In the model generated in Section 3, this is represented as the convergence to a state in which all completion places are marked. In this section, we will first guarantee the completion of a single operation if some clearly specified condition are fulfilled. A second goal in an FMS is to minimize production cost or to maximize profit. This can be conveniently formulated with a cost function. In the MPC, this cost function is directly use as objective function of the optimization problem (6a). As the cost function is only optimized over a limited prediction horizon \(N\), the reward of performing actions in the manufacturing system needs to be perceived through evaluating the cost function during this limited time frame. This results in a condition on the cost function \(c(x,u)\) and subsequently in a condition on the prediction horizon \(N\). In the sequel we will show how the prediction horizon \(N\) must be chosen based on the given manufacturing system as described in Section 2 and a given cost function \(c(x,u)\) in order to guarantee completion of a specific operation \(O=(\tau,J)\) in the production problem with the MPC. To achieve this result, we first give a general condition that must hold such that the MPC completes _any_ operation. **Lemma 4** (Starting an operation). : _Given a Petri Net of a flexible manufacturing system in its state space form (3), (4) is generated with the Algorithms 1 and 2. If for a steady state \(x^{s}\) all optimal input trajectories \(u^{*}(\cdot|k)\) for the MPC problem (6) initialized at \(x(k)=x^{s}\) are such that \(u^{*}(0|k)\
eq 0\), then at least one operation \(O=(\tau,J)\) will be started at time instant \(k\) in closed loop (7), the operation \(O\) will eventually be completed, and it will remain completed._

Proof of Lemma 4.: In Algorithm 2, the only transitions that are added to the set of controlled transitions \(\mathbb{T}_{C}\) are starting transitions \(T_{(\ldots,S)}\). Therefore, every optimal first input \(u^{*}(0|k)\
eq 0\) fires at least one starting transition and thereby initiates the execution of at least one operation by marking at least one production place \(P_{(\ldots,P_{1})}\). The first input \(u^{*}(0|k)\) is applied to the closed loop system controlled by the MPC (7) at time instant \(k\).