Interpretation: The resources mentioned in this paper refer to the production conditions required to complete a production operation (or task, production task), such as machines, raw materials, etc., called generalized resources.
The following four types of production plans are common:
The following four production plans are analyzed one by one, the analysis of this paper, focusing on the optimization of the implementation of the plan, rather than the guarantee of hard rules. For example, through the readiness of an operation to determine the readiness requirements of a resource, such as MRP, these hard constraints can be used by the rule engine (such as drools) to ensure that the planned schedule meets the various business rules during the build planning process, without having to pass through the planning engine (for example, Optaplanner). Further optimization is made on the basis of satisfying rigid business rules.Single process, single resource type
For a single process, a single kind of resource situation, is the simplest of a scheduling scenario. That is, the production process of a product requires only the same resource, and the entire production process of the product is completed once processed. In this case, since it is a single process, then there is no process of the constraints of the successive resources, a single kind of resources, that is, there is no resource selection optimization. In production practice, such production plans are often used to plan for a more important process in a product process route, in many operations. The main requirement for optimization is the allocation of resources, such as the need for load balancing between machines. When we implement this kind of plan, we need to set the machine balance constraints, so that the engine in the process of assigning tasks, as far as possible to achieve the same type of machine load balance. For example, in the printing production, in the final manual process in the production planning, according to the manpower arrangement of each production line, according to the proportion of the quota task. These conditions can be used with the "single operation, single category" Resource plan.Single process, multi-resource type
Single process, a variety of resources, only one process of production scheduling, only the resources available for this process is diverse, and the various resources can be interchangeable. This type of program is primarily designed to achieve optimal allocation of resources. That is, according to certain principles to the various processes of resource arrangements. For example, various resource use costs vary, and in planning, in order to reduce production costs, the use of low-cost resources should be made to ensure that other higher-priority constraints or rigid constraints are in place. As a practical example, in the printing industry, in the printing process, some of the printed sheet can be printed by CMYK four-color, but also by the deployment of special colors, through spot-color printing, but the former cost compared to the latter, the two types of printing means two resources. In the printing process customized production planning, will be preferred to use CMYK printing, but this is not absolute, for example, if the CMYK resources have exceeded the load, do not use spot color printing can not achieve on-time delivery, or will abandon the cost of this constraint, to accommodate the delivery of this higher priority constraints.Multi-process, single resource type
It is relatively rare to have multiple operations and a single kind of resource. That is, the plan requires the resources and time for all the operations in the entire product operations route, where resources only need to be one option. It can be understood that the requirement for resource allocation is lower, and the plan focuses on the optimization of the pre-and post-process constraints or other factors in the process itself. That is, on the resource allocation, as in the first case: "Single resource, single task", based on some principles of resource utilization for resource allocation. In order to arrange the processing time of the process, it is necessary to realize the sequence relation of the process in time according to the process route of the product, which is limited by the allocation of resources. For example: If the printing of the second process (some enterprises called post-press processing), there are oil, over-glue, UV three processes, if there is a machine can also achieve these three processes, then meet the "multiple processes, a single resource category" scenario. At this time the resource allocation of the operation, there will be a corresponding resource use constraints. But the more important constraint is: a product of multiple processes in the order of processing, this order must be based on the production process route set resources to execute, otherwise it violates the rigid constraints. Therefore, in combination with the above-mentioned resource allocation and process resources requirements, we need to face two contradictory problems: 1. For the same product need to ensure that its execution of the operation and the operation line set on the same, 2. For the productivity of a resource (for example, a machine), how can you achieve more production connections to the same operation, because even with the same resource, usually on that resource, the switch between production tasks for different operations can incur costs, possibly time costs, and possibly specific monetary costs. Therefore, the difficulty is how to balance the above two problems, so as to maximize the utilization of resources and process resources are not violated.Multi-process, multi-resource type
Many processes, multi-resource types and production planning, is the most common, but also the most complex planning, is the focus of this discussion. As with the previous problem, multiple operations are scheduled for the entire product's process route. And the resources used to produce each process are of different kinds. Therefore, we face two relatively fragmented and interactive contradictions: 1. For a product, its multiple processes are based on the operation of the production line formation of resources; 2. A variety of resources means that the resources used by each production process may be different and possibly the same. Because of the constraints of the sequence of operations, when the engine has completed the allocation of resources to an operation, further production time allocation, but because the same product sequence of operations, it is necessary to follow the sequence of the operation line, which means that the plan, in addition to allocating good resources, Also make sure that this resource is not occupied by the production tasks of other products for a specified period of time. Then when the production of multiple products at the same time, the operation of each product line formation sequence and resource allocation scheme, it is easy to form a stalemate state, even between the multiple resources will appear deadlock state.
Below, we plan the "multi-process, multi-resource category" scenario with a number of different types of machines, dealing with cases of multiple operations on a process route, and analyze the skills, technical difficulties, and possible scenarios that need to be implemented, and how to respond.Multi-process and multi-machine scenarios describe the concepts used in the planning process
To facilitate the description of the various scenarios in the planning process, the following concepts are defined first:
task or production task : A production process of a product called a task, such as printing after processing: Over the plastic, bronzing, silk screen printing, the product after processing there are three tasks, respectively, is the glue task, bronzing task and screen printing task.
Operation Route task chain : A production job that corresponds to a different operation in a product, whose order is determined by its operation route, and the sequence of all production jobs for a product, that is, the task sequence, called the Operation Route task chain.
Machine Task Chain : When multiple tasks are assigned to a single machine, only one product can be processed at a time, that is, only one task can be performed at the same time, the task sequence formed on one machine is called the Machine task link.
predecessor, post task : Multiple tasks on the same product, forming a production task order (that is, the Operation Route task chain) in the order of operations according to the rules of the operation route. In a chain of two adjacent tasks, the former is referred to as the predecessor of the latter, and the latter is called a post-task of the former.
previous Task: Multiple operations tasks distributed on the same platform (i.e., the machine task chain), which are adjacent to each other in the task chain of the machine, which is called the former task of the latter, the former task of the former.The limitation of multi-process and multi-machine row thread
Here we come to the most practical, the manufacturing industry to face the most scenarios: multi-process, multi-machine scene to expand the discussion. The following two factors are the most troublesome to deal with this kind of production plan.
1. Multi-tasking and multi-machine matching
Because there is a variety of tasks and machines in the scheduling elements to be scheduled, and there may be a task that can be assigned to multiple machines, a machine can do a variety of tasks, so the task and machine matching problem will be more complex than the other three production plans. But often this is also one of the key points that embodies the value of Optaplanner.2. There is a mutual constraint between the process route task chain and the machine task chain.
The task sequence determined by the operation line of a product, and the task sequence assigned to the same platform, are constrained in the processing order. The processing order is reflected in the processing time successively. That is, the task sequence of a product, according to its process route, there are certain priorities. When a product is assigned to each machine for production operations, the time period for each task may not be tightly connected, since there is a chronological order on the production line that will cause multiple tasks on a single machine to be produced in sequence. Because when you are ready to start a task on the platform, the predecessor of the task may not be complete, so that the machine on which the task is located is ready (its previous task is completed and the machine is ready for the task), but because its predecessor operation is not completed, it cannot start because the Operation alignment constraint is violated once it starts. So that the other post-task behind it is postponed, and these tasks are delayed, and may cause their own back-up tasks to be postponed, resulting in the machine task chain and the operation Route task chain affect each other. We call this a " chain Reaction ", which solves this ripple effect and is the key to solving the schedule.
As a result of the chain reaction described above, it is possible to cause a ring-shaped impact situation. Because a normal production plan exists two main dimensions of time and space , where the spatial dimension of this article is the machine, which is represented as a task assigned to the designated machine. The time dimension is defined as the start and end time of the task (in fact the end time can be deduced from the start time), which is the time when the scheduled start of a task is determined. Then you need to have a logic that makes time deduction for the tasks of each allocated space (that is, the machine). Time derivation of the task we need to do this through the Optaplanner afterentitychanged event (this event appears only in chained Through time mode, and there will be a special article about Optaplanner's temporal distribution pattern, Where the chained Through time pattern is the focus), and the origin of the derivation (that is, from which task is pushed) we usually start with the task that is being handled by the current move (move is the smallest unit of work for Optaplanner), which we call the vibration source. through its process route task chain to the machine task chain, and then by the machine task chain back to the process route task chain, when this annular influence line, after a series of chain reaction, just return to the vibration source to deduce the time, then the equivalent to start the wheel and the previous round the same derivation route, will be deduced indefinitely, and the cycle of death is produced. We need to accurately identify whether this chain reaction will produce a dead loop, and when it does produce a dead loop, it is necessary to make the current move identifier illegal , before the start time deduction, through Optaplanner's move Selection Filter cancels the current move, thus avoiding a program overflow and causing the system to crash. Here is an example of the actual dead loop to illustrate the situation.
Below we first clear the multi-task multi-machine Production Plan Foundation constraint, then discusses the dead cycle the concrete generation passes.Schedule constraints
For example: Red Box task Task1, Task2, TASK3 represents a product of the operation of the 3 operations on the task line, that is to say that the three tasks formed the Operation Route task chain, they are distributed in Machine1, Machine2, Machine3 three machines. According to the order constraints of the Operation Route task chain, the production order is Task1---Task2---TASK3. While the blue background of the two tasks is another product of the process route task chain, according to the product's operation route, its production layman is Taska-TASKB, you can see the sequence of these two operations with the red box process Task2, TASK3 order is reversed. From the machine's machine2 task chain, we can see that there is a production order relationship: Task B and Task 2. Then, when Optaplanner through a move to produce a possible scenario, and the start time of each task in this scenario is deduced, it is possible to assemble the state in order to have a dead loop, because the process of a product needs to be executed in the order of the Operation Route task chain, and a machine platform production machine task chain in the task is also has a sequential relationship, that is, the timing of a machine can only produce a task at the same time, there is a machine itself production task is also a chain of orders. It can be seen that there is such a circular production task order: Task2, TASKB, Taska, Task3, Task2 ,
That is, when the start time of any task in Task1, Task2, Task3, Taska, TASKB is deduced, it will become the source of the vibration described in the above-mentioned dead loop, thus producing a dead loop.
Constraints in the production planning of multi-machine units with actual multi-process
In actual manufacturing, in addition to the three main constraints discussed above, there will be a very large number of enterprises own business scenarios related to the constraints, will more restrict the execution of production activities. This restriction needs to be correctly reflected in the production plan, otherwise the resulting plan cannot be executed. This article only lists the common factors that have an impact on the correctness of the build plan, and the individual factors that are relevant to the business of the various industries and businesses, which are not within the scope of this article, and are considered when you design your system. For example: the printing industry in the post-processing process, after the process of spraying gold, it is necessary to wait for a certain period of time, so that the powder after curing, to enter the next process, then that is the process and the next process there is a minimum time interval limit, otherwise it will produce quality accidents, and therefore is a hard constraint.Experience in the detection of task dead loops
Because of the complexity of the production plan, the complicated constraints between the process task chain and the machine task chain, it is necessary to judge the legitimacy of the possible scheme produced by Optaplanner, and to identify the possibility of the death cycle during the start time derivation of the task. It requires very rigorous logic analysis and correct model and algorithm design. Now share some of the problems that this farm has encountered in this kind of project.
At that time, I put the machine task chain, process route task chain design, and clear the model of the entity's responsibilities and relationships. It was found that the time derivation exists the possibility of a dead loop. Because I think that the Optaplanner will be planned out of the various tasks in the possible program of the relationship has been sufficient knowledge, according to the derivation process can occur in the case of dead cycle detection, the detection process is quite simple. Because when the time-space relationship of a task in a possible scenario is determined, all the tasks constitute a graph of the directed graph, then I check to see if there is a ring to the graph. I tried to use the queue structure to take a breadth-first traversal of the graph and to identify whether the ring existed. Also tried to pass the depth-first traversal by recursion (in fact, recursive use of data structure is the stack, know VC + + students should learn from the WINAPI32 programming function call mechanism, in fact, call path is a stack). No matter how you try, the test results are not perfect and comprehensive. Because there are more factors to consider in our project, there is a greater likelihood of unexpected surprises. Therefore, for some time I feel that it is not possible to solve this problem, the union gave up the idea of giving up. Fortunately, I met a good leader, my boss (we are called Superior boss) Jeffrey gave me a lot of opportunities and support, and occasionally with me to analyze, he also understand the complexity of the problem, and give understanding and encouragement. Finally, my solution is: to Optaplanner in the planning process of each possible scenario, the model of the abstraction and simplification, removing some factors that do not affect the death cycle judgment, it is normalized to a formal direction of the graph, and through a number of mature forward-loop detection algorithm to judge it. In fact, the main idea is: the former according to the complex business rules to achieve different logic branch detection method, upside down, will contain some business factors of the graph, the Yocheng mathematical algorithm can be processed by the canonical map, and then to detect it. At present, this function has been quite stable, and she will not occasionally appear unexpected situation. On the graph of the ring detection algorithm, there are many online, we find themselves or their own research can be made, it is not in this article to delve into.Filtering of the selection filter through the filter of the non-solution method
In fact, if we only study the multi-task multi-machine production task proposed in this paper, the most basic three constraints, the above-mentioned illegal scheme is only the task of the Dead Loop scheme. In real-world project development, an illegal definition of a scheme will be more, richer, and more complex. Once we detect a solution by various means is not legal. We can pass the selection Filter, before optaplanner to the Variablelistener object of the Afterentitychanged event processing method, move a move to discard. For the use of the selection filter, you can start with the Optaplanner Development manual, and I'll write selection filter-related articles to illustrate them.Summary
Since then, this article describes a tricky problem when designing APS scheduling engines based on Optaplanner. Include: the identification of the type of the plan, the task consists of the process chain and the machine chain, the matching between the task and the machine, the link between the process chain and the machine chain of the possibility and cycle identification and processing. Hope to help everyone.
I am also beginning to study the APS scheduling engine, are still in the ongoing exploration, there is not the right place, but also please mention a lot. to thank.
If you have any suggestions for this, you are welcome to add me penguins to explore, q:12977379 or v Letter:
In fact, the Optaplanner planning engine does not need to be too proficient in Java to use, because it is used to Java most basic know, but still need to have basic Java knowledge to do, I hope you find me in the discussion, if Java, Maven and other aspects still touch less, Please first of all to fill the knowledge, this ape for the moment only to discuss with you optaplanner, drools application, and Java-related knowledge, can not provide effective help, after all, this ape is only a novice java. Thank you first.