Constraint Programming for Flexible Flow Shop Scheduling Problem with Repeated Jobs and Repeated Operations

The manufacturing process relies heavily on production scheduling to guarantee effective production schedules, reduce costs and product shortages, and get away from delays, interruptions, and waste products. Scheduling issues have been effectively solved via constraint programming. In this paper, we consider a constraint programming formulation of the flexible flow shop scheduling problem with repeated jobs and operations repetitions. We also implemented seven fast heuristics and compared the results with the constraint programming solution. The results from using the CPLEX solver as a solution tool were satisfactory. Computational experiments demonstrate that using constraint programming can be significantly more advantageous than using heuristics.


INTRODUCTION
Due to Industry 4.0, also known as the fourth industrial revolution, which aspires to fully automate and digitize processes, particularly production processes, scheduling has become more crucial than ever in the industrial setting [1,2]. Technology advancements, including the Internet of Things, big data, electric vehicles, 3D printing, cloud computing, artificial intelligence, and cyber-physical systems, are included in Industry 4.0 [3].
For manufacturing companies aiming to advance their production facility, production scheduling has become a requirement. The distribution of the operations, processes, and resources needed to produce goods and services is referred to as production scheduling.
Due to the introduction of "Internet of Things" applications that present numerous opportunities for improving existing systems, this is currently becoming an even more significant application field for scheduling theory, to the point that the modern world is frequently referred to as the start of the fourth industrial revolution [1,4].
For expanding manufacturing enterprises to increase their output, production planning is crucial. In manufacturing, scheduling is used to inform a production facility when to manufacture something, with whom, and on what machinery in order to meet customer deadlines while also reducing production time and costs. In order to maximize productivity, make the most of the available resources, and cut expenses, production scheduling strives to do all three.
A situation where machines can communicate with one another in the most effective way possible, "free" from the error-prone interaction of human staff, is becoming more and more likely as facilities become more automated. This is already true in logistics, as seen by Amazon's autonomous shelf robots in their warehouses and automated packaging machines that are five times faster than people [5], as well as in transportation, where it is predicted that highways would be safer when free of human-driven cars [6]. Scheduling theory developments can now more than ever have a significant impact on the real-world economy [7,8].
In traditional scheduling issues, decisions about technology activities and transport duties are frequently made separately, or issues are only present with technological chores. The production schedule's quality suffers as a result of this simplification. Moreover, sometimes, situations in industrial production processes occur where setup time is much longer than processing time. Additionally, there are not many transport resources, which could lead to a stalemate in the system [9].
Some businesses use Gantt charts, data from their ERP system, and Excel spreadsheets to manage schedules manually. Companies may reach a point when it becomes extremely challenging to keep manually scheduling their factory using Excel spreadsheets and data entry due to constraints on staff and consumer demand.
The goal of the production scheduling is to arrange resources effectively and affordably to fulfil customer orders. Planning production improves the productivity of the factory.
Due to their numerous industrial applications, shop scheduling issues are one of the most studied optimization issues. Variants of the flow shop scheduling problem and the job shop scheduling problem have drawn much attention from production scheduling academics in recent years. The well-known flexible flow shop scheduling problem (FFSSP) serves as the foundation for the issue being discussed in this article.
Constraint programming (CP) is an effective method for addressing combinatorial production planning issues. The search space is narrowed using sophisticated deduction, and the search space is explored using a combination of variable-and value-selection heuristics. Utilizing a constraint programming method, the production FFSSP problem could be resolved.

BACKGROUND
The job shop scheduling problem (JSSP) is frequently regarded as one of the most challenging problems in combinatorial optimization [9][10][11][12]. The issue with the goal criteria, which is the completion time of all activities, has been indepth analyzed by numerous researchers due to its enormous practical significance, and numerous precise as well as approximative methods have been devised [9].
A selection of jobs and a set of machines are provided in the job shop problem. There is no recirculation and each job must be completed by a number of machines in a specific order. Each job consists of a set of operations (tasks) that must be completed by a machine designated for each operation (task) in a predetermined length of time, uninterrupted. Each task has a stated execution time, which often includes both the time required to set up the workstation for the task at hand and the time required to return it to its pre-task condition. It frequently also accounts for travel time to the created item place. The device is capable of carrying out up to one operation at any given time. The goal is to reduce the makespan (i.e., complete production ends as fast as possible). This issue involves creating a schedule using a predetermined priority rule (assigning related jobs to the appropriate machines within a specified time frame). The above-described issue is a classic combinatorial optimization issue and is a member of the problem class that is strongly NP-hard [9].
These days, just-in-time delivery poses particular difficulties for the supplier sector. With just-in-time delivery, the supplier is required to give the client the material when it is required. The present demand of the customer's production and assembly unit determines delivery schedules, e.g., the automotive industry [13].
A job shop problem is used by a manufacturer of automobile components to produce a wide range of parts. The setups for many manufacturing procedures are extensive. The manufacturer must rapidly determine whether it has the capacity necessary to take an order when a customer calls in.
In the paper [14] researchers studied the scheduling issue in job shop systems with transportation. Similar to a standard scheduling problem, it entails allocating a set of tasks (production and transportation tasks) to a set of resources (processing equipment, transportation vehicles) while minimizing the maximum completion time of a production order (makespan) and accounting for the related constraints -production and transportation constraints. Researchers adopted the Variable Neighborhood Search metaheuristic to reorganize various job scheduling in order to tackle transport and processing tasks. This metaheuristic used asynchronous local search techniques to discover the best resource task allocation while minimizing the makespan [14].
The study [9] provided a generalized jobshop problem that sets up machines under deadlock-free operation conditions while accounting for travel time between workstations. A multitude of autonomous guided vehicles are used in the automated transportation system. The optimization criterion was the average completion time of all jobs. This problem was solved using the developed computational application, in which the priority algorithms were used [9].
In the paper [15] researchers discussed a brand-new multimachine multiobjective task scheduling problem (P) that was modelled after the one Renault, the automaker, put up for the ROADEF 2005 Challenge. The latter issue's resource use was balanced by placing a major emphasis on minimizing the smoothing penalties. In (P), smoothing costs are also taken into consideration, but actual elements such as eligibility limits, non-identical parallel production lines/ machines (instead of a single line), machine and job-dependant setup times and costs, and overall makespan reduction are also introduced. Assigning a reasonable order of importance to the goals is a method to minimize the overall makespan, smoothing costs, and setup costs [15].
The majority of advanced economies heavily rely on technology, with technology-intensive industries predominating. The majority of automated and routine jobs are now carried out by robots because cost and productivity are two of the key factors influencing manufacturing competitiveness. Flexibility is another important factor, and it may be improved by using resources that can carry out a variety of jobs, allowing for the use of various resources for various tasks. Higher levels of automation and greater flexibility produce extremely complex industrial processes that call for the best possible decision-making, especially in scheduling decisions, which entail the long-term distribution of finite resources [16].
The author of the paper [2] introduced various types of flexibility and investigated how the flexibility type, the quantity of permitted flexibility, and the presence of machine-dependent processing times impacted the solution quality that can be attained by a state-of-the-art constraint solver within a constrained time since the classic problem formulation is more general than what is found in most modern industrial settings. The difficulty can be lessened, according to the results, by particular types of flexibility, higher flexibility factors, and the absence of machine-dependent processing delays [2].
Another group of researchers [17] demonstrated the value of using a decision-making tool in an Industry 4.0 context to enhance resource management and reap the rewards of real-time data. They also proposed a task allocation optimization method based on a flexible job-shop problem that can be solved in a few minutes to dynamically allocate real-time tasks to operators in a 4.0 context. Next, they outlined the advantages of using a dynamic allocation system for tasks and resources requiring multiple skills that are released periodically and arbitrarily [17].
The authors of the paper [16] put forth the MILP model for the flexible job shop problem with transportation that solved benchmark examples with optimally small and some mediumsized sizes. They provided a heuristic that outperforms contemporary heuristics and can quickly locate decent solutions [16].
In multiobjective scheduling issues, decreasing the makespan while taking setup expenses and timeframes into account is common [15]. The flexible multiobjective job shop problem is proposed and solved by the authors of the paper [18] by combining particle swarm and local search techniques. In contrast to a job shop problem, where a set of jobs must be scheduled on a set of various machines, and each job must follow a specific routing on the machines, a flexible job shop problem is an extension where each job can be processed by any machine of a set along various routes, taking eligibility restrictions into consideration [15].
Due in part to the wide range of production environments it can model, the flow shop scheduling problem (FSP) is a sequencing problem that has drawn a lot of interest from experts and researchers in recent years [7].
A number of machines placed in a series must process a set of jobs or products in an FSP. All jobs must be processed via each machine in the same order. There is a defined processing time which is needed for each job in the machine. The main objective of FSP is to choose a processing order for the jobs that will optimize one or more efficiency metrics [19].
The demanding order in which all operations must be completed on every task is known as flow shop scheduling, which is a particular kind of job shop scheduling. Production facilities and computer designs may both benefit from flow shop scheduling.
In the study [20], a two-machine flow shop problem with ineligible transportation lags in the production process was examined. Two different types of transportation were taken into consideration: one for moving partially completed jobs between machines and the other for delivering fully completed jobs to clients. Two heuristic algorithms are also created to effectively solve the issue -Johnson's rules order the tasks, and the First Only Empty algorithm decides how each transportation batch should be combined [20].
A set of parallel machines set up in a sequence of phases is related to an FFS scheduling problem. There are several identical machines running in parallel at each level. Each work can disregard one or more phases and does not need to be processed at every stage. A single job can only be processed by each machine at once.
A broad type of flow shop when two or more parallel machines are used for at least one step is known as a flexible flow shop (FFS), sometimes known as a multi-processor flow shop [12,21]. There are some tasks that must be completed in a sequence of steps in order to optimize the specified objective function. Although there have been numerous variations of this issue, they all share the following characteristics [22,23]: • There are certain jobs identified by that need processing time, such as a stage. • There are at least two stages to the procedure.
• In each stage, there are parallel machines.
• From stage 1 to stage 2, the jobs should be processed using the same production flow. Nevertheless, some jobs may skip several steps.
The papers [22,24] provided a thorough overview of the research on the hybrid flow shop scheduling problem. The latter summarized the literature on exact, heuristic, and metaheuristic problem-solving strategies. For each of the different versions of the problem, they took into account various assumptions, restrictions, and goal functions. The related works can be divided into two categories: the solution method and the hybrid flow-shop features and production constraints [25].
The hybrid flow shop scheduling problem with job family is examined in the research [26]. One or more parallel machines are present at each of the two or more production stages that make up a hybrid flow shop, which is an expanded version of the standard flow shop. The addition of parallel machines boosts flexibility and production. The authors proposed an approach that doesn't keep any machine idle during scheduling in a hybrid flow shop. Their study demonstrated how adding deliberate idle time to a non-delay schedule can cut setup time and makespan even more [26].
The hybrid flow shop scheduling problem with a rework is the subject of the paper [25]. With this issue, jobs are reviewed at the very end, and those that were improperly processed are sent back. The authors modelled a hybrid flow-shop with the re-entrant flow as a result of a work potentially visiting a stage more than once. Each work begins at stage 1 and ends at stage 0 in a normal hybrid flow shop scheduling problem, visiting each stage only once and being processed by one of the parallel machines at each level. In additional iterations of the problem, known as re-entrant hybrid flow shops, each job may go through the same step more than once. Many different businesses, such as the final inspection system in the manufacture of automobiles, may employ this type of shop. In order to address the issue of sequence-dependent setup times and unrelated parallel machines, the authors expanded a few heuristic methods based on a few fundamental dispatching rules and suggested a variable neighbourhood search [25].
Even in more conventional situations like metal machining, Industry 4.0 concepts allow for a new way of thinking about the allocation of human resources. While some manual operations still need to be carried out by operators, the milling of parts on Computer Numerical Control equipment is automated. The current strategy usually involves statically allocating operators to one or more computers. Thus, avoidable bottlenecks are created [17].
Finding the appropriate instruments requires management and the appropriate software for production planning and scheduling. To manage the flow and identify production schedule problems, efficient production planning software is required.
The complexity of the task (relationships between operations and additional constraints) and the size of the problem (the number of different orders and the number of available machines) are the main factors that determine how long an algorithm will take to process.
This issue might be resolved using the Integer Linear Programming (ILP) approach. By minimizing the objective function, ILP finds the best solution to issues that can be solved by formulating a set of inequalities as constraints.
Especially for complicated problems that are difficult to solve with integer linear equations, constraint programming is a contemporary paradigm for combinatorial optimization issues [11]. Constraint programming first appeared in the field of artificial intelligence, but it has created high-quality outcomes when used to address issues with production sequencing [12].
A problem instance that has been defined in this way can be given to an expert solver. The number of tasks heavily influences the number of variables, and the number of equations influences the number of restrictions brought on by the difficulty of the assignment.
Nowadays, a lot of scheduling problems have been successfully addressed by constraint-based techniques [4,10]. A constraint solver tool included in the IBM ILOG CPLEX Optimization Studio is called Constraint Programming Optimizer (CPO). ILOG was a well-known software business specializing in supply chain and optimization issues. The creation of a generic optimization suite, combining CPLEX to handle mixed integer linear programming (MILP) problems and CP Optimizer for CP problems, has received a lot of attention since ILOG, the maker of the wellknown CPLEX mathematical programming tools, was acquired by IBM in 2008 [4,28].
There are various possibilities available today for the manufacturing company to locate production planning software that has been created especially for contemporary manufacturers.
The authors of the paper [28] proposed a formulation for the order insertion problem using mixed integer linear programming, which avoided complicated Gantt chart manipulations while still ensuring feasibility. They put forth and thoroughly tested heuristics based on evolutionary algorithms, tabu search, simulated annealing, myopic search, and a relaxation of the shortest path [28].
Companies often use Manufacturing Execution System (MES) software. In this case, not only should scheduling be improved but also the entire production process as a whole. Data collected by effective MES software can show where inefficiencies are occurring. MES software provides visibility of inefficiencies such as machine utilization, waste of raw materials, downtime of machines, problems with the changes, and overall equipment effectiveness metrics.
Heuristics have largely been used by researchers to address the variants of scheduling problems. These heuristics may produce quick and efficient solutions, although they are frequently customized. Furthermore, because they merge the problem description and the solution method into one framework, the effectiveness of these techniques heavily depends on the correct implementation and careful tweaking of parameters. In contrast, the issue description and the solution approach are separated in the mathematical modelling approach [29]. Furthermore, practitioners have been able to create more intricate and sophisticated problems as computer hardware, and solvers have advanced [28].

PROBLEM DEFINITION AND FORMULATION
Our model is motivated by the electronic components production example. Many people view the production of electronics as a high-level manufacturing issue. An electronic manufacturer utilizing an original equipment manufacturer is the ideal illustration of a business that develops electronic items to sell or promote them. Effective interaction between the manufacturer and the consumer is necessary for electronic design. The manufacturer will frequently request some idea from the client or clients and then work on it. Figure 1 presents an investigated problem. A company manufactures a wide variety of components. There are 6 production stations (machines). There are 2 positions (1 and 6) which are not replaceable. There are 4 universal production stations, mutually replaceable at each station, all of them can be implemented assembly/production tasks assembly of each component that is produced.
There are tasks which could be repeated. Each task consists of a set of operations. The operations could be repeated, but they must be executed on the same machine. Some operations could be executed only on the first or the last machine. The rest operations could be executed on the medium replaceable machine. An operation is characterized by the execution time on the machine. The transportation time between machines is neglected.
The supplier needs to decide how to assign the components' production operations (operations) to (machines) so that the makespan is minimized.
Next, we present the CP model for the described problem. The following notation is used in the problem.

Indices and sets:
V -initial number of jobs; q -index for initial jobs, The number of operations in a job j considering operation repetitions is the same as in case with job q but the duration of the operation increases by operation repetition coefficient g s . Here index q must be appropriately converted to j because of jobs repetitions. (1)

Subject to:
A given operation l must start after the previous operation k is finished: A given job j cannot be processed simultaneously on two or more machines: A single job at a time can be produced on a machine i :

HEURISTICS
Heuristic techniques are usually applied to problem-solving that uses a practical approach that is not always optimal or reasonable but is nonetheless acceptable for achieving a quick, Fig. 1. Universal production station approximate, or immediate result. Heuristic methods are used to expedite the process of obtaining a workable solution in situations when it is impractical or unattainable to find an ideal one. Figure 2 explains some initial steps that must be executed, providing a heuristic rule as a parameter. A set of operations that must be assigned to machines must be created, duplicating a definite number of times the operations that must be repeated in each task. Next, the appropriate order to the operations according to seven heuristic rules is applied. After that, the standard sorting order of task ID, repeated task ID, and operation ID are applied despite the selected heuristic rule.
There are some beginning operations that must be executed only on the first machine. There are also some final operations that must be executed after all operations on the last machine only. Other operations may be executed on other (medium) machines. Figure 3 explains the steps of assigning operations to machines.
Operations to the first and the last machines are assigned in sequential order of operation. Assigning operations to medium machines is executed in the order set by appropriate heuristics H1-H7 which are explained in Figure 2. Generally, all operations of one task are assigned to one machine. The operations of the next task after sorting them are assigned to the next available machine. In the end, the start time and end time for each task after executing operations on machines are calculated. At this step, there is no check if the constraints on operations and machines are satisfied. Figure 4 explains the process of checking constraint satisfaction and correction of assignment operations on machines by shifting the operations. Check if operations clash exists (operations of a task must be executed sequentially after the previous operation is finished). If yes, calculate the time that must be added to the clashed operations and shift them to machines. Also, shift operations are executed later on the given machine. Next, calculate the total execution time on each machine. Finally, calculate the start and end time for each machine. Check if a machine clash exists (the machine must execute only one operation at a time). If yes, calculate the time that must be added to operations on a clashed machine. Next, calculate the total execution time on each machine. Finally, calculate the start and end time for each machine. Figure 5 presents the complete procedure of calculating makespan. In the beginning, initial operations are executed by applying the appropriate order of tasks and operations. Next, assigning operations to machines is performed. Lately, shifting operations on machines are iteratively executed while the constraints are not satisfied, and correction of assigning operations to machines is needed. Makespan is the sought value.  Proposed heuristics disadvantages: • Operation sorting is performed at the beginning before assigning them to machines, so later, the idle time on machines could appear. • The quality of results achieved is rather low.

EXPERIMENT
The purpose of the computational experiment was to evaluate the solution quality found by CPO in the CPLEX solver and to compare the results with some heuristics.   For the experiment, 20 instances were generated in which there were from 4 to 13 tasks, but from 20 to 81 tasks considering task repetitions (Table 1). In each task, there were from 4 to 12 operations, but from 9 to 43 operations considering operation repetitions ( Table  2). In this instance, there were from 61 to 313 operations considering operation repetitions (Table 3). Table 4 reports the number of machines by instance. So there were from 6 to 10 machines per instance. Table 5 reports the performance of heuristics per instance with the identification of which heuristics found the best solution among all heuristics, i.e. the solution with minimum makespan. Heuristics 1 was the best among all heuristics, which found the 9 solutions with minimum makespan from 20 instances. Heuristics 3-5 found only 1 best solution per instance. Despite this fact, other heuristics didn't find the same solution. So mentioned heuristics 3-5 as also important. For the 1st instance, two heuristics (heuristics 3 and 7) found the same solution, which was the best among all heuristics. For other instances, only one heuristic found the best solution among all. Therefore all heuristics are noteworthy.
The next experiments were performed with the use of CPO solver. It has been executed once for each instance. The results of scheduling are summarised in Table 6, which compares the performance of heuristics and CPLEX Constraint Programming Optimizer. For 10 instances, an optimal solution was identified by CPO. For the rest instances, the solution which was found was far enough from the optimal one from 0.30% up to 94.49% with an average value 75.84%, which is low enough and identifies that more efficient algorithms should be implemented.
Heuristics found the optimal solution only for one instance. On average, the heuristics solution was worse than CPO 19.37% up to 39.17%. But comparing the heuristics with the CPO optimal solutions, heuristics was worse than CPO, slightly less on average 17.68% up to 39.17%.
All heuristics found the solution in less than a second. The time limit for CPO was set to 30 seconds.

CONCLUSIONS
Production can be planned very precisely for a small business using only basic tools; therefore, the company needs the best options from a special system. A certain margin of error is acceptable for a large factory with several dozen manufacturing lines and orders numbering in the hundreds per day because the goal is to optimize a problem that is difficult for a human to solve. The accountability of such a system is crucial for both sorts of users since the plan must be established quickly enough to avoid discouraging the use of the software.
Problems involving mathematical optimization can be solved in numerous ways. Among the methods are local search, evolutionary algorithms, constraint programming, mixed integer programming, and greedy algorithms. One approach might be more effective than the other, based on the problem size, nature, and desired quality of the solution to the problem.
One of the most challenging but crucial aspects of manufacturing is production scheduling. In this research, we show how the practical production FFSSP can be implemented using the CP. The ideas discussed here are easily adaptable to a wider range of issues. We demonstrated that CP methods can be successfully applied to scheduling problems in the production planning sector. Based on the proposed CP model, the practitioners have been able to create more complex problems.
We also proposed seven heuristics which demonstrate generally worse results than the CP. But implemented heuristics could be a part of more complex planning and problem-solving metaheuristics in future research.
CP is a paradigm for resolving combinatorial issues which incorporates numerous methods from operations research, computer science, and artificial intelligence. Programmers can declare the possible constraints on the practical situations for a given set of choice variables in constraint programming. Contrary to the known programming languages, constraints indicate the characteristics of a solution to be found rather than an algorithm to be implemented. Programmers must also indicate a way to solve the restrictions in addition to the set of constraints. CP is a crucial tool for engineering and manufacturing since it has a significant effect on how productive a process is.