Method for improving message scheduling mechanism based on adaptive genetic algorithm
By introducing adaptive mechanisms and cosine function strategies into the genetic algorithm, the parameters are dynamically adjusted to balance global and local searches, solving the problem of premature convergence in message scheduling in traditional genetic algorithms, achieving more efficient search and lower transmission time.
Patent Information
- Application Number
- CN202510527186.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-04-25
AI Technical Summary
Traditional genetic algorithms are prone to the loss of excellent gene fragments in message scheduling, resulting in premature convergence of the algorithm and low search efficiency.
The message scheduling mechanism based on adaptive genetic algorithm is adopted, and the cross probability and variation probability are dynamically adjusted, combined with the smooth transition strategy of the cosine function, to ensure the balance between global exploration and local development.
Effectively prevent the loss of excellent individuals, improve search efficiency, ensure that the best message scheduling solution is found within a lower number of iterations, and reduce transmission time and running time.
Smart Images

Figure CN120074979A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of intelligent control, and more specifically, relates to an improved method for a message scheduling mechanism based on an adaptive genetic algorithm. Background Art
[0002] The genetic algorithm (GA) is a computational model that simulates the natural selection of Darwin's theory of biological evolution and the biological evolution process of genetic mechanisms. It is a method for searching for the optimal solution by simulating the natural evolution process. Its main feature is that it directly operates on structural objects, without the limitations of derivative calculation and function continuity.
[0003] Chinese invention patent CN101814086A discloses a Chinese WEB information filtering method based on a fuzzy genetic algorithm. Using a text training set, a filtering template is established by means of a fuzzy genetic algorithm; intercept and parse WEB data packets, and extract valid text information therefrom; extract website information, keyword information, and Chinese domain name information from the obtained valid information, and apply a three-layer filtering mechanism for preliminary filtering to return a filtering result; perform word segmentation and stop word removal processing on the text information that has not been filtered out, and perform hierarchical clustering to form a concept-based logical paragraph, and calculate the weight of feature items; perform similarity matching between the processing result and the filtering template to return a matching result; comprehensively determine whether the obtained text information is filtered based on the filtering result and the matching result, and directly block the filtered web page information; use a feedback method and combine user feedback information to feedback on the filtering result and update the filtering template.
[0004] However, traditional genetic algorithms have problems such as parameter fixity, slow convergence speed, difficulty in balancing global and local searches, insufficient adaptability, and poor algorithm stability, as well as excessive CAN message transmission time. Summary of the Invention
[0005] The present invention aims to overcome the above technical defects of traditional genetic algorithms and provides an improved method for a message scheduling mechanism based on an adaptive genetic algorithm to solve problems such as the genetic algorithm being prone to losing some excellent gene fragments, resulting in premature convergence of the algorithm and low search efficiency in the later stage of evolution.
[0006] In addition, it also includes a device for implementing an improved method for a message scheduling mechanism based on an adaptive genetic algorithm.
[0007] In another aspect of the present invention, a computer-readable storage medium is also provided, which stores executable instructions for executing an improved method for a message scheduling mechanism based on an adaptive genetic algorithm.
[0008] The detailed technical solution of the present invention is as follows: An improved method for a message scheduling mechanism based on an adaptive genetic algorithm, the method comprising: S1. Represent the CAN message scheduling scheme as a chromosome, i.e., a set of genes, where each gene represents a message parameter, including transmission time, priority, message identifier, bandwidth allocation, and transmission node, thereby determining the encoding strategy. Then, use sorting encoding to establish a one-to-one mapping relationship between the actual values of the independent variables and the encoding algebra.
[0009] Further, the CAN bus message scheduling scheme is encoded as {X, Y, Z, P, Q}, where X is the transmission time; Y is the priority; Z is the message identifier; P is the bandwidth allocation; and Q is the transmission node.
[0010] S2. Initialize the population, select the population size, i.e., a set of CAN message data frames, the chromosome size, and determine the convergence condition. Select the roulette wheel selection and the elite retention selection as the selection methods; Select non-uniform mutation as the mutation method; select single-point crossover as the crossover method. Mutation and crossover are key genetic operations in the genetic algorithm.
[0011] S3. Use the transmission time of a set of CAN message scheduling schemes that have completed the crossover and mutation processes as the fitness value of this set for fitness analysis; This set of CAN message scheduling schemes that have completed the crossover and mutation processes is an individual, and the population is all the offspring generated after experiencing the crossover and mutation processes again. Then, calculate the fitness of each individual in the population and sort them according to the size of the fitness; S4. According to the sorting by the size of the fitness, the median fitness value of the population can be obtained and the average fitness value of the population , and judge whether it holds: If it does not hold, then the median of the fitness set composed of the fitness values of all individuals in this population is greater than the average fitness of this population, and enter the S5 operation; If it holds, then the median of the fitness set composed of the fitness values of all individuals in this population is less than the average fitness of this population, and enter the S6 operation.
[0012] S5: First, perform mutation and crossover operations to generate a second-generation population, and then screen and save the high-quality individuals in this population through the selection operation; the specific S5 is: First, let the minimum crossover probability of the first-generation population be ; the maximum crossover probability be ; the minimum mutation probability be ; the maximum crossover probability be , and first perform non-uniform mutation operations; In the non-uniform mutation operation, first, the relationship between the fitness value of the individual and the average fitness value of the current population is judged. If , then the crossover probability of the individual is: (1); In formula (1), is the crossover probability of the individual, is the maximum crossover probability in the current population, is the minimum crossover probability in the current population, is the maximum fitness value in the current population, is the average fitness value in the current population, is the fitness value of the current individual; If , then the mutation probability of the individual is reduced to preserve its high-quality genes, and the mutation probability of the individual , and then the five message parameters included in the individual are mutated according to this mutation probability respectively; Then, the single-point crossover operation is performed. In the single-point crossover operation, first, the relationship between the fitness value of the individual and the average fitness value of the current population is judged; among them, at this time, the population is the new population composed of the individual population before the mutation operation plus all the new individuals generated by the mutation operation; If , then the mutation probability of the individual ; If , then the mutation probability of the individual: (2); In formula (2), is the crossover probability of the individual, is the maximum mutation probability in the current population, is the minimum mutation crossover probability in the current population; The single-point crossover operation is as follows: For an individual in a new population, for one message parameter of this individual, it exchanges with the same message parameter of another individual with the crossover probability of the individual.
[0013] After completing the mutation and crossover operations, finally, the selection operation of the best retention strategy is performed, that is, only the top individuals with the highest individual fitness values in the population are retained as the second-generation population.
[0014] This selection method can effectively prevent the loss of excellent individuals in the new population generated by the crossover and mutation operations. In the early stage of convergence, in order to ensure population diversity, when the number of iterations is less than or equal to 30 generations, let k = the average value of the population size. In the later stage of convergence, in order to ensure the rapid convergence of the result. Therefore, when the number of iterations is greater than 30 generations, let , is the average of the population size.
[0015] S6. First, perform a selection operation to preserve the high-quality individuals in the population, and then perform mutation and crossover operations on the selected population to increase the probability of generating high-quality individuals; specifically, S6 is as follows: First, perform the selection operation of roulette wheel selection. Roulette wheel selection simulates the random selection process of a casino roulette wheel. The higher the fitness value of an individual, the greater the probability of being selected; calculate the selection probability of each individual, and the individual selection probability formula is as follows: (3); In formula (3), is the selection probability of individual i; is the fitness value of individual i; is the number of individuals in the population; is the total probability of the population, and j is a variable; Subsequently, calculate the cumulative probability to form a roulette wheel interval: (4); In formula (4), is the cumulative probability of individual i; Secondly, generate a random number r within , and then select the individual i that satisfies to form a new population and perform single-point crossover operation, and finally perform non-uniform mutation operation; Among them, the crossover and mutation operations are the same as S5 to obtain the second-generation population; S7. In this improved cosine-type adaptive genetic algorithm, determine the convergence condition.
[0016] Then perform convergence judgment until the best fitness value of the individual in this convergence is equal to the best fitness value of the historical individual, and then stop the convergence; otherwise, enter the next convergence and re-perform S3; S8. Perform such cyclic operations until the optimal solution, that is, the best message scheduling scheme, is found and output the optimal solution.
[0017] Furthermore, specifically, S7 includes: First, set maxIter = 150, preset the maximum number of iterations to 150 times; and record the best fitness value of the historical individual, and compare it with the best fitness value of the previous individual each time an iteration is completed to judge convergence; After one convergence is completed, first determine whether the number of iterations exceeds the preset maximum number of iterations, and then determine the relationship between the individual best fitness value in this convergence and the historical individual best fitness value. If it is less than the historical individual best fitness value, enter the next convergence and re - perform S3; if they are equal, stop the convergence.
[0018] The present invention further includes a device for an improved method of a message scheduling mechanism based on an adaptive genetic algorithm. The device includes: A processor; A memory, on which a computer program that can run on the processor is stored; Wherein, when the computer program is executed by the processor, it implements the steps of an improved method of a message scheduling mechanism based on an adaptive genetic algorithm.
[0019] A computer - readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements an improved method of a message scheduling mechanism based on an adaptive genetic algorithm.
[0020] Compared with the prior art, the beneficial effects of the present invention are as follows: (1) For the improved method of a message scheduling mechanism based on an adaptive genetic algorithm provided by the present invention, compared with the traditional genetic algorithm, the improved cosine - type adaptive genetic algorithm can first dynamically adjust the probability to achieve a balance between global exploration and local development; secondly, it has a fitness feedback mechanism, that is, it can automatically optimize parameters according to the population state, and finally uses the cosine function as a smooth transition strategy, thereby reducing the impact of parameter mutation on the population.
[0021] (2) For the improved method of a message scheduling mechanism based on an adaptive genetic algorithm provided by the present invention, compared with the cosine - type adaptive genetic algorithm, it can better optimize the CAN protocol message scheduling mechanism, so that while ensuring the best CAN protocol message scheduling scheme, that is, the lowest transmission time, it can ensure fewer iterations, that is, fast convergence, and thus better complete the transmission task of CAN messages on the CAN bus. Description of the Drawings
[0022] Figure 1 is a flowchart of the improved method of a message scheduling mechanism based on an adaptive genetic algorithm of the present invention. Detailed Embodiments
[0023] The following further describes the present invention in conjunction with the drawings and embodiments.
[0024] It should be noted that the following detailed description is exemplary and is intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present invention belongs.
[0025] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular forms are also intended to include the plural forms. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0026] In the case of no conflict, the embodiments in the present invention and the features in the embodiments can be combined with each other.
[0027] Embodiment 1 Refer Figure 1 , this embodiment provides an improved method for a message scheduling mechanism based on an adaptive genetic algorithm. The method includes: S1. Represent the CAN message scheduling scheme as a chromosome, that is, a set of genes. Each gene represents a message parameter, including transmission time, priority, message identifier, bandwidth allocation, and transmission node. Thus, determine the encoding strategy as sorting encoding and establish a one-to-one mapping relationship between the actual values of the independent variables and the encoding generations.
[0028] Preferably, the CAN bus message scheduling scheme is encoded as {X, Y, Z, P, Q}; where: X is the transmission time; Y is the priority; Z is the message identifier; P is the bandwidth allocation; Q is the transmission node.
[0029] S2. Initialize the population, that is, perform encoding operations to generate an initial population, select the population size, that is, a set of CAN message data frames, the chromosome size, and determine the selection method. Since other selection methods are not suitable for the optimization strategy of the CAN message scheduling mechanism, the roulette wheel selection and the best retention selection methods are selected for the selection process. For the transmission time requirements of the CAN message data frames, this dual selection method can ensure that it does not converge too quickly and that the number of offspring is not too large, resulting in too slow convergence.
[0030] Since there are only five message parameters, non-uniform mutation can be selected for the mutation method. This method can improve the diversity and selectivity of the offspring. However, the number of offspring cannot be too large, resulting in too slow convergence. Therefore, the single-point crossover method is selected for the crossover method. Mutation and crossover are the key genetic operations in the genetic algorithm.
[0031] Preferably, this embodiment applies the Improved Cosine-based Adaptive Genetic Algorithm (ICAGA). This algorithm can dynamically adjust these parameters according to the running situation of the algorithm. For example, the crossover probability and mutation probability can be adjusted based on information such as the diversity of the population and the change of fitness values to avoid premature convergence and enhance the search ability.
[0032] The crossover and mutation probabilities can be adaptively adjusted according to the fitness of individuals or other statistical information. For example, individuals with high fitness can adopt a lower mutation probability, while individuals with low fitness can adopt a higher mutation probability to increase the possibility of mutation and exploring new solutions.
[0033] The formulas for the improved crossover probability and mutation probability are as follows: (5); (6); In formulas (5)-(6), is the crossover operator, is the maximum probability in the crossover probability, is the minimum probability in the crossover probability, is the maximum fitness value of the current population, is the average fitness value of the current population, is the fitness value of the current individual, is the mutation operator, is the maximum probability in the mutation probability, is the minimum probability in the mutation probability.
[0034] The improved crossover probability and mutation probability decrease as the fitness value increases and increase as the fitness value decreases. This way can effectively preserve excellent individuals and increase the probability of inferior individuals producing excellent offspring. When the current fitness and the average fitness are infinitely close, the cosine value is close to 1, and at this time, the values of the crossover probability and mutation probability are the largest. When the value of the current fitness and the value of the average fitness are infinitely far apart, the cosine value approaches 0.
[0035] S3. Construct a fitness function to calculate the individual fitness value: Use the transmission time of a group of CAN message scheduling schemes that have completed the crossover and mutation processes as the fitness value of this group for fitness analysis; A group of CAN message scheduling schemes that have completed the crossover and mutation processes is an individual, and the population is all the offspring generated after going through the crossover and mutation processes again; Then calculate the fitness of each individual in the population and sort them according to the size of the fitness.
[0036] S4. Sorting according to the fitness values can obtain the median fitness value of the population and the average fitness value of the population. , and judge whether it holds: If it does not hold, it means that the median of the fitness set composed of the fitness values of all individuals in this population is greater than the average fitness of this population, that is, there are fewer high-quality individuals in this population. The high-quality individuals represent message scheduling schemes with high fitness values, and finally enter the S5 operation.
[0037] If it holds, it means that the median of the fitness set composed of the fitness values of all individuals in this population is less than the average fitness of this population, that is, there are more high-quality individuals in this population, and finally enter the S6 operation; S5: First perform mutation and crossover operations to generate a second-generation population, and then screen and save the high-quality individuals in this population through selection operations.
[0038] Preferably, the S5 specifically includes: First, let the minimum crossover probability of the first-generation population be ; the maximum crossover probability be ; the minimum mutation probability be ; the maximum crossover probability be ; according to the process of the improved cosine-type adaptive genetic algorithm, that is, first perform non-uniform mutation operations; In the non-uniform mutation operation, first judge the size relationship between the fitness value of this individual and the average fitness value of the current population. If , then the crossover probability of the individual is: (1); In formula (1), is the crossover probability of the individual, is the maximum crossover probability in the current population, is the minimum crossover probability in the current population, is the maximum fitness value in the current population, is the average fitness value in the current population, is the fitness value of the current individual; If , that is, the fitness value of this individual is greater than the average fitness value of this population, it means that this individual is a high-quality individual. Therefore, it is necessary to preserve its high-quality genes by reducing the mutation probability of this individual. So the mutation probability of this individual, and then the five message parameters included in this individual mutate according to this mutation probability respectively.
[0039] Then perform the single-point crossover operation to generate the second-generation population. In the single-point crossover operation, first determine the relationship between the fitness value of an individual and the average fitness value of the current population. Here, the population at this time is not just the population before the mutation operation, but a new population composed of the individual population before the mutation operation plus all the new individuals generated through the mutation operation.
[0040] If , then the mutation probability of this individual ; If , then the mutation probability of this individual: (2); In formula (2), is the crossover probability of the individual, is the maximum mutation probability in the current population, is the minimum mutation crossover probability in the current population; Taking an individual in a new population as an example, for a message parameter of this individual, it is exchanged with the same message parameter of another individual with the crossover probability of the individual.
[0041] After completing the two operations of mutation and crossover, finally perform the selection operation of the best retention strategy to screen and save the high-quality individuals in this population, that is, only retain the top individuals with the highest fitness value in the population as the second-generation population.
[0042] This selection method can effectively prevent the loss of excellent individuals in the new population generated by the crossover and mutation operations.
[0043] Preferably, in the early stage of convergence, in order to ensure population diversity, when the number of iterations is less than or equal to 30 generations, let k = the average value of the population size. In the late stage of convergence, in order to ensure the rapid convergence of the result. Therefore, when the number of iterations is greater than 30 generations, let , be the average value of the population size.
[0044] S6. First, perform the selection operation to save the high-quality individuals in this population, and then perform the mutation and crossover operations on the screened population to increase the probability of generating high-quality individuals.
[0045] Preferably, the S6 specifically includes: According to the process of the improved cosine-type adaptive genetic algorithm, first perform the selection operation of roulette wheel selection, which simulates the random selection process of a casino roulette wheel. The higher the fitness value of an individual, the greater the probability of being selected. This selection method can further filter out a small number of non-high-quality individuals in the population for a population with more high-quality individuals, so as to achieve the rapid convergence of the population. First, calculate the selection probability of each individual, and the individual selection probability formula is as follows: (3); In formula (3), is the selection probability of individual i; is the fitness value of individual i; is the number of individuals in the population; is the total probability of the population, and j is a variable.
[0046] Subsequently, calculate the cumulative probability to form a roulette wheel interval: (4); In formula (4), is the cumulative probability of individual i; Secondly, generate a random number r within, and then select the individual i that satisfies and form a new population, and then perform the single-point crossover operation, and finally perform the non-uniform mutation operation, where the crossover and mutation operations are the same as S5, so as to obtain the second-generation population.
[0047] S7. In this improved cosine-type adaptive genetic algorithm, determine the convergence condition.
[0048] Preset the maximum number of iterations and record the historical individual optimal fitness value; Then perform the convergence judgment until the individual best fitness value in this convergence is equal to the historical individual best fitness value, then stop the convergence; otherwise, enter the next convergence and re-perform S3.
[0049] Preferably, first set maxIter = 150, preset the maximum number of iterations to 150 times; that is, maxIter = 150; if iter >= maxIter break; end.
[0050] And record the historical individual optimal fitness value, that is, best_fitness_history(iter) = current_best_fitness; make a comparison with the previous individual optimal fitness value every time an iteration is completed, so as to judge the convergence; After one convergence is completed, first determine whether the number of iterations exceeds the preset maximum number of iterations, and then determine the magnitude relationship between the individual best fitness value in this convergence and the historical individual best fitness value. If it is less than the historical individual best fitness value, enter the next convergence and re - perform S3. If they are equal, stop the convergence.
[0051] S8. Repeat this operation in a loop until the optimal solution, that is, the best message scheduling scheme, is found and the optimal solution is output.
[0052] Preferably, the condition for finding the optimal solution is to reach the maximum number of iterations or the individual best fitness value in this convergence is equal to the historical individual best fitness value.
[0053] Preferably, the present invention performs sample selection: Select a control system based on the CAN protocol, which consists of 12 sensor nodes, 1 network management node (NMT) and 1 master controller node. Among them, the messages of the sensor node TPDOs are all triggered by synchronous cyclic messages (SYNC). The network management node is used to configure the network and manage the state of the system, and the master controller node is used to send synchronous cyclic messages and receive RPDOs.
[0054] Set the communication rate to 250 kbit / s and the synchronous communication period to 10000 μs. The 12 sensor nodes and their states are shown in Table 1: Table 1 Sensor nodes and their states
[0055] Table 2 Experimental results
[0056] The experimental results processed by this embodiment are shown in Table 2 and the analysis is as follows: All the message scheduling mechanisms optimized by the genetic algorithm have a reduction in the transmission time of CAN messages. However, compared with the message scheduling mechanism optimized by the traditional genetic algorithm, the message scheduling mechanism optimized by the improved cosine - type adaptive genetic algorithm not only converges more precisely, that is, the transmission time required for the CAN message scheduling scheme is lower, but also the number of iterations is increased by about two times.
[0057] Compared with the message scheduling mechanism optimized by the improved cosine - type adaptive genetic algorithm, although the transmission time required for the CAN message scheduling scheme is the same, the number of iterations of the message scheduling mechanism optimized by the improved cosine - type adaptive genetic algorithm is increased by 40% - 100%, that is, it can converge faster, reduce the running time of the genetic algorithm, and increase the confirmation time of the CAN message scheduling scheme, thus avoiding the congestion of CAN messages on the CAN bus.
[0058] Example 2 This embodiment provides an apparatus for implementing an improved method of a message scheduling mechanism based on an adaptive genetic algorithm. The apparatus includes: At least one processor; and A memory that stores instructions, which when executed by the at least one processor, cause the at least one processor to execute the improved method of a message scheduling mechanism based on an adaptive genetic algorithm as described above.
[0059] In this embodiment, the electronic device includes but is not limited to: personal computers, server computers, workstations, desktop computers, laptop computers, notebook computers, mobile computing devices, smartphones, tablet computers, cellular phones, personal digital assistants (PDAs), handheld devices, messaging devices, wearable computing devices, consumer electronic devices, etc.
[0060] Example 3 This embodiment also provides a computer-readable storage medium that stores executable instructions, which when executed cause the machine to execute the improved method of a message scheduling mechanism based on an adaptive genetic algorithm as described above.
[0061] Specifically, a system or apparatus equipped with a readable storage medium can be provided. On this readable storage medium, software program code for implementing the functions of any one of the above embodiments is stored, and the computer or processor of the system or apparatus is caused to read and execute the instructions stored in the readable storage medium.
[0062] In this case, the program code read from the readable medium itself can implement the functions of any one of the above embodiments. Therefore, the computer-readable code and the readable storage medium storing the computer-readable code constitute a part of this specification.
[0063] Examples of the readable storage medium include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, the program code can be downloaded from a server computer or a cloud via a communication network.
[0064] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) that contain computer-usable program code.
[0065] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for realizing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0066] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that realizes the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0067] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for realizing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0068] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solutions of the present invention, rather than limitations on the specific implementation manners of the present invention. Any modifications, equivalent replacements, and improvements made within the spirit and principle of the claims of the present invention shall be included within the protection scope of the claims of the present invention.
Claims
1. An improved method for message scheduling mechanism based on adaptive genetic algorithm, characterized in that: The method comprises: S1. The CAN message scheduling scheme is represented as a chromosome, i.e., a set of genes, each gene represents a message parameter, the coding strategy is determined to be sorting coding, and a one-to-one mapping relationship is established from the actual value of the independent variable to the coding algebra; S2, initialize the population, select the population size, i.e., a group of CAN message data frames, chromosome size, and determine the selection method, and select the roulette wheel selection and the best retention selection in the selection process; In the mutation mode, non-uniform mutation is selected; in the crossover mode, single-point crossover is selected; S3, taking the transmission time of a group of CAN message scheduling schemes that have completed the crossover and mutation process as the fitness value of the group to perform fitness analysis; a group of CAN message scheduling schemes that have completed the crossover and mutation process is an individual, and the population is all the offspring generated by the crossover and mutation process; Then calculate the fitness of each individual in the population and sort them according to the size of fitness; S4. Sorting by fitness can get the median fitness value of the population And the average fitness value of the population ,judge Is it established: If it is not true, the median of the fitness set composed of all individual fitness values in the population is greater than the average fitness of the population, and the process goes to S5. If it is established, the median of the fitness set composed of all individual fitness values in the population is less than the average fitness of the population, and the process goes to S6; S5, first perform a mutation crossover operation to generate a second-generation population, and then screen and preserve high-quality individuals in the population through a selection operation; S6. First, a selection operation is performed to preserve high-quality individuals in the population, and then a mutation crossover operation is performed on the screened population to increase the probability of generating high-quality individuals; S7, preset the maximum number of iterations and record the historical individual optimal fitness value; Then, the convergence judgment is performed until the best fitness value of the individual in this convergence is equal to the best fitness value of the individual in history, then the convergence is stopped; otherwise, the next convergence is entered and S3 is repeated; S8. Repeat this process repeatedly until the optimal solution, i.e., the best message scheduling solution, is found, and the optimal solution is output.
2. The improved method for message scheduling mechanism based on adaptive genetic algorithm according to claim 1, characterized in that: The message parameters include sending time, priority, message identifier, bandwidth allocation and sending node, and the CAN bus message scheduling scheme is encoded as {X, Y, Z, P, Q}; X is the sending time; Y is the priority; Z is the message identifier; P is the bandwidth allocation; and Q is the sending node.
3. The improved method for message scheduling mechanism based on adaptive genetic algorithm according to claim 2, characterized in that: The S5 is specifically: First, let the minimum crossover probability of a generation be ; The maximum crossover probability is ; The minimum mutation probability is ; The maximum crossover probability is , first perform the non-uniform mutation operation; In the non-uniform mutation operation, first determine the relationship between the fitness value of the individual and the average fitness value of the current population. If , then the crossover probability of an individual is: (1); In formula (1), is the crossover probability of an individual, is the maximum crossover probability in the current population, is the minimum crossover probability in the current population, is the maximum fitness value in the current population, is the average fitness value in the current population, is the fitness value of the current individual; if , then by reducing the mutation probability of the individual, its high-quality genes can be preserved, and the mutation probability of the individual , then the five message parameters contained in the individual are mutated according to the mutation probability; Then perform a single-point crossover operation. In the single-point crossover operation, the first step is to determine the relationship between the fitness value of the individual and the average fitness value of the current population. At this time, the population is the new population composed of the individual population before the mutation operation plus all new individuals generated by the mutation operation. if , then the mutation probability of this individual ; if , then the mutation probability of this individual is: (2); In formula (2), is the crossover probability of an individual, is the maximum mutation probability in the current population, is the minimum mutation fork probability in the current population; After completing the mutation and crossover operations, the best retention strategy selection operation is finally performed to screen and save the high-quality individuals in the population, that is, only the top individuals with the highest individual fitness value in the population are retained. individuals as the second-generation population.
4. The improved method for message scheduling mechanism based on adaptive genetic algorithm according to claim 3 is characterized in that: The S6 is specifically: First, the selection operation of roulette selection is performed. Roulette selection simulates the random selection process of casino roulette. The higher the fitness value of the individual, the greater the probability of being selected. The selection probability of each individual is calculated, and the formula for individual selection probability is as follows: (3); In formula (3), is the choice probability of individual i; is the fitness value of individual i; is the number of individuals in the population; is the total probability of the population, j is a variable; The cumulative probability is then calculated to form the roulette range: (4); In formula (4), is the cumulative probability of individual i; Next, generate a Then select a random number r that satisfies The individuals i form a new population; Then a single-point crossover operation is performed, and finally a non-uniform mutation operation is performed. The single-point crossover operation and the non-uniform mutation operation are the same as S5, thereby obtaining the second-generation population.
5. The improved method for message scheduling mechanism based on adaptive genetic algorithm according to claim 4 is characterized in that: In the early stage of convergence, that is, when the number of iterations is less than or equal to 30 generations, let k = the average number of populations; In the late stage of convergence, that is, when the number of iterations is greater than 30, let , is the average number of populations.
6. The improved method for message scheduling mechanism based on adaptive genetic algorithm according to claim 1, characterized in that: The S7 specifically includes: First, by taking maxIter=150, the maximum number of iterations is preset to 150 times; and the historical individual optimal fitness value is recorded, so that each completed iteration is compared with the previous individual optimal fitness value to determine convergence; After completing a convergence, first determine whether the number of iterations exceeds the preset maximum number of iterations, and then determine the relationship between the individual best fitness value in this convergence and the historical individual best fitness value. If it is less than the historical individual best fitness value, enter the next convergence and re-perform S3; if they are equal, stop convergence.
7. A device for improving a message scheduling mechanism based on an adaptive genetic algorithm, characterized in that: The device comprises: processor; a memory having stored thereon a computer program executable on the processor; Wherein, when the computer program is executed by the processor, the steps of the method for improving the message scheduling mechanism based on an adaptive genetic algorithm as described in any one of claims 1 to 6 are implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Chinese WEB information filtering method based on fuzzy genetic algorithm
CN101814086A
Parameter optimization method for wireless energy transmission system based on improved genetic algorithm
CN105320988A
Method for solving flexible job shop scheduling by improved genetic algorithm based on catastrophe mechanism
CN111325443A
Affine transformation solving method under massive control points based on improved genetic algorithm
CN111931934A
Data mining method and system based on simulated annealing genetic algorithm
CN117349341A