Cable distribution method and device based on genetic algorithm
By applying the cable distribution method based on genetic algorithms in the online cable manufacturing industry, the problems of inefficiency and high error rates caused by traditional manual operations are solved, and automated distribution is realized, which improves inventory utilization and resource management efficiency.
Patent Information
- Application Number
- CN202510611421.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2045-05-13
AI Technical Summary
The material management and order processing systems of the traditional cable manufacturing industry rely on manual operations, resulting in inefficiency and error proneness, making it difficult to meet the needs of modern cable manufacturing industry for efficient and preciseness.
A cable distribution method based on genetic algorithm is used to obtain user order information and inventory data, create initial gene populations, and use genetic algorithms to iterate populations until the end conditions are met, and the target gene population is obtained, thereby determining the optimal distribution plan.
It realizes automated material order billing, reduces the working pressure of sales managers, optimizes the distribution process of inventory cables, improves inventory utilization rate, and reduces resource waste.
Smart Images

Figure CN120124992A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of supply chain management and optimization, and particularly to a cable distribution method and device based on a genetic algorithm. Background Art
[0002] With the development of the industrialization and urbanization processes in modern society, the scale of the wire and cable industry has been growing steadily. This trend has not only promoted the innovation of related technologies but also put forward higher requirements for the material management and order processing in the wire and cable manufacturing industry.
[0003] In some current wire and cable manufacturing industries, the lengths of most orders mainly concentrate below 1 kilometer. This characteristic often leads to material waste in the traditional manual control of material billing processes. Due to the large number and diverse demands of short-length orders, the traditional material management and distribution methods are difficult to accurately match the specific requirements of each order, making the excess materials unable to be effectively utilized, thus causing resource waste.
[0004] In addition, with the continuous and steady growth of the sales business in the wire and cable sector, the work pressure faced by sales management personnel during the peak business period is also increasing continuously. The increasing order volume not only requires sales management personnel to improve work efficiency but also requires higher work accuracy. However, the traditional material management and order processing systems for the wire and cable manufacturing industry usually rely on manual operations and traditional management methods. These methods often involve manually recording order requirements, material distribution, and inventory management, which are not only inefficient but also error-prone.
[0005] In this context, the traditional management methods have been difficult to meet the efficient and accurate requirements of the modern wire and cable manufacturing industry for material management and order processing. Therefore, it is urgent to introduce more advanced technologies and management strategies to optimize this process to improve the overall work efficiency and accuracy. Summary of the Invention
[0006] The embodiments of this application provide a cable distribution method and device based on a genetic algorithm, which can adapt to various specific requirements of the wire and cable manufacturing industry and improve the work efficiency and accuracy of sales management personnel.
[0007] In a first aspect, the embodiments of this application provide a cable distribution method based on a genetic algorithm, and the method includes: Obtain user order information and inventory data; the user order information includes the required lengths of various types of cables respectively, and the distribution strategy of the user order; the inventory data includes the inventory lengths under each type, and the number of pieces corresponding to each inventory length; For each type, create a preset number of gene sequences according to the distribution strategy, required length, and inventory data to form an initial gene population; The initial gene population is iterated until the termination condition is met using a genetic algorithm to obtain the target gene population; the population iteration includes calculating the fitness of each gene sequence in the gene population using a fitness function, and performing genetic operator operations on the gene sequences in the gene population according to the fitness to obtain a new gene population; the gene sequences with the top fitness in the target gene population are used to determine the cable allocation results corresponding to each model.
[0008] Thus, it is possible to automatically query the matching inventory and count the available quantity according to the required models, required lengths, and allocation strategies specified in the user order. On this basis, a genetic algorithm is further applied to find the optimal allocation plan.
[0009] In a second aspect, an embodiment of the present application provides a cable allocation device based on a genetic algorithm, the device including: An acquisition module, configured to acquire user order information and inventory data; the user order information includes the required lengths of various models of cables and the allocation strategy of the user order; the inventory data includes the lengths of each inventory under each model and the number of pieces corresponding to each inventory length; A processing module, configured to create a preset number of gene sequences for each model according to the allocation strategy, required length, and inventory data to form an initial gene population; The processing module is further configured to perform population iteration on the initial gene population using a genetic algorithm until the termination condition is met to obtain a target gene population; the population iteration includes calculating the fitness of each gene sequence in the gene population using a fitness function, and performing genetic operator operations on the gene sequences in the gene population according to the fitness to obtain a new gene population; the gene sequences with the top fitness in the target gene population are used to determine the cable allocation results corresponding to each model.
[0010] In a third aspect, an embodiment of the present application provides a computer storage medium, on which a computer program is stored. When the computer program is executed on a computer, the computer is made to execute the method described in the first aspect or any possible implementation manner of the first aspect.
[0011] In a fourth aspect, an embodiment of the present application provides a computer program product containing instructions. When the instructions are run on a computer, the computer is made to execute the method described in the first aspect or any possible implementation manner of the first aspect.
[0012] It can be understood that the beneficial effects of the above second aspect to the fourth aspect can refer to the relevant descriptions in the above first aspect, and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0014] Figure 1 It is a flowchart of a method for finding an optimal distribution plan using a genetic algorithm provided by an embodiment of the present application. Figure 2 It is a flowchart of a cable distribution method based on a genetic algorithm provided by an embodiment of the present application. Figure 3 It is another flowchart of a cable distribution method based on a genetic algorithm provided by an embodiment of the present application. Figure 4 It is a schematic diagram of a cable distribution device based on a genetic algorithm provided by an embodiment of the present application. Detailed implementation manners
[0015] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings.
[0016] In the description of the embodiments of the present application, any embodiment or design solution described as "exemplary", "for example", or "for illustration purposes" should not be understood as being more preferred or having more advantages than other embodiments or design solutions. Exactly, the use of words such as "exemplary", "for example", or "for illustration purposes" is intended to present relevant concepts in a specific manner.
[0017] In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the technical features indicated. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. The terms "include", "comprise", "have" and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways. "Multiple" can be one or more, where multiple means two or more.
[0018] In response to the problems mentioned in the background art, the embodiments of the present application propose a solution that can automatically query and match the inventory and count the available quantity according to the required model, required length, and distribution strategy specified in the user order. On this basis, a genetic algorithm is further applied to find the optimal distribution plan. This method can achieve automated material order generation, reduce the work pressure of sales management personnel. And, it can optimize the cable distribution process for specific requirements, improve the utilization rate of the inventory, and reduce waste of resources.
[0019] Exemplarily, Figure 1 FIG. shows a flowchart of a method for finding an optimal cargo allocation plan using a genetic algorithm according to an embodiment of the present application.
[0020] The genetic algorithm is a search heuristic algorithm that simulates natural selection and genetic mechanisms and is used in this solution to solve the cable cargo allocation optimization problem. As Figure 1 shown, the process of finding an optimal cargo allocation plan using a genetic algorithm includes the following steps: Step S101, establish a set of actual problem parameters.
[0021] It is necessary to transform the actual problem of cable cargo allocation into a set of parameters to obtain a set of actual problem parameters.
[0022] Step S102, convert to gene encoding.
[0023] Convert these parameters into the form of gene encoding so that the genetic algorithm can process them.
[0024] Step S103, establish an initial population T.
[0025] Initialize a population T, where each individual in the population represents a possible solution.
[0026] Step S104, calculate the fitness of individuals.
[0027] Evaluate the fitness of each individual in the population. The fitness function is defined according to the specific requirements of the actual problem and can represent the quality of the solution.
[0028] Step S105, simulate genetic operators.
[0029] Use genetic operators (including selection, crossover, and mutation) to simulate the natural selection process and generate a new population. The functions of these operators are as follows:
[0030] Selection operator: Select individuals with higher fitness for reproduction.
[0031] Crossover operator: Combine the genes of two individuals to produce new individuals.
[0032] Mutation operator: Randomly change the genes of some individuals to increase the diversity of the population.
[0033] Step S106, generate a new population T+1.
[0034] Step S107, check whether the population iteration requirements are met.
[0035] Check whether the new population meets the preset conditions (such as reaching the maximum number of iterations, finding a satisfactory solution, etc.).
[0036] If the requirements are met, proceed to the next step, entering step S108.
[0037] If the requirement is not met, the new population is used as the current population, and the process returns to step S104 to continue iterating.
[0038] Step S108, performing gene decoding.
[0039] Decode the genes of the top ranked individuals in the final population and convert them back into solutions to practical problems.
[0040] Step S109, obtaining an optimal solution.
[0041] The optimal individual is taken as the optimal solution to the practical problem.
[0042] thus, Figure 1 The whole process of genetic algorithm from practical problem definition to solution is demonstrated, including gradually approaching the optimal solution of the problem through iterative optimization.
[0043] For example, Figure 2 A flow chart of a cable distribution method based on a genetic algorithm provided in an embodiment of the present application is shown.
[0044] like Figure 2 As shown, the cable distribution method is mainly implemented by the following modules: distribution management module 20, order module 21, inventory management module 22, data management module 23, algorithm module 24, and security encryption module 25. Each module interacts with each other to jointly complete the cable distribution process based on the genetic algorithm.
[0045] Step S201, sending user order information.
[0046] Exemplarily, the distribution management module 20 provides an order input interface, through which the sales management personnel can fill in the user order information. When filling in, it is necessary to clearly specify the required cable model, required length, and desired distribution strategy. This information will directly affect the selection of the subsequent genetic algorithm and the application of the fitness function. After obtaining the user order information, the distribution management module 20 sends the user order information to the order module 21.
[0047] In one implementation, the distribution management module 20 may be a Microsoft Dynamics 365 system, which is an integrated business application platform that integrates functions such as customer relationship management and enterprise resource planning, and can provide a comprehensive solution for the entire cable sales business. For example, an enterprise manages business processes in multiple aspects such as sales, customer service, marketing, finance, supply chain, and human resources.
[0048] Step S202, requesting to search for a corresponding cable.
[0049] Exemplarily, the order module 21 groups the required cable models and required lengths, fills the requirements of the same model into an order request message respectively, and processes them sequentially. For each order request message, it is sent to the inventory management module 22 to request to find the corresponding cable.
[0050] Step S203: Return the cable search result.
[0051] Exemplarily, the inventory management module 22 provides a Web application to receive order request information. After receiving this information, the inventory management module 22 first searches for the inventory models that match the order request in the system's available inventory table, statistically classifies all eligible inventory items according to their lengths, determines the "available quantity" of cables of each length specification, that is, the quantity of cables of a specific length specification in the existing inventory, and returns the result of the statistical classification as the cable search result to the order module 21.
[0052] In addition, after receiving the cable distribution result through step S212, the inventory management module 22 is also used to update the status (such as the cable inventory length) and quantity of the cable inventory.
[0053] Step S204: Request the public key.
[0054] Step S205: Return the public key.
[0055] Step S206: Send the ciphertext data.
[0056] Exemplarily, after receiving the cable search result, the order module 21 organizes the above user order information and cable search result into a structured data format.
[0057] Subsequently, for this structured data, the order module 21 requests the public key from the security encryption module 25 in real time and receives the public key returned by the security encryption module 25.
[0058] Next, the order module 21 encrypts the structured data using this public key, and after obtaining the ciphertext data, sends it to the algorithm module 24.
[0059] In one implementation, during the distribution calculation process, the order module 21 performs homomorphic encryption processing on sensitive user order data and inventory data, and then sends it to the algorithm module 24. This special encryption method allows the algorithm module 24 to directly perform calculations on the encrypted data without decrypting first, thereby ensuring the security and privacy of the data even in a third-party computing environment. Considering that homomorphic encryption may increase the data volume, the order module 21 can implement an efficient compression algorithm to reduce the volume of the encrypted data, thereby optimizing the transmission efficiency.
[0060] During this process, the security encryption module 25 is used to ensure the security of data during transmission, storage, and calculation. By encrypting the data before transmission and processing, the data remains encrypted during transmission and when optimized calculations are performed by the algorithm module 24, thus preventing the leakage of sensitive information. Even during the calculation process, the data exists in ciphertext form, ensuring the privacy and security of the data. At the same time, this module is also responsible for decrypting the result after the calculation is completed in order to obtain an available plaintext output, which can protect data security without affecting the use of the final result.
[0061] Specifically, after receiving the public key request information, the security encryption module 25 uses a random number generation algorithm to generate a public key and private key pair for homomorphic encryption in real time, and returns the public key to the order module 21 for encrypting user order data and inventory data.
[0062] In addition, the security encryption module 25 also receives the private key request sent by the goods allocation management module 20 through the following step S209, and returns the private key corresponding to the public key carried in the user order message processed this time to the goods allocation management module 20 for decrypting the calculation result. To enhance security, the security encryption line key is updated and actively sent to relevant modules.
[0063] Optionally, the security encryption module 25 can also implement a fine-grained access control policy to ensure that users with different roles can only access resources within their permissions. For example, ordinary users can only submit tasks, while administrators can monitor the running status of the entire system and adjust the configuration of the calculation model.
[0064] Step S207, return the calculation result.
[0065] Exemplarily, the algorithm module 24 is used to calculate encrypted data. It is the core functional module of the system, and obtains an optimized cutting plan through data modeling and calculation. This module uses a genetic algorithm for optimized calculation, including three basic operators: a selection operator, a crossover operator, and a mutation operator, to find a global or near-optimal solution. The genetic algorithm simulates natural selection and genetic mechanisms, continuously iterates to generate new populations, and selects individuals for reproduction and mutation according to fitness, thereby gradually approaching the optimal solution.
[0066] Specifically, after receiving the encrypted data, the algorithm module 24 first creates an initial gene population for possible solutions (i.e., cutting plans on each available inventory) according to the preset population size. This process involves generating a certain number of initial solution sets or "gene populations" for each possible solution length.
[0067] Secondly, execute the genetic algorithm, and this process includes: (1)Fitness evaluation: Calculate the fitness value of each individual using the defined fitness function to measure the quality of its solution.
[0068] (2)Selection mechanism: Adopt the tournament selection method to select the individual with the highest fitness score as the outstanding representative in the next generation population.
[0069] (3)Crossover operation: Perform the crossover operation on the two selected individuals, exchange genetic information between the selected positions, and generate new offspring individuals.
[0070] (4)Mutation operation: To increase the population diversity, randomly select a few gene segments for modification or recombination to create a new combination of features different from the parent generation.
[0071] After a preset number of iterations, when the predetermined condition is reached, the algorithm stops and returns several individuals ranked among the top in the current population. These several individuals are then decoded and transformed into structured data as the calculation result, which is sent to algorithm module 24 to provide a specific solution regarding the cutting situation on each stock.
[0072] Step S208, forward the calculation result.
[0073] Exemplarily, the calculation result is forwarded by algorithm module 24 to the goods allocation management module 20.
[0074] Step S209, request the private key.
[0075] Step S210, return the private key.
[0076] Exemplarily, after receiving the calculation result, the goods allocation management module 20 sends a request to the security encryption module 25 for the private key corresponding to the public key carried in the user order message processed this time, and receives the private key returned by the security encryption module 25.
[0077] Subsequently, the goods allocation management module 20 decrypts the calculation result this time using the private key to obtain the decrypted calculation result, which is the optimal solution for cable allocation of the user order.
[0078] Next, to meet the special requirements put forward by the sales management department, such as avoiding the influence of specific remaining material lengths on sales or supporting the allocation with substitute materials, etc., the goods allocation management module 20 will perform additional optimization and processing on the optimal solution to obtain the final cable allocation result of the user order to better serve the actual needs of the sales business.
[0079] Step S211, send the decrypted calculation result and the cable allocation result.
[0080] Step S212, forward the cable allocation result.
[0081] Step S213, forward the user order information, the decrypted calculation result, and the cable distribution result.
[0082] Exemplarily, the order module 21 sends the cable distribution result sent by the distribution management module 20 to the inventory management module 22 for inventory update. And forward the user order information, the decrypted calculation result, and the cable distribution result to the data management module 23 for recording the user order, the calculation result, and the cable distribution result, for later result review, problem troubleshooting, genetic algorithm optimization, etc.
[0083] Thus, it is possible to automatically search for matching inventory and count the available quantity according to the required models, required lengths, and distribution strategies specified in the user order, and then calculate the distribution plan with the highest or nearly highest material utilization rate, so as to achieve efficient processing and optimized distribution of sales orders.
[0084] Based on the above content, another cable distribution method diagram proposed in this application based on the genetic algorithm is introduced in detail.
[0085] Exemplarily, Figure 3 Fig. shows a flowchart of another cable distribution method based on the genetic algorithm provided by an embodiment of this application. This method can be implemented by any computing unit, server, device, device cluster, etc. with computing and processing capabilities, and mainly includes the following execution steps:
[0086] Step S301, obtain user order information and inventory data. The user order information includes the required lengths of various types of cables respectively, and the distribution strategy of the user order. The inventory data includes the inventory lengths under each model, and the number of pieces corresponding to each inventory length.
[0087] In one embodiment, first, the user can place orders for different types of cables in a user order through the distribution management module 20. Secondly, the sales management personnel can select the distribution strategy corresponding to the user order through the distribution management module 20. For example, the minimum margin strategy, which aims to reduce waste generated by cutting cables, or the safety stock strategy, which aims to maintain a certain amount of safety stock to cope with demand fluctuations and supply chain uncertainties, etc. These strategies can be used alone or in combination to adapt to cost, time, resource utilization rate, or other business requirements. By implementing effective cable distribution strategies, enterprises can improve customer satisfaction, reduce costs, and improve overall operational efficiency.
[0088] Subsequently, the distribution management module 20 groups the requirements of various types of cables in the user order by model to obtain the required lengths of multiple cables under each model, and also includes the distribution strategy of the user order.
[0089] Next, usingFigure 1 The inventory management module 22 shown searches according to the cable requirements of multiple models, obtaining multiple different inventory lengths for each model and the corresponding quantities for each inventory length.
[0090] Furthermore, use Figure 1 the order module shown to obtain the information of the user order from the goods allocation management module 20 and the inventory data from the inventory management module 22.
[0091] In the following content, the requirements of the same model will be processed in sequence using Figure 1 the genetic algorithm shown to obtain the cable allocation result corresponding to each model.
[0092] Step S302, for each model, create a preset number of gene sequences according to the allocation strategy, required length, and classification data to form an initial gene population.
[0093] Exemplarily, when applying the genetic algorithm to the cable allocation scenario, each allocation strategy has a corresponding price strategy. The price strategy is used to determine the cost - effectiveness of different allocation schemes. The price strategy includes a pricing model that can set prices according to factors such as the model, length, and material of the cable. This model can be linear or non - linear, depending on the cost structure and market conditions.
[0094] In the genetic algorithm, the price strategy is implemented through a price dictionary. The price dictionary, as a key data structure, contains the pricing information of the cables of this model. During the iterative process of the algorithm, this pricing information is used to estimate the costs of different allocation schemes, thereby guiding the algorithm to find the allocation scheme with the lowest cost. In this way, the price strategy directly affects the optimization direction of the genetic algorithm and the final allocation decision.
[0095] After obtaining the information of the user order and the inventory data, first, according to the price strategy corresponding to the allocation strategy and multiple different inventory lengths, the prices corresponding to each inventory length can be obtained to form a price dictionary.
[0096] In one example, for a specific model of cable, its price strategy adopts a linear pricing model. This model sets the price through a linear ratio, and this ratio reflects the relationship between the cable length and the price. In the inventory management of cables, there may be multiple different lengths of this model of cable. To reflect the importance of the length factor in the price strategy, the linear ratio can be used to adjust the prices of these cables with different lengths.
[0097] Specifically, this process may include: adjusting the price by scaling it up or down proportionally using a linear ratio according to the actual length of the cable. If the cable is long, the price will increase proportionally; if it is short, the price will decrease proportionally. Through this method, the linear pricing model can ensure fair and reasonable prices for cables of different lengths.
[0098] For example, if the distribution strategy corresponding to the user order is the minimum margin strategy, and the linear ratio included in its corresponding price strategy is 1:10, then the price dictionary PRICE can be a simple set of key-value pairs, where the key is the different cable lengths and the value is the corresponding price. The following is a simple example of a price dictionary:
[0099] PRICE = {8: 0.8, 19: 1.9, 20: 2, 22: 2.2, 49: 4.9, 89: 8.9, 180: 18, 580: 58, 780: 78, 940: 94, 1940: 194, 2330: 233, 2580: 258, 3290: 329}
[0100] As shown in the above price dictionary, each length of in-stock cable has its specific price. For example, for a cable with a length of 8, the price after scaling down using the linear ratio 1:10 is 0.8.
[0101] Secondly, structure the above price dictionary, required length, and inventory data to obtain a problem data set as the input parameter of the genetic algorithm model. The problem data set includes a required length data set, an in-stock length data set, a price data set composed of value pairs of each in-stock length and its corresponding price, and a quantity data set composed of value pairs of each in-stock length and its corresponding quantity.
[0102] Continuing with the above example, establish a problem data set in the form of an array data structure.
[0103] For example, establish a length data set: PIECE = [70, 15, 214, 88, 95, 111, 200, 34, 39, 64, 30, 180, 79, 133, 254, 28, 37, 489], The length data set includes all the required cable lengths of this model.
[0104] Establish an in-stock length data set: STOCK = (8, 19, 20, 22, 49, 89, 180, 180, 580, 780, 940, 1940, 2330, 2580, 3290), The inventory length dataset includes the lengths of all inventory cables that meet the model requirements.
[0105] Directly use the price dictionary PRICE in the above example as the price dataset.
[0106] Establish the quantity dataset: QUANTITY = {8: 1, 19: 1, 20: 1, 22: 1, 49: 1, 89: 1, 180: 2, 580: 1, 780: 1, 940: 1, 1940: 1, 2330: 1, 2580: 1, 3290: 1}, The quantity dataset includes the "available quantity" of inventory cables of each length in the inventory.
[0107] Next, use the greedy algorithm to perform an initial cable allocation for a preset number of rounds (such as T rounds) based on the problem dataset, obtaining T gene sequences, which constitute the initial gene population T. Each gene sequence includes multiple vectors, corresponding to the results of an initial cable allocation. Each vector is a set of at least one required length in the required length dataset, and the set represents that at least one required length is allocated based on one inventory cable. In the greedy algorithm, in each step of selection, the best or optimal (i.e., most favorable) choice is made in the current state, hoping to lead to a globally best or optimal result, that is, the local optimal solution can determine the global optimal solution. The greedy algorithm involves a state space and a selection strategy. The state space is the set that describes all possible states of the problem, and the selection strategy determines the greedy selection criterion for each step.
[0108] Exemplarily, for each round of initial cable allocation, use the problem dataset of this round as the state space of the greedy algorithm, and set the benefit function as the selection strategy of the greedy algorithm. The benefit function is set based on the allocation strategy and needs to meet the costs, time, resource utilization rate, or other business requirements adapted to the allocation strategy. Based on this, use the benefit function of the greedy algorithm to evaluate the problem dataset of this round, determine the multiple vectors of the gene sequence corresponding to this round, as the results of each round of initial cable allocation. Randomly adjust the order of multiple required lengths in the required length dataset to obtain the problem dataset of the next round for the initial cable allocation of the next round.
[0109] Among them, when using the benefit function of the greedy algorithm to evaluate the problem dataset of this round, perform multiple evaluation iterations on the problem dataset of this round until multiple required lengths in the required length dataset are all allocated.
[0110] For each evaluation iteration, for the unfulfilled demand lengths in the demand length dataset, traverse the inventory length dataset based on the quantity dataset, and use the benefit function to select the first optimal inventory length corresponding to the maximum benefit from the inventory length dataset. At the same time, generate the first vector of the gene sequence for the current round. The quantity corresponding to the first optimal inventory length is not zero at present. And perform a decrement operation on the quantity corresponding to the first optimal inventory length in the quantity dataset; and mark the demand lengths included in the first vector as fulfilled in the demand length dataset for the next evaluation iteration until all demand lengths in the demand length dataset are fulfilled.
[0111] Assume that the allocation strategy is the least surplus strategy. The benefit E of the first vector can be calculated using the following benefit function: E = (∑Length i ) ÷ Price 1 (1) where Length i is the i-th demand length included in the first vector, and Price 1 is the price corresponding to the first optimal inventory length. Select the optimal inventory length through the benefit value E. The higher the benefit value E, the more demand lengths can be loaded per unit price, that is, more demand lengths can be allocated with one inventory cable. Thus, the selected inventory length is more optimal.
[0112] Continuing the above example, for the initial cable allocation in the m-th round, perform the j-th evaluation iteration.
[0113] Step 1: Determine the list of unfulfilled demand lengths in the demand length dataset: [70, 15, 214,...].
[0114] Traverse all inventory lengths with non-zero quantities, calculate the benefit value E through formula (1), and find the solution with the highest benefit E: Select an inventory of 180m (price 18 yuan), load 180m of demand length (index value in the demand length dataset is 11, the inventory cable is just filled, the cable surplus is 0, and E is 10).
[0115] Add the index value (ranging from integers ≥ 0) of the loaded demand length in the PIECE array to the same vector to obtain the first vector:
[11] , and add it to the gene sequence obtained from the previous evaluation (it can be understood that when performing the first evaluation, the gene sequence is initialized as an empty set).
[0116] Obtain the gene sequence for the current j-th evaluation: [...,
[11] ] (assuming the 11th in the PIECE array is 180m).
[0117] Step 2: Perform a decrement operation on the quantity of the inventory length of 180m in the QUANTITY.
[0118] Step 3: Mark the demand lengths sorted at 11 in the demand length dataset as allocated.
[0119] Continue with the (j + 1)-th evaluation iteration. Step 1: Determine the list of unallocated demand lengths in the demand length dataset: [70, 15, 214,...] (excluding the 11th demand length compared to the j-th round). Traverse all inventory lengths with non-zero inventory quantities again to find the solution with the highest benefit E: Select the inventory of 580m (price 58 yuan) to load as many demands as possible, such as 214 + 200 +... (total length not exceeding 580m). Obtain the first vector: [2, 6,...], and add it to the gene sequence obtained from the previous evaluation. Obtain the current gene sequence for the (j + 1)-th evaluation: [...,
[11] , [2, 6,...]]. Step 2: …… Step 3: …… And so on until all demand lengths in the demand length dataset are allocated, obtaining the result of the initial cable allocation for the m-th round, which is the m-th gene sequence in the initial population T. This gene sequence is the gene sequence obtained from the last evaluation iteration during the multiple evaluation iterations of the m-th round. In the above example, it can be represented as a vector array:
[11] , # Group 1: Demand length 11 (length 180) [2, 6], # Group 2: Demand lengths 2 (length 214) and 6 (length 200) → Total length 414 → May select an inventory length of 580m [0, 1, 7, 8], # Group 3: Demand lengths 0 (length 70), 1 (length 15), 7 (length 34), and 8 (length 39) → Total length 158 → May select an inventory length of 180m ....] The above vector array is the m-th gene sequence. The process of dividing the demand lengths into different vectors is the process of converting the problem dataset (i.e., the input parameter of the genetic algorithm model) into a gene sequence.
[0120] To enhance the randomness of the genetic algorithm and avoid premature convergence to a local optimal solution, after completing the m-th round of initial cable allocation, the order of multiple required lengths in the length dataset PIECE is randomly adjusted (while keeping the index values corresponding to each required length unchanged), thereby generating a new sequence of required lengths. This new sequence is used as the length dataset PIECE' for the next round of allocation to guide the initial cable allocation in the next round. It can be understood that for the initial cable allocation in the first round, the original order of required lengths in the length dataset PIECE is directly used.
[0121] Thus, the genetic algorithm can consider the required lengths in different orders in each iteration, which helps the algorithm jump out of the local optimum and increases the possibility of finding the global optimum.
[0122] Exemplarily, before sending the problem dataset composed of the price dictionary, required lengths, and inventory data to the algorithm module 24 for processing, it is encrypted using the public key provided by the security encryption module 25 to obtain encrypted data. Further, the algorithm module 24 creates a preset number of gene sequences based on the encrypted data to form an initial gene population.
[0123] Thus, it ensures the security and privacy of data even in a third-party computing environment.
[0124] Step S303: Use the genetic algorithm to perform population iteration on the initial gene population until the termination condition is met to obtain the target gene population. Population iteration includes calculating the fitness of each gene sequence in the gene population using the fitness function, and performing genetic operator operations on the gene sequences in the gene population according to the fitness to obtain a new gene population. The gene sequences with higher fitness in the target gene population are used to determine the cable allocation results corresponding to each model.
[0125] Exemplarily, in the genetic algorithm, the fitness function is used to score each individual in the population. The higher the score, the more adaptable the individual is to the environment, that is, the better the solution.
[0126] Since the initial gene population T is obtained using the greedy algorithm, but the greedy algorithm does not always obtain the global optimum because it only considers the local optimum at each step and does not consider the overall situation of the entire problem. Therefore, when calculating the fitness of each gene sequence in the initial gene population T using the fitness function, for each gene sequence, the following operations are performed on each vector it includes in turn to re-determine the second-optimal inventory for the required lengths allocated by each vector from the inventory length dataset.
[0127] For the current vector, the operations include: traversing the inventory length dataset based on the number dataset, and using the benefit function of the greedy algorithm (such as formula (1)) to select the second-optimal inventory length corresponding to the maximum benefit from the target data subset of the inventory length dataset. It can be understood that the number corresponding to the second-optimal inventory length currently is not zero. After determining the second-optimal inventory length of the current vector, perform a subtraction operation on the number corresponding to the second-optimal inventory length in the number dataset to determine the second-optimal inventory of the next vector. The inventory lengths in the target data subset conform to the global policy, and the global policy is determined based on experience, representing the distribution policy that the cable section sales business usually needs to follow. For example, the inventory length minus the demand length is non-negative, etc.
[0128] Finally, sum up the prices corresponding to the second-optimal inventory lengths of each vector to obtain the fitness of the gene sequence.
[0129] Among them, the fitness function F is expressed by formula (2) as:
[0130] F = ∑Price 2(j) (2)
[0131] Price 2(j) is the price corresponding to the second-optimal inventory length of the jth vector in the gene sequence.
[0132] After performing the above operations, the fitness of each gene sequence in the initial gene population T can be obtained.
[0133] Next, enter the genetic operator simulation stage as Figure 1 shown.
[0134] Exemplarily, apply three basic operators of the genetic algorithm for population iterative optimization: the selection operator (such as random selection) retains individuals with high fitness, and the crossover operator (such as single-point or multi-point crossover) and the mutation operator (such as random perturbation) introduce diversity to generate a new population (population T + 1). The population iteration process continues until the termination condition is met (such as reaching the maximum number of iterations or fitness convergence).
[0135] First, in the selection stage, use the selection operator to randomly select at least two gene sequences from the gene population, for example, select 20 from 50 gene sequences. Fitness is used to determine which individuals will be selected for breeding the next generation. Usually, individuals with higher fitness have a higher probability of being selected. Therefore, select the first gene sequence and the second gene sequence with the highest and second-highest fitness from at least two gene sequences.
[0136] Secondly, in the crossover stage, use the crossover operator to randomly select a crossover point to recombine part of the vectors of the first gene sequence and the second gene sequence into offspring, that is, a new gene sequence (the first sub-gene sequence).
[0137] For example, the intersection of parent 1: intercept item_chromosome1[0:2] → [
[11] , [2,6]], Intersection of parent 2: intercept item_chromosome2[1:3] → [[2,5], [0,7]], The offspring inherits the first half of parent 1 + the second half of parent 2, so the offspring is [
[11] ,[0,7]].
[0138] The first sub-gene sequence replaces the vector represented by item_chromosome1[0:2] in parent 1 to obtain the third gene sequence.
[0139] Finally, in the mutation phase, it is randomly determined whether to perform the mutation operation of the third gene sequence. If it is performed, the fourth gene sequence is obtained according to the mutation operation, and the fourth gene sequence is added to the gene population to obtain a new gene population. The mutation operation is used to simulate the genetic mutation process in nature.
[0140] The random judgment process includes: generating a random number, and if the random number is greater than the preset mutation rate, performing a mutation operation. Since the mutation operation is performed randomly, the exploration ability of the genetic algorithm can be increased.
[0141] If not executed, the third gene sequence is added to the gene population to obtain a new gene population.
[0142] The mutation operation includes using a mutation operator to randomly select a portion of the vectors of the third gene sequence, shuffle them, and then reassemble them into a new gene sequence (the fourth gene sequence).
[0143] Specifically, a partial vector of the third gene sequence is randomly selected, and a required length component of the partial vector of the third gene sequence is used to obtain a required length data set. The partial required length data set is used to replace the required length data set to obtain a partial problem data set. The initial cable distribution is performed according to the partial problem data set using a greedy algorithm to obtain a second sub-gene sequence. The second sub-gene sequence replaces a partial vector of the third gene sequence to obtain a fourth gene sequence.
[0144] For example, in the case where the third gene sequence is [
[11] , [2,3,4], [0,7,8], [5,6]], two vectors [2,3,4] and [5,6] are randomly selected. The two vectors are disassembled and re - configured for initial cable distribution according to the method in step S302 to obtain a possible mutated sequence [
[11] , [2], [5,6,3], [4],[0,7,8]], which is the second sub - gene sequence. The second sub - gene sequence is used to replace the two vectors [2,3,4] and [5,6] in the third gene sequence to obtain the fourth gene sequence.
[0145] The fourth gene sequence is added to the initial gene population T to obtain a new gene population T + 1.
[0146] Thus, through the iterative process of simulating natural selection, including operations such as selection, crossover, and mutation, the genetic algorithm continuously optimizes the distribution plan and gradually approaches the goal of cost optimization. This method not only helps to reduce the distribution cost but also improves the efficiency of inventory management, ensuring the maximization of economic benefits in the cable distribution process.
[0147] In this way, the genetic algorithm is used to perform population iteration on the initial gene population until the end condition is met to obtain the target gene population. The multiple vectors included in the gene sequences with the top fitness in the target gene population and the second - best inventory corresponding to each vector are used as the multiple preferred cable distribution results for each model.
[0148] Exemplarily, if the genetic algorithm creates a preset number of gene sequences based on encrypted data, the gene sequences with the top fitness in the target gene population are also decrypted, and the decrypted data is used to determine the multiple preferred cable distribution results corresponding to each model.
[0149] Optionally, according to special requirements proposed by the sales and management department, such as avoiding the impact of specific remaining material lengths on sales or supporting the distribution of substitute materials, etc., the optimal solution is further optimized and processed to obtain the final cable distribution result for the user order.
[0150] For example, a cable distribution result can be presented as: running GA_stock_cutting... stock_length_8: [] stock_length_19: [[15, 4]] stock_length_20: [] stock_length_22: [] stock_length_49: [] stock_length_89: [[88, 1]] stock_length_180: [[180, 0], [111, 64, 5]] stock_length_580: [[214, 200, 133, 30, 3]] stock_length_780: [[489, 254, 37, 0]] stock_length_940: [[39, 901]] stock_length_1940: [[95, 79, 70, 34, 28, 1634]] stock_length_2330: [] stock_length_2580: [] stock_length_3290: [] stock_length: 8 left qty: 1 stock_length: 19 left qty: 0 stock_length: 20 left qty: 1 stock_length: 22 left qty: 1 stock_length: 49 left qty: 1 stock_length: 89 left qty: 0 stock_length: 180 left qty: 0 stock_length: 580 left qty: 0 stock_length: 780 left qty: 0 stock_length: 940 left qty: 0 stock_length: 1940 left qty: 0 stock_length: 2330 left qty: 1 stock_length: 2580 left qty: 1 stock_length: 3290 left qty: 1 cost: 470.8 ---GA runtime: 0.04809141159057617 seconds --- Among them, the array in the form of stock_length_ represents the cutting situation of the in-stock cables. For example, stock_length_180: [[180, 0], [111, 64, 5]]. This array includes two vectors, indicating that two in-stock cables with a length of 180 are allocated. On the first in-stock cable with a length of 180 meters, no cutting is required for all uses. The second one needs to be cut twice to obtain 111 meters and 64 meters, with 5 meters of remaining material.
[0151] stock_length: 180 left qty: 0 means that the remaining sellable quantity of the 180-meter in-stock cable is 0.
[0152] cost is the fitness of the cable allocation result for this time.
[0153] In summary, the embodiment of the present application proposes a solution. This solution can automatically query and match the in-stock inventory and count the available quantity according to the required model, required length, and allocation strategy specified in the user order. On this basis, the genetic algorithm is further applied to find the optimal allocation plan. This method can achieve automated material order generation, reduce the work pressure of sales management personnel. Moreover, it can optimize the cable allocation process for specific requirements, improve the utilization rate of the in-stock inventory, and reduce resource waste.
[0154] It can be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application. In addition, in some possible implementation manners, the steps in the above embodiments can be selectively executed according to the actual situation, can be partially executed, or can be fully executed, which is not limited herein. Additionally, all or part of any feature in the above embodiments can be freely combined arbitrarily on the premise of not being contradictory. The combined technical solutions are also within the scope of the present application.
[0155] Exemplarily, Figure 4 shows a schematic diagram of a cable allocation device based on a genetic algorithm provided by an embodiment of the present application.
[0156] As Figure 4 shown, the cable allocation device 400 includes:
[0157] An acquisition module 410 is configured to acquire information on a user order and inventory data; the user order includes cable requirements of multiple models, the information includes the models of multiple cables under the same model and their respective required lengths, and the distribution strategy corresponding to the user order; the inventory data includes multiple different inventory lengths under each model and the number of pieces corresponding to each inventory length.
[0158] A processing module 420 is configured to create a preset number of gene sequences for each model according to the distribution strategy, the required length, and the inventory data to form an initial gene population.
[0159] The processing module 420 is further configured to perform population iteration on the initial gene population using a genetic algorithm until an end condition is met to obtain a target gene population; the population iteration includes calculating the fitness of each gene sequence in the gene population using a fitness function and performing genetic operator operations on the gene sequences in the gene population to obtain a new gene population; the gene sequences with the top fitness in the target gene population are used to determine the cable distribution results corresponding to each model.
[0160] Based on the method in the above embodiments, an embodiment of the present application provides an electronic device. The electronic device may include: at least one memory for storing a program; at least one processor for executing the program stored in the memory. Wherein, when the program stored in the memory is executed, the processor is configured to execute the method described in the above embodiments. Exemplarily, the electronic device may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, a server, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an artificial intelligence (AI) device. The specific type of the electronic device is not particularly limited in the embodiments of the present application.
[0161] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0162] It can be understood that the various numerical numbers involved in the embodiments of the present application are only for the convenience of description and are not used to limit the scope of the embodiments of the present application. It should be understood that in the embodiments of the present application, the magnitudes of the serial numbers of the above processes do not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
[0163] The specific embodiments described above further elaborate on the purpose, technical solution, and beneficial effects of the present application. It should be understood that the above is only the specific embodiment of the present invention and is not used to limit the protection scope of the present application. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solution of the present application should be included in the protection scope of the present application.
Claims
1. A cable distribution method based on genetic algorithm, characterized in that: The method comprises: Obtaining user order information and inventory data; the user order information includes the required lengths of cables of various models and the distribution strategy of the user order; the inventory data includes the inventory lengths of each model and the number of cables of each inventory length; For each model, a preset number of gene sequences are created according to the distribution strategy, the demand length and the inventory data to form an initial gene population; The initial gene population is iterated by using a genetic algorithm until an end condition is met to obtain a target gene population; the population iteration includes calculating the fitness of each gene sequence in the gene population by using a fitness function, and performing genetic operator operations on the gene sequences in the gene population according to the fitness to obtain a new gene population; the gene sequences with the highest fitness in the target gene population are used to determine the cable distribution results corresponding to each model.
2. The method according to claim 1, characterized in that The step of creating a preset number of gene sequences according to the distribution strategy, the demand length and the inventory data includes: According to the price strategy corresponding to the distribution strategy, the price corresponding to each inventory length is obtained to form a price dictionary; The price dictionary, the demand length, and the inventory data are structured to obtain a problem data set; the problem data set includes a demand length data set, an inventory length data set, a price data set consisting of value pairs of each inventory length and its corresponding price, and a number data set consisting of value pairs of each inventory length and its corresponding number of items; A greedy algorithm is used to perform the preset number of rounds of initial cable allocation according to the problem data set to obtain the preset number of gene sequences; each gene sequence includes multiple vectors corresponding to the result of the initial cable allocation once, each vector is a set of at least one required length in the required length data set, and the set indicates that the at least one required length is allocated based on a stock cable.
3. The method according to claim 2, characterized in that The method of using a greedy algorithm to perform a preset number of rounds of initial cable distribution according to the problem data set includes: For each round of initial cable distribution, the problem data set of the round is evaluated using the benefit function of the greedy algorithm to determine multiple vectors of gene sequences corresponding to the round; the benefit function is set based on the distribution strategy; The order of multiple required lengths in the required length data set is randomly adjusted to obtain a problem data set for the next round.
4. The method according to claim 3, characterized in that The use of the benefit function of the greedy algorithm to evaluate the problem data set of this round includes: For each round of initial cable allocation, multiple evaluation iterations are performed on the problem data set of the round until multiple required lengths in the required length data set are allocated; Wherein, in each evaluation iteration, for the unallocated demand length in the demand length data set, the inventory length data set is traversed based on the number data set, and the first optimal inventory length corresponding to the maximum benefit is selected from the inventory length data set using the benefit function, and the first vector of the current round of gene sequences is generated at the same time; the number of items currently corresponding to the first optimal inventory length is not zero; and Subtract 1 from the number of items corresponding to the first optimal inventory length in the item number data set; and The demand length included in the first vector is marked as allocated in the demand length dataset for the next evaluation iteration.
5. The method according to claim 4, characterized in that The distribution strategy is a minimum surplus strategy; The benefit E of the first vector is calculated using the following benefit function: E=(∑Length i )÷Price1, Among them, Length i is the i-th demand length included in the first vector, and Price1 is the price corresponding to the first optimal inventory length.
6. The method according to claim 2, wherein the step of calculating the fitness of each gene sequence in the gene population using a fitness function comprises: For each gene sequence, the following operations are performed in sequence for each vector included therein: based on the number data set, the inventory length data set is traversed, and the second optimal inventory length corresponding to the maximum benefit is selected from the target data subset of the inventory length data set using the benefit function of the greedy algorithm, and the number of items currently corresponding to the second optimal inventory length is not zero; as well as Subtract 1 from the number of items corresponding to the second optimal inventory length in the item number data set to perform a next vector operation; The inventory length in the target data subset complies with a global policy, wherein the global policy is determined based on experience; Sum the prices corresponding to the second optimal inventory length of each vector to obtain the fitness of the gene sequence; Wherein, the fitness function F is expressed by the formula: , Price 2(j) is the price corresponding to the second optimal inventory length of the jth vector in the gene sequence.
7. The method according to claim 2, wherein the genetic operator operation is performed on the gene sequence in the gene population according to the fitness to obtain a new gene population, comprising: randomly selecting at least two gene sequences from the gene population; Selecting a first gene sequence and a second gene sequence with the highest and second highest fitness from at least two gene sequences; Randomly selecting intersection points to rejoin partial vectors of the first gene sequence and the second gene sequence to obtain a first sub-gene sequence; Substituting the first sub-gene sequence for a partial vector of the first gene sequence to obtain a third gene sequence; Randomly determine whether to perform a mutation operation on the third gene sequence, and if performed, obtain a fourth gene sequence according to the mutation operation, and add the fourth gene sequence to the gene population to obtain the new gene population; the mutation operation is used to simulate a genetic mutation process in nature; If not executed, the third gene sequence is added to the gene population to obtain the new gene population.
8. The method according to claim 7, wherein obtaining a fourth gene sequence according to the mutation operation comprises: Randomly selecting a partial vector of the third gene sequence; Utilize the required length component required length data set included in the partial vector of the third gene sequence; Replacing the required length data set with the partial required length data set to obtain a partial problem data set; Using the greedy algorithm to perform initial cable matching based on part of the problem data set, the second sub-gene sequence is obtained; The second sub-gene sequence replaces a part of the vector of the third gene sequence to obtain the fourth gene sequence.
9. The method according to claim 6, further comprising: A plurality of vectors including gene sequences with the highest fitness in the target gene population and the second best inventory corresponding to each vector are used as a plurality of preferred cable distribution results for each model.
10. The method according to claim 1, wherein the step of creating a preset number of gene sequences according to the distribution strategy, the demand length and the inventory data comprises: According to the price strategy corresponding to the distribution strategy, the price corresponding to each inventory length is obtained to form a price dictionary; Encrypting the price dictionary, the demand length and the inventory data to obtain encrypted data; Creating a preset number of gene sequences according to the encrypted data to form an initial gene population; The gene sequences with the highest fitness in the target gene population are used to determine the cable distribution results corresponding to each model, including: the decrypted data of the gene sequences with the highest fitness in the target gene population are used to determine the cable distribution results corresponding to each model.
11. A cable distribution device based on genetic algorithm, characterized in that: The device comprises: The acquisition module is used to acquire user order information and inventory data; the user order information includes the required lengths of cables of various models and the distribution strategy of the user order; the inventory data includes the inventory lengths of each model and the number of cables of each inventory length; A processing module, for creating a preset number of gene sequences for each model according to the distribution strategy, the demand length and the inventory data to form an initial gene population; The processing module is also used to use a genetic algorithm to perform population iteration on the initial gene population until an end condition is met to obtain a target gene population; the population iteration includes using a fitness function to calculate the fitness of each gene sequence in the gene population, and performing genetic operator operations on the gene sequences in the gene population according to the fitness to obtain a new gene population; the gene sequences with the highest fitness in the target gene population are used to determine the cable distribution results corresponding to each model.
Citation Information
Patent Citations
To-be-warehoused cargo data processing method, device and equipment and a storage medium
CN112860917A
Production and manufacturing scheduling optimization method based on improved genetic algorithm
CN113379087A
Assembly sequence planning method of genetic greedy combinatorial algorithm
CN116933485A
Optical cable fiber distribution method and device based on improved genetic algorithm
CN117952193A
Goods shelf hit method, processor and machine readable storage medium
CN119228274A