{'fraction_non_alphanumeric': 0.02633757836218113, 'fraction_numerical': 0.006702677128099988, 'mean_word_length': 4.74626189397372, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Closed-loop Scheduling in a canned food factory

This paper addresses the problem of closed-loop operation of scheduling, together with the interaction of control and scheduling, for a class of processes that appear very often in industry: those that combine continuous production lines with parallel batch units that share some resources. The paper presents a novel approach to this problem, including batching and a new type of precedence in the assignment problem. It also considers the effect of shared resources on the duration of the cycle time of the batch units. The approach is illustrated with a real-life example of a canned tuna factory


INTRODUCTION
In a context of increasing competition and regulations, operating in the most efficient way while respecting constraints imposed by processes, products, safety or legal regulations is of outmost importance. The field of Process Systems Engineering (PSE) has developed many methods and algorithms for production optimisation both for continuous plants (e.g. Real Time Optimisation (RTO) and Model Predictive Control (MPC) (Alonso et al. 2013)) and for batch ones, where planning and scheduling are the most important tools (Harjunkoski et al. 2014). Nevertheless, implementing these tools in the corresponding processes as isolated islands is only a first step for exploiting the full potential of digitalisation. Large gains can be additionally obtained with their integration in two dimensions: horizontally, connecting the information and actions on different processes among them; and vertically, linking the different decision levels that appear in the so-called automation pyramid, Fig. 1.
Horizontal integration means that the operation of the different interconnected processes must be coordinated to avoid bottlenecks or to take actions in advance to compensate the effects of changes among subsystems. In particular, when continuous and batch lines are in operation this implies additional difficulties because of the different ways of functioning and models and operational tools involved. Meanwhile, vertical integration faces the problem of the coexistence of different time scales and aims in the different decision layers but provides extra flexibility and information to all levels involved, widening the feasible space for computing optimal decisions in each of them. Integration among RTO and MPC has given rise to economic MPC (Engell 2007) and there are also good contributions regarding the integration of scheduling and planning (Zhang et al. 2019), but there are not so many works dealing with the integration of MPC and scheduling. In (Nie et al. 2014) authors show on a two reactors case that it is possible to integrate both technologies in a single dynamic optimisation and solve it efficiently. But, when faced with larger industrial environments, this solution may be impractical due to the size of the associated mixed-integer optimisation problem. Additionally, from the point of view of operators, its implementation in a control room may be more difficult if control is not maintained as a separated activity. This calls for some type of integration that, keeping the control layer functionality, provides an interchange of information that improves global operation.

Fig. 1. Automation pyramid
At the same time, another aspect to consider regarding implementation is the presence of variables with uncertain values and the need to quickly adapt schedules to the changes that take place in the operation of the plant (failures of assets, changes in aims or operating conditions…). The straightforward solution is to re-schedule the planned operation when any of these changes arrives, using updated plant information. But one may think in doing this in real-time at regular intervals with shorter time horizons. Recent contributions to this topic can be found in (Gupta et. al 2019;Palacín et al. 2019).
In the paper, we address the problem of closed-loop operation of the scheduling together with the interaction of control and scheduling for a class of processes that appear very often in industry: those that combine continuous production lines with parallel batch units that share some resources. The paper presents a novel approach to this problem, including a new type of precedence in the assignment problem and considering the effect of shared resources on the duration of the cycle time of the batch units. The approach is illustrated with a real life example of a canned tuna factory.
The paper is organized as follows. After the introduction, section 2 presents the industrial framework and the associated aims and problems to address. Then, section 3 describes the mathematical approach, followed by section 4 that is dedicated to the closed-loop scheduling implementation. Finally, section 5 deals with the integration scheduling-control and section 6 gives results that show the performance of the method. The paper ends with a Conclusions section.

Processes to be addressed
The type of processes considered are represented in Fig. 2. In the picture we can see a flow of different products (triangles) arriving at random times from continuous production lines which must be processed in a set of parallel batch units (blue boxes). The products must be grouped and wait forming queues or stored until a group can be processed. There are some limited shared resources (e.g. manpower). The cycle time of the batch operation may depend on these shared resources and on the type of products they are processing. This interface between continuous and batch production is often the place where bottlenecks appear, being of outmost importance to take the right operation decisions to minimize them, e.g. how the groups are formed. Main constraints appear linked to the shared resources and to the influence that some of them (e.g. heating steam) may have on the cycle time of the batch units. Typical aims are minimising makespan, cost, energy use or maximising throughput, which requires an adequate scheduling formulation.
Changes in the operation of the batch units may affect the ease or feasibility of scheduling. The problem was addressed in (Palacín and de Prada 2019) organising the scheduling so that it avoided interfering with the control layer. Here, this limitation is removed and the interaction is fully considered.

Canned tuna factory
To provide a more precise formulation of the scheduling, it is exemplified with the case of a canned tuna factory. The overall process is schematized in Fig.3. After preparation (essentially thawing and cooking) the tuna is sent to automated canning lines (filling and sealing). These operate in parallel and generate cans of different sizes and preparations, according to the production planning of the factory, which must be sterilized to avoid growing of toxic substances. This is done in a set of autoclaves working in batch mode and in parallel. After that, the cans are sent to the packaging section and then distributed to clients.

Fig.3 Schematic of a typical canned tuna factory
As mentioned before, the most critical operating point is the interface between the automated canning lines and the batch units. More in detail, as illustrated in Fig.4, the different types of cans arriving from the automated lines are placed in carts, so that each cart contains only one kind of cans. Carts are then sent to sterilizers (autoclaves), each one being able of processing a few carts simultaneously. Arriving carts wait in a waiting area until a suitable group of carts is ready and a sterilizer is free. An important constraint refers to the maximum waiting time of a cart before it enters an autoclave to prevent the formation of histamine. After being sterilized, the carts are unloaded and sent back to the head of the line. Once a group of carts is loaded in an autoclave, a sequence of control actions starts in that unit, following three well defined stages shown in Fig. 5. Initially, cans are heated up by means of superheated water (previously heated on a plate heat exchanger with steam) to a desired "plateau" temperature inside the autoclave that is maintained in the second stage for a certain time in order to ensure that lethality (a variable related to food safety) is above a desired value. After maintenance, cans are cooled down under pressure control and finally discharged and sent to the packaging lines. The duration of the stages and time-temperature profiles depend on the type of cans being processed and steam availability. One important point of the operation is related to the fact that all autoclaves are connected to a common steam ring feeding their respective heat exchangers. Hence, if two autoclaves coincide in time in the heating phase, it may happen that the steam pressure drops so that the time required by the control system to reach the temperature setpoint enlarges, increasing the duration of the heating phase. This is illustrated with the example of Fig.6 where the heating (orange), plateau (green) and cooling (blue) phases of four autoclaves are displayed over time. As the heating phase of three of them overlap, their duration is enlarged (light orange) and, consequently, the makespan may be enlarged too.
Optimal operation is formulated as a scheduling problem that considers the current situation of the production lines and the expected arrival of the different types of carts within a certain future horizon to generate the optimal decisions concerning current and future cart grouping and sterilizers operation. This allows launching the scheduling software at regular time intervals, adapting the operation to the new conditions that may appear, in a similar way as MPC is implemented. Fig. 6 Operation of 4 autoclaves where three of them overlap the heating phase (orange), which is enlarged.

MATHEMATICAL FORMULATION
This includes two main sub-problems: the assignment of carts and the interaction with the autoclaves operation and control due to the use of steam as a shared resource.

Assignment problem
According to the previous section, three main points appears in the assignments of carts: (a) How to assign carts to groups (b) How to assign groups to autoclaves and (c) When each autoclave should start operating. All of them must respect constraints and the formulation must take into account the presence of shared resources. Dealing with these shared resources is easier when a discrete time basis is employed for the mathematical formulation. Nevertheless, the use of discrete time implies that the actions can only be taken at discrete times. This is very restrictive for an operation in realtime involving hundreds of carts unless the grid size is reduced and the size of the problem is enlarged significantly. Alternatively, we propose a continuous time formulation instead, with the following notation regarding sets: i ∈ I : the carts j ∈ J : the group of carts that is going to be sterilized in the same autoclave at the same time (slots) k ∈ K : the autoclaves h ∈ H : the types of cans Sets are linked through the binary variables: Xi,j = 1 if cart i belongs to group j Yj,k = 1 if group j will be processed in autoclave k Uj = 1 if group j has carts included actually Vj,h = 1 if group j has at least one cart of type h included Gj,h = 1 if group j will be processed using the recipe of can h Ti,h = 1 if cart i has been filled with cans of type h The following real parameters are considered: rh heating time required for cans of type h in the autoclave eh plateau plus cooling time required for h type cans τ maximum waiting time of a cart before being processed tai expected arrival time of cart i tpj duration of the processing of group j in an autoclave tej duration of the plateau plus cooling phases in group j thj duration of the heating phase of group j tj duration of the heating phase of group j without overlapping tsj time at which group j starts being processed Problem is completed with inequalities: Inequality (1) means that one cart cannot be assigned to more than one group, notice that the assignment can be delayed if its maximum waiting time is not reached within a certain horizon. In (2) the minimum and maximum (Γ) number of carts per group are fixed, and (3) forces each group to be processed in one and only one autoclave.
Eqn (4) stablish that each group, if actually formed, can only be processed according to one type of cans. Eqns (5) and (6) select the heating and plateau plus cooling times of group j whereas (7) selects the type of can that will be attributed to the processing of group j, taking into account that the can types h are ordered by rigor, meaning that if h < h', all carts of type h can be sterilized with the profile specific for the type h', but not the other way round. In the paper, M always refers to large positive numbers known as "big M".
,ℎ ≥ ,ℎ ⋅ , ∀ ∈ , ∀ ∈ , ∀ℎ ∈ ,ℎ ≤ � � ,ℎ ⋅ , � ∈ℐ ∀ ∈ , ∀ℎ ∈ Eqn (8) limits the number of different types of cans that can be included in a group. Eqns (9) and (10) state that, if a cart i contains cans of type h and belongs to group j, then the group contains carts with type h cans. Otherwise, it does not contain any can of that type. Additionally, Eqns (11) and (12) below, limit the types of cans that can be processed together in a group to those in which the required processing times rh + eh do not differ more than a certain maximum time δ.
The following equations establish that a group j cannot start being processed before the arrival of all carts of the group and not later that these arrival times plus the maximum waiting time τ: Eqn (15) forces the carts that have arrived or will arrive before a certain time horizon η to be assigned to a group.
Notice that tai and tsj are relative to current time t.
Finally, the processing of the groups in the autoclaves has to be ordered in time. Here, instead of a typical immediate or general precedence approach (Méndez et al. 2006), the following is proposed: The set J of groups is assumed to be ordered, and the order is extended to the starting instant of the slots, therefore if a slot precedes another in the set, its starting time will be earlier, (16). Eqn. (17) forces group j' to be processed after group j has finished being processed, provided that both have been assigned to the same autoclave. In addition, note that for those autoclaves already in operation at every execution of the scheduling problem, or those arriving within the current sampling time, the corresponding variables are fixed to its current values.

Interaction with the autoclaves operation
It may happen that due to the high demand of steam associated to this phase, the heating phase of some autoclaves coincide in time, causing a drop in steam pressure. Consequently, the control system cannot follow the desired temperature profile, what calls for enlarging the heating time of all of them. Fig.6 illustrates one such situation. From now on, we assume that the increment of time is proportional to the number of autoclaves that overlap.
In order to compute these increments, let us define a new binary variable Wj, j' such that Wj, j' =1 if the heating phase of groups j and j' with ord(j) < ord(j'), coincide in time, Where (18) establishes that if the heating stage of group j'' overlaps the one of group j, then it also overlaps the heating stage of group j' that is processed between both of them. Eqn (19) indicates that if heating stage of group j' overlaps the one of group j, then its starting time cannot be larger than the one of j plus its heating time. Eqn (20) computes the heating time of group j as the one without overlapping, tj, plus an increment ξ times the number of preceding or succeeding overlapping groups. Eqn (21) computes the processing time of a group j as the summation of the ones of the three stages.

Optimisation problem
Several aims can be chosen as targets for the operation of the process. In our case, the scheduling is formulated as an optimisation problem that minimizes makespan (CMAX): min , , , , , , , ℎ s.t. constraints (1) to (21) As Tih, rh, eh, tai, τ and ξ are known magnitudes, this results in a MILP problem solved with the usual algorithms.

CLOSED-LOOP IMPLEMENTATION
Due to the uncertainty associated to industrial operations, a closed-loop implementation of the scheduling is proposed, which means that the optimisation problem is executed at regular intervals, each time considering the actual situation of the process at current time. Analogous to MPC, the real-time execution of the scheduler applies a rolling horizon approach to compute the actions to perform at present time and recompute the scheduling the next sampling time incorporating the new information available.
Because of this closed-loop policy and the need of speed up the computations so to operate in real-time, rather than computing a solution for a whole week, the scheduling uses a short term horizon of several hours. This horizon is defined by the expected number of arrival carts that are going to be scheduled whereas the problem formulation is updated and executed every 15 minutes. Automated updating requires an integration within the MES system, which also shows allocation and control policies to the operators. The messages incorporate the batching, allocation of the carts and the sets of control parameters. If the operator does not accept these suggestions, the scheduler must reorganise the system. Hence, altogether, it can be considered as a man-in-the-loop closed loop system. For its operation, a main procedure has been defined that reads the database, compares the current status to the predicted one, readjust the inputs of the optimiser and then runs it again. Firstly, it computes the time that has passed since the last iteration. Secondly it captures the actions that took place during this period and makes a new prediction based on these past actions and MES data base content. Subsequently, the software removes the wrong predictions and suggestions that were not followed and modifies the constraints of the optimisation problem. Afterwards, it executes the optimisation again.
One important practical point regarding implementation appears in the commitment of carts to groups and autoclaves. The placement of carts is done manually, so, those that have already arrived at current time, or within the next sampling time, maintain their assignments in the next scheduling due to the practical difficulties of moving carts continuously.

INTEGRATION WITH THE CONTROL LAYER
The previous formulation uses parameters rh, eh as fixed amounts that guarantee the fulfilment of the lethality constraints in the autoclaves. Further improvements can be obtained integrating the operation of the scheduling and control layers. Using a validated model of the sterilisation operation (Vilas Fernández and Alonso 2018), Pareto fronts relating plateau temperature and processing time for given availability of steam pressure, such as the one in Fig.7 (left) can be obtained for each type of can. They establish a region of safe operation that balances processing time and quality. Hence, for a certain lethality level, one can consider the coupling temperature/time rather than the fix values.
This degree of freedom can be included in the scheduling formulation incorporating the allowed range of operation and deciding additionally about the best plateau temperature of the autoclaves to improve the scheduling targets according to the current production aims. In this way, the scheduling will set the best operating point of the autoclaves recipe and the autoclave operation is taken into account in the scheduling problem, integrating the operation of both. Fig. 7 (left) Shape of the relation between processing time and plateau temperature that guarantees fulfilment of the lethality constraints in an autoclave for all points above it. (right) intersection (green) of Pareto fronts of two products To include this new degree of freedom in the model, a new variable that indicates the desired temperature set point for every group is added, ∈J . In addition, the Pareto front is approximated by straight lines (An,hTª+ Bn,h) in order to preserve the linearity of the problem. An upper straight line (A0Tª+ B0) is added to exclude points far away of the Pareto front and establish a sensible operating region, as in Fig.7 (left). Hence, the parameter eh, that determines the length of the plateau and cooling stages required for every can type, are now deprecated and replaced by the two new series of parameters: slopes An,h, and ordinates Bn,h, n corresponding to the line number.
Eqns (6), (11), (12) are then replaced by new constraints (24) and (25) that establish that the chosen plateau temperature for a group of carts j has to be in the region enclosed by the straight lines corresponding to all types of cans included in that group. One example can be seen in Fig.7 (right): ≤ 0,ℎ ⋅ + 0,ℎ + �1 − ,ℎ � ∀ ∈ , ∀ℎ ∈ (25) 6. RESULTS Fig.8, depicts the Gantt diagram of one off-line example where the schedule of two hundred carts with five different recipes is shown. Sixteen autoclaves (vertical axis) were available, and fifteen groups of carts have to be sterilized according to its respective arrival times. The sterilisation processes are represented composed of two parts: the heating phase (red) and the plateau and cooling ones. The different colours represent the different types of products; therefore the length of the second phase is equal for all the procedures with the same colour. Meanwhile, the heating phase depends on the coincidence with other heating phases.
The optimizer has found a solution minimising the makespan, using only thirteen devices, in less than one minute. The MILP problem has been solved in a laptop computer, with a i7-4510U processor, and coded in GAMS 25.1.1, using Cplex 12.8.0.0 as MILP solver. Next, Fig.9 illustrates one example of closed-loop operation showing three successive schedules, obtained every 15 minutes corresponding to a plant with 16 autoclaves (vertical axis) working in parallel with carts containing cans of 17 different recipes, arriving randomly from seven sealing lines. The future horizon accommodates up to 200 carts and the horizon η was set in two hours. Maximum waiting time from the arrival of every cart, τ, is one hundred minutes.
The scheduling formulation has been coded in Julia/JuMP and the MILP problem has been solved in a computer, with an AMD Quad Core R5-2500U processor, using Gurobi 8.1. The optimizer finds solutions minimising the makespan, in less than one minute. The size of the problem has around 21000 constraints and 20 000 variables, including 4000 binary variables. Fig.9 Three consecutive Gantt charts obtained every 15 minutes. Vertical red line represents current time.
In Fig.9, the coloured bars are different groups of up to nine carts assigned in future or current time to the autoclaves. Grey bars represent autoclaves already in operation. The operation codes of the groups appear on the upper right corner of every graph. Notice that several autoclaves were not being used. This is due to the fact that carts arriving from some sealing lines are not allowed to be processed in very distant autoclaves, so that only nine autoclaves were operational in practice in the example. These additional constraints are incorporated in the software but they do not appear in the paper due to lack of space. The graphs show how the scheduling was evolving, fixing current assignments and incorporating new ones according to its arrivals.

CONCLUSIONS
The paper shows that process scheduling can be used on-line as a useful tool for the real-time operation of combined continuous-batch plants. It represents a step forward in the automation of upper levels of the control hierarchy toward the implementation of the ideas of Industry4.0.
Regarding this point, there are some elements that are worth mentioning. The first one is the importance of integrated information from different operational levels, which must be available online: production planning is required to supply predictions of carts arrivals and its properties from each sealing line complemented with the on-line information from MES system about the plant state. Secondly, we have seen that it is possible to integrate the operation of the control layer into the scheduling, gaining an additional degree of freedom that makes easier and improve the scheduling, while maintaining the independence of execution of the control layer, which facilitates acceptance by plant operators. This refers to the balance between duration of batches and operating temperature of the autoclaves which instead of applying a fix recipe use the operating point computed by the scheduling within the feasible region of the corresponding group. Another key point is the importance of keeping the linearity when formulating the optimisation problem, as this allows for shorter and more reliable executions. In our experience, human-in-the-loop presence cannot be avoided when dealing with upper decision layers, but let us mention that industrial implementation of this type of systems requires to include a lot of small details and automated procedures in the codes, so that adaptation to the changing operational conditions and production aims can be done with minimum human intervention.