Artificial intelligence-based adaptive procedural generation method, agent and electronic device
By dynamically adjusting temperature parameters and selecting parent programs, the balance between exploration and utilization during program generation is resolved, enabling the generation of diverse and high-performance programs.
Patent Information
- Application Number
- CN202511430734.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-09
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2045-10-09
AI Technical Summary
Existing technologies struggle to balance exploration and utilization during program generation, resulting in insufficient diversity and performance of generated programs.
By determining the diversity information of the target population, dynamically adjusting the temperature parameters, selecting the first parent program and its corresponding second parent program, and performing evolutionary iterations, the target program is generated.
It improves the ability to balance exploration and utilization during the evolution process, generating diverse and high-performance programs.
Smart Images

Figure CN120909564B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, especially to the field of artificial intelligence such as deep learning, large models, agents, coding agents, and auxiliary programming, and specifically relates to an adaptive program generation method based on artificial intelligence, an agent, an electronic device, and a storage medium. BACKGROUND
[0002] Evolutionary algorithms are a class of optimization algorithms inspired by biological evolution theory, which search for optimal or approximate optimal solutions in the solution space by simulating mechanisms such as natural selection, genetic, and mutation. Evolutionary algorithms have been widely applied in fields such as engineering design, bioinformatics, artificial intelligence, etc. For example, in the field of artificial intelligence, they can be applied to program generation, scientific computing model optimization, etc. SUMMARY
[0003] The present application provides an adaptive program generation method based on artificial intelligence, an agent, an electronic device, and a storage medium. The specific solutions are as follows:
[0004] According to an aspect of the present application, an adaptive program generation method based on artificial intelligence is provided, comprising:
[0005] determining diversity information of a target population; wherein the diversity information is used to indicate program diversity of the target population;
[0006] determining a temperature parameter according to the diversity information; wherein the temperature parameter is used to adjust selection pressure;
[0007] selecting a first parent program and a second parent program corresponding to the first parent program from the target population according to the temperature parameter;
[0008] performing evolutionary iteration according to the first parent program and the second parent program to obtain a target program.
[0009] According to another aspect of the present application, an agent is provided, comprising:
[0010] a first determining module configured to determine diversity information of a target population; wherein the diversity information is used to indicate program diversity of the target population;
[0011] a second determining module configured to determine a temperature parameter according to the diversity information; wherein the temperature parameter is used to adjust selection pressure;
[0012] a selection module configured to select a first parent program and a second parent program corresponding to the first parent program from the target population according to the temperature parameter;
[0013] generating module configured to perform evolutionary iteration on the target population according to the first parent program and the second parent program to obtain a target program.
[0014] According to another aspect of the present application, an electronic device is provided, comprising:
[0015] at least one processor; and
[0016] a memory connected to the at least one processor in communication; wherein,
[0017] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the above embodiments.
[0018] According to another aspect of the present application, a non-transitory computer readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to perform the method described in the above embodiments.
[0019] According to another aspect of the present application, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method described in the above embodiments.
[0020] The artificial intelligence-based adaptive program generation method, agent, electronic device and storage medium provided by the embodiments of the present application determine the diversity information of the target population, determine the temperature parameter according to the diversity information, select the first parent program and the corresponding second parent program from the target population according to the temperature parameter, and perform evolutionary iteration on the target population according to the first parent program and the second parent program to obtain a target program. Therefore, in the process of evolutionary iteration, the temperature parameter can be dynamically adjusted according to the diversity information of the population, the matching degree of the temperature parameter and the program diversity of the population can be improved, the parent program can be adaptively selected based on the temperature parameter, the balance ability of exploration and utilization in the evolutionary process can be improved, and thus the diversified and high-performance program can be efficiently generated.
[0021] It should be understood that the contents described in this part are not intended to identify the key or important features of the embodiments of the present application, nor are they used to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0022] The accompanying drawings are used to better understand the present application and do not limit the present application. Among them:
[0023] Figure 1 A flowchart of an artificial intelligence-based adaptive program generation method according to an embodiment of the present application is provided;
[0024] Figure 2 A flowchart of an artificial intelligence-based adaptive program generation method provided for another embodiment of the present application is shown in FIG. 5.
[0025] Figure 3 A flowchart of an artificial intelligence-based adaptive program generation method provided for another embodiment of the present application is shown in FIG. 5.
[0026] Figure 4 A flowchart of an artificial intelligence-based adaptive program generation method provided for another embodiment of the present application is shown in FIG. 5.
[0027] Figure 5 A structural diagram of an agent provided for an embodiment of the present application is shown in FIG. 6.
[0028] Figure 6 A block diagram of an electronic device for implementing the artificial intelligence-based adaptive program generation method of the embodiments of the present application is shown in FIG. 7. DETAILED DESCRIPTION
[0029] The exemplary embodiments of the present application are described below with reference to the accompanying drawings, which include various details of the embodiments of the present application to assist in understanding, and should be considered as merely exemplary. Thus, those of ordinary skill in the art will recognize various changes and modifications of the embodiments described herein, without departing from the scope and spirit of the present application. Also, for the sake of brevity and clarity, descriptions of well-known functions and constructions are omitted from the following description.
[0030] It should be noted that the acquisition, storage, use, processing, etc. of data in the technical solutions of the present application comply with relevant provisions of national laws and regulations, and do not violate public order and good customs.
[0031] The artificial intelligence-based adaptive program generation method, agent, electronic device and storage medium of the embodiments of the present application are described below with reference to the accompanying drawings.
[0032] Figure 1 A flowchart of an artificial intelligence-based adaptive program generation method provided for an embodiment of the present application is shown in FIG. 4.
[0033] The artificial intelligence-based adaptive program generation method of the embodiments of the present application can be executed by the agent of the embodiments of the present application, which can be configured in an electronic device.
[0034] The electronic device can be any device with computing capability, such as a personal computer, a mobile terminal, a server, etc., and the mobile terminal can be a vehicle-mounted device, a mobile phone, a tablet computer, a personal digital assistant, a wearable device, etc. with various operating systems, touch screens and / or display screens.
[0035] As shown in FIG. 7, the electronic device can include a processor 710, a memory 720, a communication interface 730, a display 740, a touch screen 750, and a power supply 760. Figure 1As shown, the artificial intelligence-based adaptive program generation method includes:
[0036] In step 101, the diversity information of the target population is determined.
[0037] In this application, for a target problem in a target field, a batch of programs can be randomly or using a large model to generate at least one initial population, and each initial population is evolved iteratively to select programs for solving the target problem from the population at the end of evolution.
[0038] For example, the target field can be the field of automated algorithm discovery, or the field of scientific computing model optimization, or the field of autonomous driving strategy optimization, or the field of generative AI (Artificial Intelligence), or other fields, which are not limited.
[0039] Wherein, the target problem can be a problem in the target field that can be solved by a program.
[0040] For example, the target field is automated algorithm discovery, and a researcher wants to automatically discover a new and efficient algorithm for a specific problem (such as community discovery on large-scale graph data).
[0041] In this application, during each evolution iteration, the diversity information of the current target population can be determined.
[0042] For example, the target population can be any population corresponding to the target problem, and the target population can include at least one program, and the diversity information can be used to indicate the diversity of the programs in the target population. In addition, in order to facilitate distinction, the programs belonging to the target population can be referred to as first candidate programs.
[0043] For example, the diversity information can include diversity indicators, diversity levels, etc. The diversity indicator can be a numerical value, and the diversity indicator of the target population can be used to indicate the diversity of the programs in the target population, such as the greater the diversity indicator, the higher the diversity of the programs in the target population; the diversity level of the target population can also be used to indicate the diversity of the programs in the target population, such as the higher the diversity level, the higher the diversity of the programs in the target population.
[0044] For example, the diversity information of the programs in the target population can be determined according to the similarity between the first candidate programs in the target population.
[0045] For example, if the target population is multiple, the diversity information of each target population can be determined separately.
[0046] It can be understood that the target population can be one or more, which is not limited in this application.
[0047] At step 102, a temperature parameter is determined according to the diversity information.
[0048] The temperature parameter can be used to adjust the selection pressure. For example, the greater the temperature parameter, the more inclined to explore, and the smaller the temperature parameter, the more inclined to exploit.
[0049] In this application, the temperature parameter can be determined according to the diversity information and the current evolution iteration number.
[0050] For example, the current evolution iteration number can be used to introduce an annealing mechanism, and the current temperature parameter can be determined according to the diversity information and the annealing mechanism.
[0051] For example, as the evolution iteration number increases, the temperature parameter decreases, and in the later evolution iteration, it tends to exploit. When the program diversity of the target population is high, the temperature parameter can be reduced according to the diversity information, which can promote exploitation. When the program diversity is low, the temperature parameter can be increased according to the diversity information to enhance randomness and encourage exploration.
[0052] At step 103, a first parent program and a second parent program corresponding to the first parent program are selected from the target population according to the temperature parameter.
[0053] In this application, the selection probability of the first candidate program in the target population can be determined according to the temperature parameter, and the first parent program can be selected from the first candidate program according to the selection probability, and the second parent program can be selected for the first parent program from the first candidate program.
[0054] For example, the selection probability of the first candidate program can be determined according to the fitness of the first candidate program and the temperature parameter. The fitness of the first candidate program can be calculated by using the target function defined for the target problem.
[0055] For example, the target field is automatic driving strategy optimization, and a logical program for controlling the vehicle to avoid obstacles and path planning is to be generated. The target function can be safety, stability, and traffic efficiency in the automatic driving simulation environment.
[0056] At step 104, evolution iteration is performed according to the first parent program and the second parent program to obtain the target program.
[0057] In the present application, the first parent program and the second parent program can be subjected to cross mutation operation to generate offspring programs, the offspring programs are used to replace the first candidate programs with low fitness in the target population to obtain a new population, if the evolution iteration stop condition is not met, the new population can be used as the target population for the next evolution iteration until the evolution iteration stop condition is met, and the final population is obtained, and the target program is selected from the final population.
[0058] For example, if the offspring program is one, the offspring program can replace the first candidate program with the lowest fitness in the target population, if the offspring program is multiple, the multiple offspring programs can replace the first candidate programs with the lowest fitness in the target population in the same number as the number of offspring programs. It can be seen that the number of programs in the new population can be the same as the number of programs in the target program.
[0059] For example, the evolution iteration stop condition can be reaching a preset iteration number, or finding a solution that meets the performance requirement, or other conditions, which are not limited in the present application.
[0060] For example, the number of target populations is 5, evolution iteration is performed for each target population, when the evolution iteration stop condition is met, 5 populations are finally obtained, the program with the highest fitness can be selected from the final 5 populations as the target program, or the program with the highest fitness is selected from each population, so that the selected 5 programs are used as the target program, etc.
[0061] It should be noted that the above method of selecting the target program is only an example, which can be selected according to actual needs, and the present application is not limited thereto.
[0062] As an application example, the artificial intelligence-based adaptive program generation method of the present application can be applied to AI-driven research agents, such as automated algorithm discovery, scientific computing model optimization, etc., and can also be applied to automated software development, such as code generation, code optimization and automatic program repair, and can also be applied to generative AI fields, such as AI-generated art, complex system design, etc., or other scenarios that require evolution iteration to seek innovative solutions.
[0063] In the embodiments of the present application, the diversity information of the target population is determined, the temperature parameter is determined according to the diversity information, the first parent program and the corresponding second parent program are selected from the target population according to the temperature parameter, and the target population is evolved and iterated according to the first parent program and the second parent program to obtain the target program. Therefore, in the process of evolution iteration, the temperature parameter can be dynamically adjusted according to the diversity information of the population, the matching degree of the temperature parameter and the program diversity of the population can be improved, so that the parent program can be adaptively selected based on the temperature parameter, the balance ability of exploration and utilization of the evolution process can be improved, and then the diversified and high-performance program can be efficiently generated.
[0064] Figure 2 The flowchart of the artificial intelligence-based adaptive program generation method provided for another embodiment of the present application is shown.
[0065] As Figure 2 shown, the artificial intelligence-based adaptive program generation method includes:
[0066] Step 201: performing feature extraction on the first candidate program in the target population to obtain a first embedding vector.
[0067] The first embedding vector can be used to represent the syntax and semantic structure of the first candidate program.
[0068] In the present application, for any first candidate program in the target population, the key features of the first candidate program code itself can be extracted using a large model to generate a first embedding vector representing its syntax and semantic structure.
[0069] Step 202: performing formal conversion processing on the first candidate program to obtain a conversion result.
[0070] For example, the formal conversion processing can include but is not limited to pseudo code conversion, structured form conversion, etc. The pseudo code conversion is used to convert the program code into pseudo code, and the structured form conversion is used to convert the program into a structured representation.
[0071] In order to further improve the accuracy of program representation, in some embodiments, the first candidate program can be parsed to obtain code feature information of the first candidate program, and the first candidate program can be converted into pseudo code describing the functional intent of the first candidate program according to the code feature information, and the conversion result can be obtained according to the pseudo code.
[0072] For example, the code feature information can include but is not limited to the functional intent, target, structure, control flow, etc. of the code of the first candidate program.
[0073] For example, the pseudo code of the first candidate program can be generated using a large model according to the code feature information.
[0074] Exemplarily, the conversion result can include the pseudo code of the first candidate program, or can include other forms of conversion results, which are not limited.
[0075] Thus, by parsing the first candidate program, converting the first candidate program into the pseudo code based on the parsed code feature information, and performing feature extraction on the conversion result including the pseudo code, the program characteristics can be captured from the abstract logical level.
[0076] In some embodiments, the first candidate program can be parsed to obtain a structured representation of the first candidate program, and the conversion result can be obtained according to the structured representation.
[0077] Exemplarily, the structured representation can include, but is not limited to, an abstract syntax tree, a control flow graph, etc.
[0078] Exemplarily, the conversion result can include the structured representation of the first candidate program, or can include other forms of conversion results, which are not limited.
[0079] Thus, by parsing the first candidate program into the structured representation, the program characteristics can be captured from the structural level.
[0080] Optionally, the first candidate program can be processed by using any one of the two forms of conversion processing methods.
[0081] Optionally, the first candidate program can be processed by using the two forms of conversion processing methods respectively, and the conversion result can include the pseudo code and the structured representation of the first candidate program.
[0082] Step 203, performing feature extraction on the conversion result to obtain a second embedding vector.
[0083] In this application, according to the type of the conversion result, the corresponding feature extraction method can be used to perform feature extraction on the conversion result to obtain the second embedding vector.
[0084] In some embodiments, if the conversion result includes the pseudo code of the first candidate program, the pseudo code can be subjected to feature extraction to obtain the second embedding vector. The second embedding vector can be used to represent the program characteristics of the first candidate program at the abstract logical level.
[0085] In some embodiments, if the conversion result includes the structured representation of the first candidate program, the structured representation can be subjected to feature extraction by using a GNN (Graph Neural Network) to obtain the second embedding vector. The second embedding vector can be used to represent the program characteristics of the first candidate program at the structural level.
[0086] In some embodiments, if the pseudo code, structured representation, etc. of the first candidate program is included in the conversion result, feature extraction can be performed on the pseudo code and the structured representation respectively, and the extracted feature vectors can be fused to obtain the second embedding vector.
[0087] Step 204, the first embedding vector and the second embedding vector are fused to obtain a fusion representation vector.
[0088] In this application, the first embedding vector and the second embedding vector can be fused by splicing or weighted average to obtain the fusion representation vector of the first candidate program.
[0089] For example, the second embedding vector is obtained by feature extraction on the pseudo code of the first candidate program, and the fusion of the first embedding vector and the second embedding vector can obtain a fusion representation vector that can reflect the program code level and the functional intention level.
[0090] Step 205, obtaining diversity information according to the fusion representation vector.
[0091] In this application, the cosine distance between each pair of first candidate programs can be determined according to the fusion representation vector of each pair of first candidate programs in the target population, the average cosine distance between the first candidate programs in the target population can be determined according to the average value of the cosine distance between each pair of first candidate programs in the target population, and the diversity information of the target population can be obtained according to the average cosine distance. Thus, based on the fusion representation vector of the first candidate program, the average cosine distance between the first candidate programs can be calculated, which can improve the accuracy of the calculation and further improve the accuracy of the diversity information.
[0092] Wherein, the greater the average cosine distance, the higher the diversity of the programs in the target population.
[0093] For example, the average cosine distance can be used as a diversity index, and the diversity information can be obtained according to the diversity index. Wherein, the diversity index can be a numerical value, and the diversity index can be used to represent the diversity of the programs in the target population.
[0094] In order to further enhance the robustness of the measurement, the auxiliary features of the target population can be obtained, the average cosine distance and the auxiliary features can be fused to obtain the diversity index. Here the diversity index can be a comprehensive function of the core measurement and the auxiliary measurement reflecting the distribution, such as a weighted combination, so as to obtain a multi-dimensional and high-fidelity diversity index.
[0095] Exemplarily, the auxiliary features can include, but are not limited to, a code length of the first candidate program, a fitness of the first candidate program, an average edit distance between the first candidate programs, and the like.
[0096] Exemplarily, the edit distance between each two of the first candidate programs in the target population can be calculated, and the average edit distance between the first candidate programs in the target population can be determined according to an average value of the edit distances between each two of the first candidate programs in the target population.
[0097] The edit distance between each two of the first candidate programs can be used to measure the difference between the codes of the two first candidate programs.
[0098] Therefore, according to the average cosine distance, the code length of the introduced program, the fitness of the program, the average edit distance of the population, and the like are combined to perform multi-dimensional characterization on the program, which can improve the accuracy and robustness of the diversity measurement.
[0099] In step 206, a temperature parameter is determined according to the diversity information.
[0100] In step 207, a first parent program and a second parent program corresponding to the first parent program are selected from the target population according to the temperature parameter.
[0101] In the present application, steps 206-207 can refer to any one of the implementation manners of the embodiments of the present application, and thus will not be described here.
[0102] In step 208, an evolutionary iteration is performed according to the first parent program and the second parent program to obtain a target program.
[0103] In some embodiments, a large model is used to perform cross-over and mutation operations on the first parent program and the second parent program to generate a child program, and then an evolutionary iteration is performed according to the child program to obtain the target program. The process of performing the evolutionary iteration according to the child program can refer to the above embodiments, and thus will not be described here.
[0104] Exemplarily, a prompt template can be obtained, the prompt template can include program generation task information, and the prompt template is filled according to the first parent program and the second parent program to obtain prompt information, and then a large model is used to perform cross-over and mutation operations according to the prompt information to generate a child program.
[0105] The program generation task information is used to instruct the large model to perform a program generation task.
[0106] Exemplarily, the program generation task information can include, but is not limited to, a program generation task, a program generation requirement, and the like.
[0107] For example, the prompt template can further include program output requirements, program generation examples, etc. The program output requirements can include output format requirements, program quantity requirements, etc.
[0108] For example, the prompt information can be "analyze the advantages and disadvantages of the two programs, and create a new program with better performance based on them".
[0109] Therefore, by using a large model to perform crossover and mutation operations on the selected parent programs to generate new child programs, the mutation direction can be controlled, the quality of the child programs can be improved, and the evolution iteration efficiency can be improved.
[0110] In the embodiments of the present application, by performing feature extraction on the first candidate program in the target population, an embedding vector representing the syntax and semantic structure of the program is obtained, and the first candidate program is processed by form conversion. The embedding vector corresponding to the other program form is obtained by performing feature extraction on the converted result. The two kinds of embedding vectors are fused to obtain a multi-dimensional representation vector, which improves the accuracy of program representation.
[0111] Figure 3 The flowchart of the adaptive program generation method based on artificial intelligence provided by another embodiment of the present application is shown.
[0112] As shown in Figure 3 The adaptive program generation method based on artificial intelligence includes the following steps:
[0113] Step 301: Determine the diversity information of the target population.
[0114] In the present application, step 301 can refer to any one of the implementation modes of the embodiments of the present application, and therefore will not be described here.
[0115] Step 302: Perform modulo operation on the first value according to the current evolution iteration number to obtain a second value.
[0116] The difference between the first value and the total evolution iteration number can be greater than a preset threshold, and the first value can be considered as a hyperparameter much larger than the total evolution iteration number.
[0117] Step 303: Determine the temperature parameter according to the ratio between the second value and the first value and the diversity index.
[0118] In the related art, the temperature parameter is usually determined only according to the evolution iteration number. However, when the population diversity is relatively low, the search effort may not be increased in time, and when the diversity is high, the current high fitness individual cannot be fully utilized, so that the balance between exploration and utilization is poor.
[0119] Based on this, in this application, the diversity information of the target population may include the diversity index of the target population, and the temperature parameter can be determined based on the ratio between the second value and the first value, combined with the diversity index.
[0120] In some embodiments, a first difference between the target value and the diversity index can be determined, and a third value can be determined as the base and a fourth value as the index of the first difference. A second difference between the target value and the ratio can be determined, and the temperature parameter can be determined based on the product of the second difference and the fourth value.
[0121] For example, the target value can be equal to 1, or it can be any other value, without limitation.
[0122] For example, the first difference can be obtained by subtracting the diversity index from the target value.
[0123] For example, the third value can be a value greater than 1.
[0124] For example, the product of the second difference and the fourth value can be used as the temperature parameter.
[0125] To further improve the accuracy of temperature parameters, for example, an initial temperature value for controlling the randomness of selection can be set, and the product of the initial temperature value for controlling the randomness of selection, the second difference, and the fourth value can be used as the temperature parameter.
[0126] As an example, with a target value of 1 and the third base value as... For example, the temperature parameters of the target population can be calculated using the following formula (1):
[0127] (1)
[0128] in, It is a temperature parameter; It controls the initial temperature value to determine the randomness of the selection; n It is the current evolution iteration number; It is the first value, used to smooth the evolution process; Indicates based on the current evolution iteration number n For the first value Take the mold; It is a diversity indicator of the target population.
[0129] In the above formula (1), the term is... The simulated annealing process was simulated, and the number of evolution iterations was as follows. n As the value of increases, it gradually approaches 0 from 1, naturally favoring exploitation in the later stages of evolution; for the term When the population diversity is high, the value is reduced, and the temperature parameter is reduced to promote exploitation, and when the diversity is low, the value is increased, and the temperature parameter is increased to enhance randomness and encourage exploration, thereby effectively breaking premature convergence.
[0130] Thus, while the temperature parameter decays with the increase of the number of evolution iterations, the temperature parameter is dynamically adjusted by an exponential function according to the diversity index, so that the temperature parameter can be reduced to promote exploitation when the diversity is high, and the temperature parameter can be increased to encourage exploration when the diversity is low, thereby achieving a dynamic balance between exploration and exploitation in the evolution process.
[0131] In step 304, a first parent program and a second parent program corresponding to the first parent program are selected from the target population according to the temperature parameter.
[0132] In step 305, evolution iterations are performed according to the first parent program and the second parent program to obtain the target program.
[0133] In this application, steps 304-305 can refer to any one of the implementation modes of the embodiments of the application, and therefore will not be described here.
[0134] In the embodiments of the application, the temperature parameter is determined according to the current number of evolution iterations, the ratio between the second value obtained by taking the modulus of the first value and the first value much larger than the total number of evolution iterations, and the diversity index of the target population. Thus, by determining the temperature parameter through the ratio combined with the diversity index of the target population, the temperature parameter can not only decay with the increase of the number of evolution iterations, so that the selection is biased towards exploitation in the later stage, but also the adaptability of the temperature parameter is improved by adjusting the temperature parameter through the diversity index of the target population, which can improve the balance ability of exploration and exploitation in the evolution process.
[0135] Figure 4 The flowchart of the artificial intelligence-based adaptive program generation method provided by another embodiment of the application is shown.
[0136] As shown in Figure 4 The artificial intelligence-based adaptive program generation method comprises the following steps:
[0137] In step 401, the diversity information of the target population is determined.
[0138] In step 402, the temperature parameter is determined according to the diversity information.
[0139] In this application, steps 401-402 can refer to any one of the implementation modes of the embodiments of the application, and therefore will not be described here.
[0140] Step 403, determining a target cluster from the at least one cluster of the target population according to the temperature parameter.
[0141] In the present application, the target population can include at least one cluster, and each cluster can include at least one program. In addition, for the convenience of distinction, the programs belonging to one cluster can be referred to as second candidate programs.
[0142] In some embodiments, for any cluster in the at least one cluster, a performance score of the any cluster can be determined, and then the target cluster can be selected from the at least one cluster of the target population according to the performance scores of the at least one cluster.
[0143] The performance score of the any cluster can be used to measure the relationship between the program quality and the cluster size of the any cluster.
[0144] For example, the performance score of the any cluster can be determined according to the fitness of the second candidate programs in the any cluster and the number of the second candidate programs in the any cluster, and then the selection probability of the any cluster can be determined according to the temperature parameter and the performance score, and then the target cluster can be selected from the at least one cluster of the target population according to the selection probabilities of the at least one cluster.
[0145] For example, the average fitness of the second candidate programs in the any cluster can be calculated according to the fitness of the second candidate programs in the any cluster, and the performance score can be determined as the ratio between the average fitness and the number of the second candidate programs in the any cluster.
[0146] For example, the maximum fitness of the second candidate programs can also be determined, and the performance score can be determined according to the ratio between the maximum fitness and the number of the second candidate programs. For example, the ratio between the maximum fitness and the number of the second candidate programs can be determined as the performance score.
[0147] For example, the performance score of each cluster can be calculated according to the following formula (2):
[0148] (2)
[0149] wherein, is the performance score of the cluster ; is the fitness of the second candidate program in the cluster p ; denotes the size of the cluster , i.e. the number of the second candidate programs in the cluster .
[0150] Thus, the selection of the cluster containing the program with high performance can be encouraged by the numerator, i.e., the maximum fitness, and the monopoly of large cluster can be restrained by the denominator, i.e., the number of the second candidate programs, so that the small cluster representing the novel direction can be given the opportunity, thereby achieving the purpose of selecting the cluster with less exploration times and high performance score.
[0151] Exemplarily, the selection probability of any cluster can be determined according to the temperature parameter and the performance score by an exponential function.
[0152] As an example, the selection probability of each cluster can be calculated by the following formula (3):
[0153] (3)
[0154] wherein, is the selection probability of the cluster ; is the performance score of the cluster ; is the performance score of the cluster ; and T is the temperature parameter for adjusting the selection pressure. In the formula (3), when the value of T is high, the probability distribution tends to be uniform, encouraging exploration, and when the value of T is low, the probability distribution tends to be concentrated, encouraging exploitation. Thus, by determining the performance score of any cluster according to the fitness of the second candidate program in the cluster and the number of the second candidate programs in the cluster, and determining the selection probability of the cluster according to the temperature parameter and the performance score, the cluster selection pressure can be dynamically adjusted according to the temperature parameter, and the adaptive selection of the cluster can be achieved.
[0155] Thus, by determining the performance score of any cluster according to the fitness of the second candidate program in the cluster and the number of the second candidate programs in the cluster, and determining the selection probability of the cluster according to the temperature parameter and the performance score, the cluster selection pressure can be dynamically adjusted according to the temperature parameter, and the adaptive selection of the cluster can be achieved.
[0156] In step 404, the first parent program is selected from the target cluster.
[0157] In the present application, the second candidate programs in the target cluster can be sorted in the order from high to low according to the fitness of each second candidate program, and the first parent program can be determined as the second candidate program in the front of the sorted second candidate programs.
[0158] For example, the second candidate program with the highest fitness in the target cluster can be selected as the first parent program.
[0159] Exemplarily, the number of the target clusters can be one or more, and if the number of the target clusters is multiple, the first parent program can be selected from each target cluster, and thus the number of the first parent programs can be one or more, which is not limited.
[0160] Step 405, selecting a second parent program from the target population according to the first parent program.
[0161] In order to continuously improve the quality of programs in the population, in this application, for any first parent program, the target population to which the first parent program belongs can be taken as a candidate pool, and a program suitable for crossing or mutation with the first parent program can be selected from the target population.
[0162] In some embodiments, for any first candidate program in the target population, the cosine distance can be calculated according to the fusion feature vector of the first parent program and the fusion feature vector of the first candidate program, the difference degree between the first parent program and the first candidate program can be determined according to the cosine distance, and the first candidate program with the largest difference degree with the first parent program in the target population can be taken as the second parent program. Wherein, the greater the cosine distance between the programs, the greater the difference degree between the programs.
[0163] In addition, the method for obtaining the fusion feature vector of the first parent program can refer to the method for obtaining the fusion feature vector of the first candidate program in the above-mentioned embodiments, which will not be repeated here.
[0164] In some embodiments, the diversity information of the target population can include a diversity index, for any first candidate program in the target population, the difference degree between the first parent program and the first candidate program can also be determined according to the fusion feature vector of the first parent program and the fusion feature vector of the first candidate program, the first weight of the fitness and the second weight of the difference degree of the first candidate program can be determined according to the diversity index of the target population, the fitness and the difference degree of the first candidate program are weighted according to the first weight and the second weight, the comprehensive score of the first candidate program is obtained, and the second parent program is selected from the target population according to the comprehensive score.
[0165] Wherein, the comprehensive score of the first candidate program can be used to represent the comprehensive information of the first candidate program in quality and difference degree with the first parent program.
[0166] For example, the diversity index can be normalized to obtain a normalized index, the normalized index is determined as the first weight, and the difference value between the target value and the normalized index is determined as the second weight.
[0167] For example, the diversity index can be normalized by the following method: the ratio between the diversity index and the score threshold value can be determined, and the ratio and the minimum value in the target value are taken as the normalized index.
[0168] For example, the score threshold value is t , and the target value is 1, then the normalized index .
[0169] As an example, the comprehensive score of the first candidate program can be calculated by using the following formula (4):
[0170] (4)
[0171] wherein, is the comprehensive score of the first candidate program; is the normalized index; is the fitness of the first candidate program; is the difference between the first candidate program and the first parent program.
[0172] Thus, when the population diversity is high, the weight of the fitness is relatively large, and the high-performance individual is inclined to be selected for utilization, and when the diversity is low, the weight of the difference is relatively large, and the first candidate program different from the first parent program is inclined to be selected to introduce new genes, so as to strengthen the exploration, and the balance between exploration and utilization can be improved.
[0173] As an example, the second parent program can be selected from the target population according to the comprehensive score, which can be implemented in the following manner: the selection probability of any first candidate program can be determined according to the comprehensive score of any first candidate program and the sum of the comprehensive scores of the first candidate programs in the target population, and the second parent program can be selected from the target population according to the selection probability of each first candidate program in the target population.
[0174] As an example, if there are multiple first parent programs, the above scheme can be used to select a second parent program for each first parent program.
[0175] Thus, by determining the weight of the fitness of the first candidate program and the weight of the difference between the first parent program and the first candidate program according to the diversity index, the comprehensive score is dynamically determined by weighting, and the second parent program is screened based on the comprehensive score, so that the second parent program suitable for crossover and mutation can be selected for the first parent program.
[0176] Step 406: evolving iteratively according to the first parent program and the second parent program to obtain a target program.
[0177] In the present application, step 406 can be implemented in any of the embodiments of the present application, and thus will not be described here.
[0178] In some embodiments, the first parent program and the second parent program can be subjected to cross mutation operation to generate a child program, and it is determined to which cluster the child program belongs in the target population, the child program is put into the cluster to replace a program with low fitness in the target population, thereby completing population updating to obtain a new population, if the evolution iteration stop condition is not met, the new population can be used as the target population for the next evolution iteration, until the evolution iteration stop condition is met, and a final population is obtained, and the target program is selected from the final population. The method for generating the child program can be referred to other embodiments, and thus will not be described here.
[0179] For example, after generating the child program each time, it is determined whether the re-clustering condition is met, if the re-clustering condition is not met, the child program is determined to be closest to a cluster in the target population, the child program is put into the cluster to replace a program with low fitness in the target population, and a new population is obtained, if the re-clustering condition is met, the program with low fitness in the target population is removed, and the child program and the remaining programs in the target population are re-clustered to obtain at least one new cluster, thereby completing population updating to obtain a new population.
[0180] For example, the re-clustering condition can be that the number of child programs generated from the last re-clustering to the current time reaches a preset number, or the evolution iteration number reaches a preset number, or other conditions, which are not limited.
[0181] In the embodiments of the present application, the target cluster is adaptively selected from at least one cluster of the target population according to the temperature parameter, and the first parent program is selected from the target cluster, so that the quality of the first parent program can be ensured, and the second parent program is selected according to the first parent program, so that the quality of the second parent program can be improved, and the new child program is generated according to the first parent program and the second parent program, so that the quality of the child program can be improved.
[0182] The artificial intelligence-based adaptive program generation method of the embodiments of the present application can be widely applied to the field of generating solutions through evolution, and the following will be described by taking automatic algorithm discovery as an example:
[0183] Scenario description: A researcher wants to automatically discover a new and efficient algorithm for a specific problem (such as community discovery on large-scale graph data).
[0184] Application process:
[0185] Initialization: The researcher defines the objective function of the problem, that is, the score function, for example, according to the modularity Q value and the calculation efficiency of the algorithm to score. A batch of initial community discovery algorithm programs are randomly generated or generated using a large model as an initial population.
[0186] Evolution iteration starts:
[0187] Evaluation and characterization: Calculate the score for each population, and generate a fusion characterization vector for each program. At the same time, calculate the diversity index of each population.
[0188] Selection: Independently select the first parent program on each population, and select multiple pairs of (first parent program, second parent program).
[0189] Generation: Input the code and analysis of each pair of (first parent program, second parent program) into a large model, and use prompt information to perform "crossing" and "mutation" to generate a new child program. For example, the prompt information can be: "analyze the advantages and disadvantages of the two programs, and create a new program with better performance by combining them".
[0190] Replacement and migration: The newly generated child program is put back into the population to replace the low fitness program in the population. In addition, periodically, individual migration can be performed between populations, that is, the individual with the highest fitness in one population is migrated to another population to promote gene exchange.
[0191] Termination: The evolution iteration is performed until the termination condition is met (such as reaching the predetermined number of generations, finding a solution that meets the performance requirements).
[0192] Final output: A series of high-performance and diverse community discovery algorithms can be selected from the final population for researchers to choose and analyze.
[0193] In the field of automatic driving strategy optimization, the scheme of the present application can be applied to generate logical programs for controlling vehicles to avoid obstacles and path planning through evolution iteration. The objective function can be safety, stability, and traffic efficiency in a simulated environment.
[0194] In the field of game AI design, the scheme of the present application can be applied to generate decision tree or state machine programs for controlling the behavior of game NPCs (Non-Player Characters) through evolution iteration. The objective function can be the win rate in confrontation with players or other AI.
[0195] In addition, the scheme of the present application can also be extended to the field of drug molecule design, generating chemical formulas or structures of molecules through evolution iteration. The objective function can be the binding energy with the target point.
[0196] The artificial intelligence-based adaptive program generation method of the embodiments of the present application has the following beneficial effects:
[0197] (1) Raising the upper limit of problem-solving: By effectively avoiding premature convergence, there is a greater chance to break out of local optima and discover truly groundbreaking novel solutions that human experts may not have thought of.
[0198] (2) Accelerate innovation efficiency: The adaptive selection strategy enables computing resources to be intelligently allocated to the most promising evolution direction. Whether exploring new fields or cultivating advantageous areas, it is more efficient than the fixed strategy and shortens the development cycle of the above-mentioned second-generation program.
[0199] (3) Enhance the diversity of results: A precise diversity measurement and maintenance mechanism can ensure that the final output is a high-quality solution with different styles, providing users with a wider range of choices.
[0200] (4) Improve automation level: Adaptive characteristics reduce the reliance on manual parameter tuning (such as temperature annealing rate) and improve the robustness and automation of evolution iteration.
[0201] To implement the above embodiments, this application also proposes an intelligent agent. Figure 5 This is a schematic diagram of the structure of an intelligent agent provided in an embodiment of this application.
[0202] like Figure 5 As shown, the intelligent agent 500 includes:
[0203] The first determining module 510 is used to determine the diversity information of the target population; wherein the diversity information is used to indicate the program diversity of the target population;
[0204] The second determining module 520 is used to determine temperature parameters based on the diversity information; wherein the temperature parameters are used to adjust the selection pressure.
[0205] Selection module 530 is used to select a first parent program and a second parent program corresponding to the first parent program from the target population according to the temperature parameter.
[0206] The generation module is used to perform evolutionary iterations based on the first parent program and the second parent program to obtain the target program.
[0207] Optionally, the first determining module 510 is used for:
[0208] Feature extraction is performed on the first candidate program in the target population to obtain a first embedding vector; wherein, the first embedding vector is used to characterize the syntax and semantic structure of the first candidate program;
[0209] The first candidate program is subjected to formal transformation to obtain the transformation result;
[0210] perform feature extraction on the conversion result to obtain a second embedding vector;
[0211] fuse the first embedding vector and the second embedding vector to obtain a fusion representation vector;
[0212] obtain the diversity information according to the fusion representation vector.
[0213] Optionally, the first determining module 510 is configured to:
[0214] determine an average cosine distance between the first candidate programs according to the fusion representation vector;
[0215] obtain the diversity information according to the average cosine distance.
[0216] Optionally, the diversity information includes a diversity index, and the first determining module 510 is configured to:
[0217] obtain auxiliary features of the target population; wherein the auxiliary features include one or more of the following: a code length of the first candidate program, a fitness of the first candidate program, and an average edit distance between the first candidate programs;
[0218] fuse the average cosine distance and the auxiliary features to obtain the diversity index.
[0219] Optionally, the first determining module 510 is configured to:
[0220] parse the first candidate program to obtain code feature information of the first candidate program;
[0221] obtain a pseudo code of the first candidate program according to the code feature information;
[0222] obtain the conversion result according to the pseudo code.
[0223] Optionally, the first determining module 510 is configured to:
[0224] parse the first candidate program to obtain a structured representation of the first candidate program;
[0225] obtain the conversion result according to the structured representation.
[0226] Optionally, the diversity information includes a diversity index, and the second determining module 520 is configured to:
[0227] perform modulo operation on a first numerical value according to a current number of evolutionary iterations to obtain a second numerical value; wherein a difference between the first numerical value and a total number of evolutionary iterations is greater than a preset threshold;
[0228] determine the temperature parameter according to a ratio between the second value and the first value and the diversity index.
[0229] Optionally, the second determining module 520 is configured to:
[0230] determine a first difference between a target value and the diversity index;
[0231] determine a fourth value with a third value as a base and the first difference as an exponent;
[0232] determine a second difference between the target value and the ratio;
[0233] determine the temperature parameter according to a product of the second difference and the fourth value.
[0234] Optionally, the selecting module 530 is configured to:
[0235] determine a target cluster from at least one cluster of the target population according to the temperature parameter;
[0236] select the first parent program from the target cluster;
[0237] select the second parent program from the target population according to the first parent program.
[0238] Optionally, the selecting module 530 is configured to:
[0239] for any cluster of the at least one cluster, determine a performance score of the any cluster according to fitness of a second candidate program in the any cluster and a number of the second candidate programs in the any cluster, wherein the performance score is used to measure a relationship between program quality and cluster size of the any cluster;
[0240] determine a selection probability of the any cluster according to the temperature parameter and the performance score;
[0241] select the target cluster from the at least one cluster according to the selection probability.
[0242] Optionally, the selecting module 530 is configured to:
[0243] determine a maximum fitness from the fitness of the second candidate programs;
[0244] determine the performance score according to a ratio between the maximum fitness and the number of the second candidate programs.
[0245] Optionally, the diversity information includes a diversity index, and the selecting module 530 is configured to:
[0246] determine a difference degree between the first parent program and the first candidate program according to the fusion feature vector of the first parent program and a fusion feature vector of the first candidate program in the target population;
[0247] determine a first weight of the fitness of the first candidate program and a second weight of the difference degree according to the diversity index;
[0248] weight the fitness of the first candidate program and the difference degree according to the first weight and the second weight to obtain a comprehensive score of the first candidate program;
[0249] select the second parent program from the target population according to the comprehensive score.
[0250] Optionally, the selection module 530 is configured to normalize the diversity index to obtain a normalized index;
[0251] determine the normalized index as the first weight;
[0252] determine a difference value between a target value and the normalized index as the second weight.
[0253] Optionally, the generation module 540 is configured to:
[0254] perform cross variation operations on the first parent program and the second parent program by using a large model to generate offspring programs;
[0255] perform evolution iterations according to the offspring programs to obtain the target program.
[0256] It should be noted that the foregoing explanation and description of the program generation method embodiment also applies to the agent of the embodiment, and thus will not be described here again.
[0257] In the embodiment of the application, the diversity information of the target population is determined, the temperature parameter is determined according to the diversity information, the first parent program and the corresponding second parent program are selected from the target population according to the temperature parameter, and the target program is obtained by performing evolution iterations on the target population according to the first parent program and the second parent program. Therefore, in the evolution iteration process, the temperature parameter can be dynamically adjusted according to the diversity information of the population, the matching degree of the temperature parameter and the program diversity of the population can be improved, the parent program can be adaptively selected based on the temperature parameter, the balance ability of exploration and utilization of the evolution process can be improved, and thus the diversified and high-performance program can be efficiently generated.
[0258] According to the embodiments of the application, the application further provides an electronic device, a readable storage medium and a computer program product.
[0259] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present application described and / or claimed in this document.
[0260] As shown in FIG. 6, the device 600 includes a computing unit 601 that can perform various suitable actions and processes in accordance with computer programs stored in a ROM (Read-Only Memory) 602 or loaded into a RAM (Random Access Memory) 603 from the storage unit 608. Various programs and data required for the operation of the device 600 can also be stored in the RAM 603. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An I / O (Input / Output) interface 605 is also connected to the bus 604. Figure 6
[0261] Various components in the device 600 are connected to the I / O interface 605, including an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a magnetic disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through computer networks, such as the Internet, and / or various telecommunication networks.
[0262] The computing unit 601 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a CPU (Central Processing Unit), a GPU (Graphic Processing Unit), various special-purpose AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, a DSP (Digital Signal Processor), and any appropriate processor, controller, microcontroller, etc. The computing unit 601 performs various methods and processes described above, such as the AI-based adaptive program generation method. For example, in some embodiments, the AI-based adaptive program generation method can be implemented as a computer software program, which is tangibly embodied in a machine-readable medium, such as the storage unit 608. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded onto the RAM 603 and executed by the computing unit 601, one or more steps of the AI-based adaptive program generation method described above can be performed. Alternatively, in other embodiments, the computing unit 601 can be configured to perform the AI-based adaptive program generation method by other any appropriate means, such as by means of firmware.
[0263] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a Field Programmable Gate Array (FPGA), an Application-Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a System on a Chip (SOC), a Complex Programmable Logic Device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0264] Program code for carrying out methods of the present application can be written in any combination of one or more programming languages. This program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces a means for implementing the functions / acts specified in the flowcharts and / or block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine and partially on a remote machine or entirely on a remote machine or server.
[0265] In the context of this application, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include a linearly-programmed electrical connection, a portable computer diskette, a hard disk, RAM, ROM, EPROM (Electrically Programmable Read-Only-Memory) or Flash memory, an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0266] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0267] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a LAN (local area network), a WAN (wide area network), the Internet, and a blockchain network.
[0268] The computer system can include clients and servers. This relationship can be remote or on-site. The servers can be cloud servers, also known as cloud computing servers or cloud hosts, which are mainframe products in the cloud computing service system to solve the defects of large management difficulty and weak business scalability in traditional physical hosts and VPS services (Virtual Private Server, Virtual Private Server). The server can also be a server of a distributed system or a server combined with a blockchain.
[0269] According to the embodiments of the present application, the present application also provides a computer program product, when the instruction processor in the computer program product executes, executes the artificial intelligence based adaptive program generation method provided in the above embodiments of the present application.
[0270] It should be understood that the steps shown above can be reordered, added or deleted. For example, the steps described in the present application can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in the present application can be achieved, which is not limited herein.
[0271] The above specific embodiments do not constitute a limitation on the scope of protection of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. An artificial intelligence-based adaptive program generation method, comprising: determining diversity information of a target population; wherein the diversity information is used to indicate program diversity of the target population; determining a temperature parameter according to the diversity information; wherein the temperature parameter is used to adjust selection pressure; wherein the diversity information comprises a diversity indicator, and the determining of the temperature parameter according to the diversity information comprises: performing modulo operation on a first value according to a current evolution iteration number to obtain a second value; wherein a difference between the first value and a total evolution iteration number is greater than a preset threshold; determining a first difference between a target value and the diversity indicator; determining a third value as a base and a fourth value as an exponent of the first difference; determining a second difference between the target value and a ratio, the ratio being a ratio between the second value and the first value; and determining the temperature parameter according to a product of the second difference and the fourth value; selecting a first parent program and a second parent program corresponding to the first parent program from the target population according to the temperature parameter; performing evolution iteration according to the first parent program and the second parent program to obtain a target program; wherein the performing of the evolution iteration according to the first parent program and the second parent program to obtain the target program comprises: generating a child program by performing cross-over and mutation operations on the first parent program and the second parent program using a large model; and performing evolution iteration according to the child program to obtain the target program.
2. The method of claim 1, wherein, The determining of the diversity information of the target population comprises: performing feature extraction on first candidate programs in the target population to obtain first embedding vectors; wherein the first embedding vectors are used to represent syntax and semantic structures of the first candidate programs; performing formal conversion processing on the first candidate programs to obtain conversion results; performing feature extraction on the conversion results to obtain second embedding vectors; fusing the first embedding vectors and the second embedding vectors to obtain a fused representation vector; obtaining the diversity information according to the fused representation vector.
3. The method of claim 2, wherein, The obtaining of the diversity information according to the fused representation vector comprises: determining average cosine distances between the first candidate programs according to the fused representation vector; obtaining the diversity information according to the average cosine distances.
4. The method of claim 3, wherein, The diversity information comprises a diversity indicator, and the obtaining of the diversity information according to the average cosine distances comprises: obtaining auxiliary features of the target population; wherein the auxiliary features comprise one or more of the following: code length of the first candidate programs, fitness of the first candidate programs, and average edit distance between the first candidate programs; fusing the average cosine distances and the auxiliary features to obtain the diversity indicator.
5. The method of claim 2, wherein, The performing of the formal conversion processing on the first candidate programs to obtain conversion results comprises: parsing the first candidate programs to obtain code feature information of the first candidate programs; obtaining pseudo codes of the first candidate programs according to the code feature information; According to the pseudo code, the conversion result is obtained.
6. The method of claim 2, wherein, The formal conversion processing is performed on the first candidate program to obtain a conversion result, including: parsing the first candidate program to obtain a structured representation of the first candidate program; According to the structured representation, the conversion result is obtained.
7. The method of claim 1, wherein, According to the temperature parameter, a first parent program and a second parent program corresponding to the first parent program are selected from the target population, including: According to the temperature parameter, a target cluster is determined from at least one cluster of the target population; The first parent program is selected from the target cluster; According to the first parent program, the second parent program is selected from the target population.
8. The method of claim 7, wherein, According to the temperature parameter, a target cluster is determined from at least one cluster of the target population, including: For any cluster in the at least one cluster, a performance score of the any cluster is determined according to the fitness of the second candidate program in the any cluster and the number of second candidate programs in the any cluster; wherein the performance score is used to measure the relationship between the program quality and the cluster size of the any cluster; According to the temperature parameter and the performance score, a selection probability of the any cluster is determined; According to the selection probability, the target cluster is selected from the at least one cluster.
9. The method of claim 8, wherein, According to the fitness of the second candidate program and the number of second candidate programs in the any cluster, the performance score of the any cluster is determined, including: determining the maximum fitness in the fitness of the second candidate program; According to the ratio between the maximum fitness and the number of second candidate programs, the performance score is determined.
10. The method of claim 7, wherein, The diversity information includes a diversity index, and the second parent program is selected from the target population according to the first parent program, including: According to the fusion feature vector of the first parent program and the fusion feature vector of the first candidate program in the target population, the difference degree between the first parent program and the first candidate program is determined; According to the diversity index, a first weight of the fitness of the first candidate program and a second weight of the difference degree are determined; According to the first weight and the second weight, the fitness of the first candidate program and the difference degree are weighted to obtain a comprehensive score of the first candidate program; According to the comprehensive score, the second parent program is selected from the target population.
11. The method of claim 10, wherein, According to the diversity index, a first weight of the fitness of the first candidate program and a second weight of the difference degree are determined, including: The diversity index is normalized to obtain a normalized index; The normalized index is determined as the first weight; The difference between the target value and the normalized index is determined as the second weight.
12. An artificial intelligence-based adaptive program generation device, comprising: a first determination module configured to determine diversity information of a target population; wherein the diversity information is used to indicate the program diversity of the target population; The second determining module is configured to determine a temperature parameter according to the diversity information, wherein the temperature parameter is used to adjust a selection pressure, and wherein the diversity information comprises a diversity index, and the determination of the temperature parameter according to the diversity information comprises: performing modulo operation on a first numerical value with respect to a current evolution iteration number to obtain a second numerical value, wherein a difference between the first numerical value and a total evolution iteration number is greater than a preset threshold; determining a first difference between a target numerical value and the diversity index; determining a third numerical value as a base and a fourth numerical value as an exponent of the first difference; determining a second difference between the target numerical value and a ratio, the ratio being a ratio between the second numerical value and the first numerical value; and determining the temperature parameter according to a product of the second difference and the fourth numerical value; The selection module is configured to select a first parent program and a second parent program corresponding to the first parent program from the target population according to the temperature parameter. The generation module is configured to perform evolution iteration according to the first parent program and the second parent program to obtain a target program, wherein the evolution iteration according to the first parent program and the second parent program to obtain the target program comprises: performing cross-over and mutation operations on the first parent program and the second parent program by using a large model to generate a child program; and performing evolution iteration according to the child program to obtain the target program. 13.An electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-11.
14. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to perform the method of any one of claims 1-11. 15.A computer program product comprising a computer program which, when executed by a processor, implements the steps of the method of any one of claims 1-11.
Citation Information
Patent Citations
Integrated circuit design method through population optimization algorithm
CN117764025A
Unmanned aerial vehicle target allocation method, device and equipment based on diversity enhancement genetic algorithm
CN118607836A