Optimization solution method based on genetic algorithm and electronic equipment
By initializing and updating populations using tensor calculations in the genetic algorithm, the problem of slow computing speed of genetic algorithms is solved, and the calculation efficiency is significantly improved, and parallel computing is supported to further improve the solution efficiency.
Patent Information
- Application Number
- CN202411818053.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The calculation speed of genetic algorithms is slow, mainly because there are many individuals in the population and each round of calculations requires calculating the fitness function of each individual, which leads to heavy calculation operations.
Tensor calculation is used to initialize and update the population, and the response function value, satisfaction function value and comprehensive satisfaction function value of each candidate solution in the population are obtained through tensor calculation, and the population is updated according to the comprehensive satisfaction function value, including retaining excellent solutions, mixing and adjustment.
The calculation efficiency of genetic algorithms has been significantly improved, and the calculation time has been reduced through overall calculation instead of one by one, and tensor calculation can be performed in parallel on the graphics processor, further improving the solution efficiency.
Smart Images

Figure CN119808904A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of optimization solutions, and in particular, relates to an optimization solution method and device based on a genetic algorithm, an electronic device, and a computer-readable storage medium. Background Art
[0002] Genetic Algorithm (GA) is a computational model of biological evolution that simulates the natural selection and genetics mechanisms of Darwin's theory of biological evolution. It searches for the optimal solution by simulating the natural evolution process.
[0003] The genetic algorithm may include initializing the population and iteratively optimizing the population. In each round of iteration, the fitness function is used to evaluate each individual in the current population to obtain the fitness value of each individual; then the current population is updated, specifically including retaining excellent solutions, mixing and adjusting.
[0004] Since the solution of the genetic algorithm requires a large number of samples, which means that there are a large number of individuals in the population, and the fitness function of each individual needs to be calculated in each round of calculation, a large number of calculation operations leads to a very slow solution speed. Summary of the invention
[0005] The embodiments of the present application provide a genetic algorithm-based optimization solution method and device, an electronic device, and a computer-readable storage medium, which can solve the problem of slow calculation speed of genetic algorithms in related technologies.
[0006] In the first aspect, an embodiment of the present application provides an optimization solution method based on a genetic algorithm, the method comprising: initializing a population in a tensor format, the population comprising multiple candidate solutions, each candidate solution comprising a set of input parameters; using tensor calculations to obtain a response function value, a desirability function value, and a comprehensive desirability function value of each candidate solution in the population; using tensor calculations to update the population according to the comprehensive desirability function value of the population, the update operation comprising retaining excellent solutions, mixing and adjusting, the excellent solution being a specified number or proportion of candidate solutions with the largest comprehensive desirability function value in the population; repeatedly using tensor calculations to obtain the response function value, desirability function value, and comprehensive desirability function value of each candidate solution in the population, as well as subsequent steps, until a stopping condition is met.
[0007] In the second aspect, an embodiment of the present application provides an optimization solution device based on a genetic algorithm, which includes: an initialization module for initializing a population in tensor format, the population including multiple candidate solutions, each candidate solution including a set of input parameters; an iteration module for using tensor calculations to iteratively optimize the population until a stopping condition is met, and each round of iterative optimization includes: using tensor calculations to obtain the response function value, desirability function value and comprehensive desirability function value of each candidate solution in the population; using tensor calculations to update the population according to the comprehensive desirability function value of the population, and the update operation includes retaining excellent solutions, mixing and adjusting, and the excellent solution is a candidate solution with a specified number or proportion with the largest comprehensive desirability function value in the population.
[0008] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable by the processor, wherein when the processor executes the computer program, the genetic algorithm-based optimization solution method described in the first aspect is implemented.
[0009] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the optimization solution method based on a genetic algorithm described in the first aspect above.
[0010] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the optimization solution method based on the genetic algorithm described in the first aspect above.
[0011] Compared with the prior art, the embodiments of the present application have the following beneficial effects: by initializing a population in tensor format, the population includes multiple candidate solutions, each candidate solution includes a set of input parameters; using tensor calculation to obtain the response function value, desirability function value and comprehensive desirability function value of each candidate solution in the population; using tensor calculation to update the population according to the comprehensive desirability function value of the population, the update operation includes retaining excellent solutions, mixing and adjusting, and the excellent solution is the candidate solution with the largest specified number or proportion of comprehensive desirability function values in the population; repeatedly using tensor calculation to obtain the response function value, desirability function value and comprehensive desirability function value of each candidate solution in the population and the subsequent steps until the stop condition is met. Using tensors to complete the calculation of the genetic algorithm, replacing the calculation of a single individual in the population with the overall calculation of the population tensor, significantly improves the calculation efficiency of the algorithm. In addition, tensor calculations can be performed in parallel on a graphics processor to further improve the solution efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0013] Figure 1 is a structural schematic diagram of an electronic device provided by an embodiment of the present application;
[0014] Figure 2 It is a flowchart of an optimization solution method based on a genetic algorithm provided in one embodiment of the present application;
[0015] Figure 3 is a flowchart of weights in a more comprehensive desirability function provided by a specific embodiment of the present application;
[0016] Figure 4 is a flow chart of a more comprehensive power index in a desirability function provided by a specific embodiment of the present application;
[0017] Figure 5 is a flow chart of a more comprehensive power index in a desirability function provided by another specific embodiment of the present application;
[0018] Figure 6 It is a schematic diagram of the structure of an optimization solution device based on a genetic algorithm provided in one embodiment of the present application. DETAILED DESCRIPTION
[0019] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0020] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0021] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0022] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0023] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0024] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0025] The optimization solution method based on genetic algorithm provided in the embodiment of the present application can be applied to electronic devices, including but not limited to servers, server clusters, mobile phones, tablet computers, laptop computers, desktop computers, personal digital assistants, wearable devices and other electronic devices with computing functions. The embodiment of the present application does not impose any restrictions on the specific type of electronic devices.
[0026] Figure 1 FIG. 1 is a block diagram of a partial structure of an electronic device provided in an embodiment of the present application. Figure 1 , the electronic device includes: a processor 10, a memory 20, a bus 30, an input device 40, an output device 50 and a communication device 60. The processor 10 and the memory 20 are connected to each other through the bus 30, and the input device 40, the output device 50 and the communication device 60 are also connected to the bus 30. Those skilled in the art can understand that Figure 1 The structure of the electronic device shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0027] Combine the following Figure 1 A detailed introduction to the various components of electronic equipment:
[0028] The processor 10 is the control center of the electronic device, and can run the program stored in the memory 20 to perform various functions and process data. The processor 10 can be a central processing unit (CPU), and the processor 10 can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In some embodiments, the processor 10 may include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0029] The memory 20 is used to store an operating system, an application program, a boot loader, data, and other programs, such as program codes of computer programs. The memory 20 can also be used to temporarily store data required for executing the program and generated. The memory 20 may include a high-speed random access memory, and may also include a non-volatile memory, such as a flash memory, a hard disk, a multimedia card, a card-type memory, etc. The memory 20 may include a storage unit disposed inside the electronic device, such as a hard disk of the electronic device, and / or a removable external storage unit, such as a mobile hard disk, a USB flash drive, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, etc.
[0030] The input device 40 may include at least one of a keyboard, a mouse, a touch panel, a joystick, etc., and is used to collect user input operations to generate corresponding operation instructions.
[0031] The output device 50 is used to output information to be provided to the user. The output device 50 generally includes a display, and optionally, a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. can be used. In addition, the output device can further include a speaker.
[0032] The communication device 60 may include a modem, a network card, etc., for establishing a network connection with other electronic devices and communicating with each other.
[0033] The optimization solution method based on genetic algorithm provided by the embodiment of the present application can be implemented as a computer software program. For example, the embodiment of the present application provides a computer program product, which includes a computer program carried on a computer readable medium, and the computer program includes a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 60, and / or installed from a detachable external storage unit. When the computer program is executed by the processor 10, the various functions defined in the optimization solution method based on genetic algorithm provided by the embodiment of the present application are realized.
[0034] Figure 2 A schematic flow chart of an optimization solution method based on a genetic algorithm provided in an embodiment of the present application is shown. As an example but not a limitation, the method can be applied to the above-mentioned electronic device.
[0035] S1: Initialize the population in tensor format.
[0036] The population is in tensor format, which includes multiple candidate solutions; each candidate solution is a sub-tensor including a set of input parameters.
[0037] Each input parameter has its own range of values. By quantizing the range of values according to the set step size, the value set of the input parameter can be obtained. A parameter space can be defined, which contains all possible combinations of input parameters, and each combination is a set of input parameters. Multiple combinations can be randomly selected from the parameter space and then tensorized as candidate solutions.
[0038] Input parameters, target parameters (also referred to as output parameters), response functions, desirability functions of each response function, and comprehensive desirability functions belong to the optimization model established for the optimization solution.
[0039] Taking the optimization of intelligent manufacturing as an example, the input parameters can specifically include raw material parameters, production process parameters, inventory allocation parameters, etc.; the target parameters can also be understood as the output parameters of the manufacturing system. The value of the target parameter is determined by the input parameters, and this influence can be described by the response function. In addition to the target parameter itself, the optimization model also includes the expected type of the target parameter, which is used to indicate the optimization direction of the target parameter. The expected type can be divided into maximization, minimization, and targeting, which correspond to maximizing the target parameter, minimizing the target parameter, and making the target parameter approach the target value.
[0040] A common situation in optimization models is that different objective parameters are related and the optimization directions are conflicting, which requires a holistic evaluation of the solutions during the optimization calculation.
[0041] The response function, also known as the objective function, is a mapping function between input parameters and target parameters. The response function corresponds to the target parameters one by one, the independent variables of the response function are at least part of the input parameters, and the dependent variables are the corresponding target parameters. The response function can be modeled based on experimental data.
[0042] Specifically, a multivariate regression model can be constructed for the response function as shown below:
[0043]
[0044] Among them, β0 is the intercept term, β i is the linear term x i The regression coefficient, β jk is the interaction term x j x k is the regression coefficient and ε is the error term.
[0045] The multivariate regression model given here only contains the product of two different independent variables, that is, the second-order interaction term. In practical applications, the order of the interaction term, that is, the number of different independent variables in the product, can be expanded according to actual needs.
[0046] According to the experimental data, the multivariate regression model can be fitted to obtain the model coefficients, including the intercept term and the regression coefficient. Specifically, the value of the target parameter in the experimental data is called the actual observed value, and the calculation result obtained by substituting the input parameters in the experimental data into the multivariate linear regression model is the model prediction value. The optimal value of the model parameter should make the error between the model prediction value and the actual observed value as small as possible. The model coefficients can be estimated by minimizing the error, such as the least squares method, the least absolute deviation, etc., without limitation here.
[0047] The desirability function, which can also be called the satisfaction function, corresponds one-to-one with the response function, that is, one-to-one with the target parameter. The desirability function of a response function can also be called the desirability function of the corresponding target parameter. The desirability function is determined by the response function value and the expected type.
[0048] Specifically, the input of the desirability function also includes the value range [L, U] of the response function value and the target value T, where L is the preset lower limit and U is the preset upper limit, and a weight parameter r for adjusting the function curve. The desirability function can be a piecewise function determined according to the expected type.
[0049] When the expected type is maximization, if the response function value y is less than the preset lower limit L, the desirability function is 0; when y is in the interval [L, T], its desirability function is calculated according to the formula Calculation; if y is greater than T, the desirability function is 1.
[0050] When the expected type is minimization, if the response function value y exceeds the preset upper limit U, the desirability function is 0; when y is in the interval [T, U], the desirability function is calculated according to the formula Calculation; if y is lower than the response function value T, then the desirability function is 1.
[0051] When the expected type is targeted: for the response function value y, if it is outside the interval [L,U], the desirability function is 0; if y is within the interval [L,T], the desirability function is calculated according to the formula Calculation; if y is in the interval [T,U], the desirability function is calculated according to the formula calculate.
[0052] Taking into account the boundary conditions that may appear in practical applications, the epsilon parameter can be introduced in the specific calculation process. For the denominator in the calculation formula of the above desirability function, if the absolute value of the calculation result is less than the epsilon parameter, it is set to the epsilon parameter to avoid the situation where 0 is used as the denominator, so as to ensure the stability and accuracy of the calculation.
[0053] The comprehensive desirability function value is used as the fitness value in the genetic algorithm to evaluate candidate solutions.
[0054] Optionally, the comprehensive desirability function is a weighted geometric mean of the desirability functions, specifically:
[0055]
[0056] Where D is the comprehensive desirability function, w i is the weight of the i-th desirability function and satisfies d i is the i-th desirability function, i = 1, 2, …, k, and k is the total number of desirability functions.
[0057] Optionally, the comprehensive desirability function is a weighted power average of the desirability functions, specifically:
[0058]
[0059] Where D is the comprehensive desirability function, w i is the weight of the i-th desirability function and satisfies d i is the i-th desirability function, i = 1, 2, …, k, k is the total number of desirability functions, and p is the power exponent.
[0060] The power exponent p determines the nonlinearity of the comprehensive desirability function.
[0061] When p > 1, the comprehensive satisfaction function is more sensitive to higher satisfaction values, that is, it is more inclined to optimize those objective functions with high satisfaction.
[0062] When p = 1, the comprehensive satisfaction function degenerates into a weighted average.
[0063] When 0 < p < 1, the comprehensive satisfaction function pays more attention to those lower satisfaction values, highlighting the sensitivity of the system to low satisfaction.
[0064] When p approaches -∞, the comprehensive satisfaction function is closer to the minimum satisfaction value (min function).
[0065] When p approaches +∞, the comprehensive satisfaction function is closer to the maximum satisfaction value (max function).
[0066] For example, assume that the satisfaction values corresponding to three objective parameters are 0.8, 0.5, and 0.9, and the weights are w1 = 0.4, w2 = 0.3, w3 = 0.3. For different power exponents p, the comprehensive satisfaction D is calculated as follows:
[0067] a. Linear combination (p = 1): D = 0.4×0.8 + 0.3×0.5 + 0.3×0.9 = 0.71
[0068] b. Convex combination (p = 2): D = (0.4×0.8^2 + 0.3×0.5^2 + 0.3×0.9^2)^1 / 2 ≈ 0.74
[0069] c. Concave combination (p = 0.5): D = (0.4×0.8^0.5 + 0.3×0.5^0.5 + 0.3×0.9^0.5)^2 ≈ 0.68. It can be seen that by choosing different p values, the degree of attention to different types of objective parameters in the optimization process can be flexibly adjusted. This non - linear combination method enables the comprehensive satisfaction function to more realistically reflect the balance between various objectives in a complex system, thus effectively improving the quality of the optimization results.
[0070] S2: Use tensor calculation to obtain the response function values, satisfaction function values, and comprehensive satisfaction function values of each candidate solution in the population.
[0071] Each candidate solution can be substituted into the response function to obtain a response value tensor composed of the response function values of each candidate solution; then, each response function value in the response value tensor is substituted into the satisfaction function to obtain a satisfaction value tensor composed of the satisfaction function values of each candidate solution; and then, each satisfaction function value of each candidate solution in the satisfaction value tensor is substituted into the comprehensive satisfaction function to obtain a comprehensive satisfaction tensor composed of the comprehensive satisfaction function values of each candidate solution.
[0072] For example, the number of response functions and desirability functions in the manufacturing model is k; the number of input parameters is l, which means the dimension of candidate solutions is l; and the number of candidate solutions in the population is m.
[0073] The tensor X representing the population can be X=[x1,x2,…,x m ], where x j is the jth candidate solution, j = 1, 2, ..., m, and the size of X is l × m. The organization of X here is only for illustration, and the rows and columns can be reversed, that is, each row represents a candidate solution.
[0074] The calculation of the response function involves high-order interaction terms in the multivariate regression model, which can be obtained by matrix multiplication of the coefficient tensor of the response function and the candidate tensor X'. The coefficient tensor includes the model coefficients in the response function obtained by fitting the experimental data, including the intercept, linear term coefficients, and interaction term coefficients. The candidate tensor is obtained by expanding the tensor X by tensor multiplication, which includes the linear terms and interaction terms that appear in the multivariate regression model. The size of the coefficient tensor matches the candidate tensor, so that the size of the obtained response value tensor R is k×m, where the element Rij represents the i-th response function value of the j-th candidate solution.
[0075] There are two ways to expand the tensor X. One way is to directly expand the tensor X according to the maximum order supported by the multivariate regression model. The resulting candidate tensor X' is the largest in size, which contains all possible linear terms and interaction terms in the multivariate regression model. The advantage is that X' is applicable to the calculation of all response functions, ensuring the universality of the calculation. The disadvantage is that X' may be too large, resulting in a significant increase in storage and calculation overhead, which in turn affects the calculation efficiency, especially when the model contains high-order interaction terms. Another way is to expand the tensor X according to the actual order and / or specific interaction terms in the response function. The size of the resulting candidate tensor X' becomes smaller, which can improve the calculation efficiency, but the universality may be affected. It is necessary to construct an adaptive candidate tensor X' for each response function separately, which increases the complexity of the calculation. Especially when there are many response functions or the model structure is complex, it may bring maintenance and implementation burdens. In practical applications, the appropriate candidate tensor X' can be selected based on factors such as the order of the interaction terms and the number of high-order interaction terms.
[0076] Each element in the tensorized desirability function is a piecewise function determined according to the expected type of the response function at the corresponding position. The tensorized desirability function is applied to the response value tensor R to obtain the desirability value tensor D, which is k×m in size, where the element D ij Represents the i-th desirability function value of the j-th candidate solution.
[0077] The obtained consensus value tensor D is calculated according to the calculation formula of the comprehensive consensus function on the dimension inside the candidate solution, which mainly involves the power operation of a single element and the product of different elements. The obtained comprehensive consensus tensor is an m-dimensional vector CD, in which the element CD j Represents the comprehensive desirability function value of the jth candidate solution.
[0078] Taking the weighted power average as an example, the calculation of comprehensive desirability specifically includes: first, for each element D in D ij Perform power calculation Generate a new tensor D′ (same size as D); then for each candidate solution j, calculate its weighted desirability, which can be achieved by multiplying each element in the j-th row of D′ with each element in the weight vector w, and finally generate a vector S (size is m), whose formula is: Finally, an overall power operation is performed: each element Sj of S is subjected to a 1 / p power operation to obtain a comprehensive desirability tensor CD (a one-dimensional vector of size m).
[0079] S3: Use tensor calculation to update the population according to the comprehensive desirability function value of the population.
[0080] The updating operations include retaining the best solution, blending and adjusting.
[0081] To prevent the excellent solutions from being affected by the above operations and causing the global optimal solution to be lost, in each round of iteration, the excellent solutions, that is, the candidate solutions with the largest specified number or proportion of comprehensive desirability function values in the population, are retained. Specifically, the maximum value returning function can be used on the comprehensive desirability tensor to determine the excellent solutions. The maximum value returning function can be torch.topk, whose input includes the number of excellent solutions n, and returns the index of the largest n elements in the comprehensive desirability tensor, that is, the index of the excellent solution. These excellent solutions are retained without being affected by mixing and adjustment.
[0082] A certain proportion of candidate solutions can be randomly selected from the current population for mixing operations. The mixing operation simulates the sexual reproduction of organisms. Specifically, a single mixing operation can include randomly selecting two candidate solutions, determining the mixing point, and exchanging parameters at the mixing point to generate two new candidate solutions to join the population. For example, after mixing the original candidate solutions A and B, the mixed candidate solutions C and D are added to the population. The original candidate solutions A and B can be deleted or retained; the part before the mixing point p in the mixed candidate solution C comes from A, and the part after the mixing point p comes from B; the part before the mixing point p in the mixed candidate solution D comes from B, and the part after the mixing point p comes from A.
[0083] The mixing operation can be implemented by organizing the input parameters of the candidate solutions into tensors. For example, if the population contains m candidate solutions, each candidate solution contains l parameters, the entire population can be represented by a tensor of size m×l. Randomly generate the index of the mixing point and create an index tensor representing the candidate solution pair; use tensor operations (slicing, splicing, etc.) to exchange part of the gene sequence of the candidate solution pair at the selected mixing point to complete the mixing operation and generate new candidate solutions in batches.
[0084] The adjustment operation simulates biological mutations to ensure the diversity of candidate solutions. The perturbation rate can be used to determine whether a candidate solution needs to be adjusted; if adjustment is required, a random input parameter of the candidate solution is selected for modification. The new value of this input parameter is randomly selected within the allowed range of values, while ensuring that the new value does not overlap with the existing value. This random fine-tuning can help explore new possible solutions and avoid all solutions from concentrating on a certain area too early, thereby increasing the chance of finding the global optimal solution. The population is adjusted based on random selection and tensorization functions.
[0085] The tensor-based adjustment process may include: using torch.rand(1) to generate a tensor random number between 0 and 1, comparing it with the perturbation rate, randomly selecting a tensor from the parameter space as the adjustment solution, and randomly selecting a candidate solution that is not an excellent solution to replace it with the adjustment solution.
[0086] S4: Update the weights and / or power exponents in the comprehensive desirability function.
[0087] In some embodiments, this step may be omitted.
[0088] The comprehensive desirability function is the weighted power average or weighted geometric mean of each desirability function.
[0089] In a complex system, the priority of the target parameters may change with time, external conditions, or the progress of the optimization process. Therefore, a dynamic adjustment mechanism can be introduced so that the weights and / or power indexes can be adaptively adjusted according to the current state or historical performance of the system, which can more accurately reflect the actual needs and improve the optimization effect. There is no restriction on the execution order between this step and S3.
[0090] like Figure 3 As shown, in a specific embodiment of the present application, updating the weight may specifically include the following parts.
[0091] S101: Calculate the overall comprehensive desirability of the population in the current round based on the comprehensive desirability function value of each candidate solution in the population.
[0092] The overall comprehensive desirability is the arithmetic mean of the comprehensive desirability function values of each candidate solution in the population. Specifically, the overall weight of the population can be represented by a k-dimensional vector, and the overall comprehensive desirability can be a scalar.
[0093] S102: Calculate the difference between the overall comprehensive desirability of the population in the current round and the previous round.
[0094] The difference is obtained by subtracting the overall comprehensive desirability of the current round from the overall comprehensive desirability of the previous round.
[0095] S103: Calculate the weight adjustment amount according to the difference.
[0096] Specifically, w i Adjustment amount Δw i It can be expressed as:
[0097]
[0098] Among them, α is the first learning rate, is the comprehensive desirability function for w i The derivative of , ΔD is the difference between the overall comprehensive desirability of the current round and the previous round.
[0099] S104: Update the weight using the weight adjustment amount.
[0100] Since the weights need to sum to 1, they need to be normalized. The update process can be specifically expressed by the following formula, where ← represents assignment.
[0101] w i ←w i +Δw i
[0102]
[0103] Specifically, the weight tensor and the weight adjustment tensor are both k-dimensional vectors. After calculating the two using tensor addition, they are normalized and then assigned to the weight tensor.
[0104] There are three ways to update the power index, which are described below with examples.
[0105] like Figure 4 As shown, in a specific embodiment of the present application, updating the power index may specifically include the following parts.
[0106] S111: Calculate the response statistics of the response function according to the response function value of each candidate solution in the population.
[0107] The response statistic is the variance or standard deviation of the corresponding response function values of each candidate solution. For a certain response function, the response function values obtained by substituting each candidate solution in the population into the response function form an array, and the variance or standard deviation of the array is calculated as the response statistic of the response function.
[0108] You can use existing functions to calculate response statistics, for example, you can directly use torch.var(dim=1) to calculate the variance of each response function, and / or directly use torch.std(dim=1) to calculate the standard deviation of each response function. The calculated response statistics are vector tensors of size k, where each element corresponds to the variance or standard deviation of a response function.
[0109] S112: Calculate the power exponent adjustment amount according to the response statistics.
[0110] Specifically, the adjustment amount Δp of p can be expressed as:
[0111]
[0112] Among them, β is the second learning rate, σ i is the response statistic of the ith response function, k is the total number of response functions, σ target is the target statistic.
[0113] S113: Update the power exponent using the power exponent adjustment amount.
[0114] The power exponent does not need to be normalized, and the update can be specifically expressed by the following formula, where ← represents assignment.
[0115] p i ←p i +Δp i
[0116] Specifically, the power exponent and its adjustment amount are both scalars and do not need to be normalized.
[0117] like Figure 5 As shown, in another specific embodiment of the present application, updating the power index may specifically include the following parts.
[0118] S121: Calculate the overall comprehensive desirability of the population in the current round based on the comprehensive desirability function value of each candidate solution in the population.
[0119] The overall comprehensive desirability is the arithmetic mean of the comprehensive desirability function values of each candidate solution in the population.
[0120] S122: Calculate the difference between the overall comprehensive desirability of the population in the current round and the previous round.
[0121] The difference is obtained by subtracting the overall comprehensive desirability of the current round from the overall comprehensive desirability of the previous round.
[0122] S123: Update the power exponent according to the difference.
[0123] The goal of updating the power index is to continuously improve the overall comprehensive desirability of the population by adjusting the power index, thereby increasing the difference.
[0124] Specifically, the adjustment of the power index is positively correlated with the difference. When the difference between the overall comprehensive desirability of the current round and the previous round increases, it means that the optimization process has made good progress. At this time, the value of the power index should be increased to strengthen its influence on the desirability function and further promote the optimization of the solution. If the difference decreases, it means that the optimization progress slows down, and the power index should be reduced to reduce the influence on the comprehensive desirability and avoid over-reliance on the current weight configuration.
[0125] In addition, the power exponent can be dynamically adjusted according to the size of the difference. The size of the power exponent adjustment is proportional to the change in the difference. That is, the more significant the difference change, the larger the adjustment of the power exponent can be; conversely, the adjustment amount can be appropriately reduced to ensure smooth and rhythmic updates.
[0126] Specifically, the power exponent and its adjustment amount are both scalars and do not need to be normalized.
[0127] In another specific embodiment of the present application, the power exponent can be updated using reinforcement learning (e.g., Q learning). For example, the optimization process can be modeled as a Markov decision process (MDP), where the state is the current comprehensive target performance, which can be calculated based on the response function value and the weight, the action is to adjust p, specifically including increasing and decreasing p, and the reward function is the improvement of the comprehensive desirability function value. The Q value table is iteratively updated through Q learning to select the optimal p value adjustment strategy. The Q value table (i.e., Q table) can be represented as a tensor.
[0128] At the beginning of Q-learning, the power exponential adjustment problem is modeled as an MDP and the Q-value table is initialized. Assuming there are Ns discrete states and Na possible actions, the Q-value table can be represented by a tensor of size Ns×Na.
[0129] In the iterative process of Q learning, firstly, an action a is selected from the Q table according to the current state s. The commonly used strategy is the ε-greedy strategy, that is, an action is randomly selected with a probability of ε, and the action that maximizes the current Q value is selected with a probability of 1-ε; then the selected action a is executed, the power index p is adjusted, and the comprehensive desirability tensor CD is recalculated to obtain a reward, specifically the mean difference between the new and old CDs is used as the reward; then the Q value table is updated according to the Q learning formula. Each adjustment of the power index p is the adjustment made by executing the selected action a.
[0130] To facilitate parallel computing, the states, actions, rewards, and Q-value updates in the Q-learning process can be batched and computed in a tensor-like manner. For example, a combination of multiple candidate solutions can be used as a batch state, a tensorized set of actions, and parallel reward calculations.
[0131] S5: Determine whether the stop condition is met.
[0132] If satisfied, the iterative calculation ends and the process jumps to S16; otherwise, the process jumps to S12.
[0133] The stopping condition may include the number of iterations reaching a set value. In addition, in order to improve the optimization speed, an early stopping mechanism may be introduced, that is, the difference between the optimal fitness of the current round and the previous round of the population (that is, the maximum value of the comprehensive desirability function value of each candidate solution) is calculated. If the difference between the two is continuously less than the preset threshold for a specified number of rounds, it means that the optimal fitness has not been significantly improved for a certain number of rounds, and the early stopping mechanism is triggered to terminate the iteration in advance. The stopping condition corresponding to the early stopping mechanism includes the difference between the optimal fitness of the current round and the previous round of the population being continuously less than the preset threshold for a specified number of rounds.
[0134] S6: Determine the target solution from the excellent solutions.
[0135] Specifically, the one with the largest comprehensive desirability function value can be selected from the excellent solutions, that is, the candidate solution corresponding to the optimal fitness as the target solution.
[0136] Optionally, the excellent solutions can be visualized after principal component analysis technique, and scatter plots and / or surface plots can be drawn for presentation.
[0137] Through the implementation of this embodiment, a population in tensor format is initialized, and the population includes multiple candidate solutions, and each candidate solution includes a set of input parameters; tensor calculation is used to obtain the response function value, desirability function value and comprehensive desirability function value of each candidate solution in the population; tensor calculation is used to update the population according to the comprehensive desirability function value of the population, and the update operation includes retaining excellent solutions, mixing and adjusting, and the excellent solution is the candidate solution with the largest specified number or proportion of comprehensive desirability function values in the population; tensor calculation is repeatedly used to obtain the response function value, desirability function value and comprehensive desirability function value of each candidate solution in the population, as well as the subsequent steps, until the stop condition is met. Using tensors to complete the calculation of the genetic algorithm, replacing the calculation of each individual in the population with the overall calculation of the population tensor, significantly improves the calculation efficiency of the algorithm. In addition, tensor calculations can be performed in parallel on a graphics processor to further improve the solution efficiency.
[0138] Figure 6A schematic structural diagram of an optimization solution device based on a genetic algorithm provided in an embodiment of the present application is shown. The optimization solution device based on a genetic algorithm includes an initialization module 11 and an iteration module 12.
[0139] The initialization module 11 is used to initialize a population in a tensor format, wherein the population includes a plurality of candidate solutions, and each candidate solution includes a set of input parameters.
[0140] Iteration module 12 is used to iteratively optimize the population using tensor calculation until the stopping condition is met. Each round of iterative optimization includes: using tensor calculation to obtain the response function value, desirability function value and comprehensive desirability function value of each candidate solution in the population; using tensor calculation to update the population according to the comprehensive desirability function value of the population, and the update operation includes retaining excellent solutions, mixing and adjusting, and the excellent solution is the candidate solution with the largest specified number or proportion of comprehensive desirability function values in the population.
[0141] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / modules / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0142] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0143] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0144] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0145] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / electronic device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0146] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0147] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0148] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0149] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0150] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An optimization solution method based on genetic algorithm, characterized in that: The method comprises: Initializing a population in a tensor format, the population including a plurality of candidate solutions, each candidate solution including a set of input parameters; Using tensor calculation to obtain the response function value, desirability function value and comprehensive desirability function value of each candidate solution in the population; Using tensor calculation to perform an update operation on the population according to the comprehensive desirability function value of the population, the update operation includes retaining excellent solutions, mixing and adjusting, the excellent solutions are the candidate solutions with the largest specified number or proportion of the comprehensive desirability function values in the population; Repeat the steps of using tensor calculation to obtain the response function value, desirability function value and comprehensive desirability function value of each candidate solution in the population and subsequent steps until a stopping condition is met.
2. The method according to claim 1, characterized in that The method of using tensor calculation to obtain the response function value, desirability function value and comprehensive desirability function value of each candidate solution in the population includes: Substituting each of the candidate solutions into a response function to obtain a response value tensor composed of response function values of each of the candidate solutions; Substituting each of the response function values in the response value tensor into the desirability function to obtain a desirability value tensor composed of the desirability function values of each of the candidate solutions; Substitute the desirability function value of each candidate solution in the desirability value tensor into the comprehensive desirability function to obtain a comprehensive desirability tensor composed of the comprehensive desirability function values of each candidate solution.
3. The method according to claim 2, characterized in that The operation of updating the population according to the comprehensive desirability function value of the population by using tensor calculation includes: Using a maximum return function on the comprehensive desirability tensor to determine the excellent solution; The excellent solutions are retained without being affected by mixing and adjusting.
4. The method according to claim 2, characterized in that The operation of updating the population according to the comprehensive desirability function value of the population by using tensor calculation includes: The population is adjusted based on random selection and tensorization functions.
5. The method according to any one of claims 2 to 4, characterized in that: The comprehensive desirability function is a weighted power average of the desirability functions. After the tensor calculation is used to obtain the response function value, desirability function value and comprehensive desirability function value of each candidate solution in the population, the following steps are further included: The weights and / or power exponents in the comprehensive desirability function are updated.
6. The method according to claim 5, characterized in that The updating of the weight in the comprehensive desirability function comprises: Calculating the overall comprehensive desirability of the population in the current round according to the comprehensive desirability function value of each candidate solution in the population; Calculating the difference between the overall comprehensive desirability of the population in the current round and the previous round; Calculate a weight adjustment amount according to the difference; The weight is updated using the weight adjustment amount.
7. The method according to claim 5, characterized in that The updating of the power index in the comprehensive desirability function comprises: Calculate the response statistic of the response function according to the response function value of each candidate solution in the population, wherein the response statistic is the variance or standard deviation of the corresponding response function value of each candidate solution; Calculating a power exponent adjustment amount according to the response statistic; The power exponent is updated using the power exponent adjustment amount.
8. The method according to claim 5, characterized in that The updating of the power index in the comprehensive desirability function comprises: Calculating the overall comprehensive desirability of the population in the current round according to the comprehensive desirability function value of each candidate solution in the population; Calculating the difference between the overall comprehensive desirability of the population in the current round and the previous round; The power exponent is updated according to the difference.
9. The method according to claim 5, characterized in that The updating of the power index in the comprehensive desirability function comprises: The power exponent is updated using reinforcement learning.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable by the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Cable dome structure optimization method and system based on genetic algorithm
CN118673769A