Programming language compiling method and device based on end-side collaboration
Through the end-edge collaborative programming language compilation method, the game theory decision algorithm and neural network model are used to optimize the compilation location, the problem of inefficiency of traditional compilation methods is solved, efficient compilation and system performance are improved, and the stability of industrial automation systems is ensured. run.
Patent Information
- Application Number
- CN202411031049.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-22
AI Technical Summary
When facing complex industrial automation systems, the traditional IEC61131-3 compilation method has low compilation efficiency, resulting in extended compilation time, affecting response speed and real-time performance, and increasing storage pressure, increasing the risk of compilation failure, which may lead to system stagnation or failure. Impact production safety and efficiency.
Using the programming language compilation method based on end-edge collaboration, the compilation task attribute collection is constructed by obtaining information from terminal devices and edge servers, and the compilation task attributes are optimized, the compilation location is dynamically updated, and the compilation information is realized by obtaining information from the terminal devices and edge servers. intelligent allocation to improve compilation efficiency and system performance.
It improves compilation efficiency, balances system load and power consumption, improves system performance and reliability, reduces compilation time delay, ensures that terminal equipment can respond quickly and update programs, optimizes industrial processes, and accelerates the operation of the entire industrial chain.
Smart Images

Figure CN119003161A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of program compilation technology, and in particular to a programming language compilation method and device based on end-edge collaboration. Background Art
[0002] IEC61131-3 (International Electrotechnical CommiSion, IEC) is a widely used programming standard in the field of industrial automation. The five programming languages it defines: Ladder Diagram (LD), Function Block Diagram (FBD), Instruction List (IL), Structured Text (ST) and Sequential Function Chart (SFC) provide great flexibility and a standardized basis for the development of control tasks. However, in the face of increasingly complex industrial automation systems, the traditional IEC61131-3 compilation method has gradually revealed its limitations.
[0003] Traditional compilation methods mainly rely on local terminal devices for code compilation. This centralized processing method is sufficient for small-scale, low-complexity control systems. However, as the scale of the system expands and the functions become more complex, the amount of code increases dramatically, and the demand for computing power and storage resources also soars. Local terminal devices often have limited computing resources and cannot support efficient and fast compilation processes, resulting in longer compilation times, which in turn affects the response speed and real-time performance of the entire industrial automation system. In addition, the large amount of intermediate results and temporary data generated during the compilation process further aggravates the storage pressure of local terminal devices and increases the risk of compilation failure.
[0004] What is more serious is that low compilation efficiency will directly affect the subsequent program operation, execution result acquisition and specific application, forming a series of chain reactions, which may eventually lead to a decline in the operating efficiency of the entire industrial system, and even cause system stagnation or failure in certain key scenarios, posing a serious threat to production safety and efficiency.
[0005] Currently, no effective solution has been proposed for the problems in the related technologies. Summary of the invention
[0006] In response to the problems in the related art, the present invention proposes a programming language compilation method and device based on end-edge collaboration to overcome the above-mentioned technical problems existing in the existing related art.
[0007] To this end, the specific technical solution adopted by the present invention is as follows:
[0008] According to one aspect of the present invention, a programming language compilation method based on end-edge collaboration is provided, the method comprising the following steps:
[0009] S1. Obtain device information of the terminal device and status information of the edge server;
[0010] S2. extracting the code segments to be compiled contained in the device information in real time, and creating a compilation task attribute set based on the code attributes of the code segments to be compiled;
[0011] S3, setting the optimization target of the code segment to be compiled, and obtaining the compilation position of the code segment to be compiled by building a game model and matching the uninstallation strategy set;
[0012] S4. Based on the compilation position, call the compiler to compile the code segment to be compiled, and dynamically update the compilation information of the compilation position according to the compilation result;
[0013] S5. Respond to the dynamic update of the compilation information and receive the compilation result at the terminal device.
[0014] Furthermore, the device information of the terminal device includes: computing capability of the terminal device, current load of the terminal device, code segments to be compiled, and power consumption cost of locally compiled code of the terminal device;
[0015] The status information of the edge server includes: edge server computing power, edge server current load, edge server network bandwidth, edge server communication bandwidth, power consumption cost when the edge server performs computing tasks, and wireless transmission power consumption cost of the base station terminal device where the edge server is located.
[0016] Furthermore, based on the code attributes of the code segment to be compiled, creating a compilation task attribute set includes the following steps:
[0017] S21, extracting code attributes of the code segment to be compiled, wherein the code attributes include: length, number of lines, amount of text, number of characters (number of tokens), number of variables, number of loops, number of conditional branches, expected deadline of the code segment to be compiled, sensitivity weight of the code segment to be compiled to compilation delay, and sensitivity weight of the code segment to be compiled to power consumption cost;
[0018] S22. Define model input and model output, build a neural network model based on the code attributes of the historical code segments to be encoded and their known computational complexity, and use the Golden Eagle optimization algorithm to optimize model parameters;
[0019] S23, inputting the code attributes extracted in real time into the neural network model to calculate the computational complexity of the code segment to be compiled;
[0020] S24, integrating the code attributes and computational complexity of the code segments to be compiled, and constructing a compilation task attribute set, wherein the expression of the compilation task attribute set is:
[0021] F={size,f req ,ddl,w a , w b}
[0022] Where F is the compilation task attribute set; size is the text size of the code segment to be compiled; f req is the estimated amount of computation required to complete the code segment to be compiled; ddl is the expected deadline for the code segment to be compiled; w a is the sensitivity weight of the code segment to be compiled to the compilation delay; w b is the sensitivity weight of the code segment to be compiled to the power consumption cost.
[0023] Furthermore, the model input and model output are defined, the code attributes of the historical code segments to be encoded and their known computational complexity are combined, a neural network model is constructed, and the Golden Eagle optimization algorithm is used to optimize the model parameters, including the following steps:
[0024] S221, define the code attribute as an input variable, and the amount of calculation required to complete the code segment to be compiled as an output variable;
[0025] S222, obtaining the code attributes of the historical code segments to be encoded and their known calculation amounts, performing association analysis and standardization processing, and dividing the code into training sets and test sets;
[0026] S223, select a gated recurrent unit neural network to build a neural network model, and initialize the hyperparameters of the neural network model, wherein the hyperparameters include a time window step, a number of neurons, a learning rate, and a number of training times;
[0027] S224, optimizing the model parameters using the Golden Eagle optimization algorithm and calculating the model fitness;
[0028] S225. Construct and optimize a neural network model using optimal model parameters, and use the training set to train the model to obtain a final neural network model for predicting the computational amount of the code segment to be compiled.
[0029] Furthermore, obtaining the code attributes of the historical code segments to be encoded and their known computational amounts, performing association analysis and standardization processing, and dividing the training set and the test set includes the following steps:
[0030] S2221, obtaining code attributes of historical code segments to be encoded as associated indicators participating in calculation amount evaluation, and obtaining known calculation amounts of historical code segments to be encoded;
[0031] S2222. Calculate the correlation coefficients between different correlation indicators and known calculation amounts through the Pearson correlation coefficient, set a correlation threshold, select correlation indicators that meet the correlation threshold, and assign weight coefficients to each of them;
[0032] S2223. Integrate the known computing amount and the retained related indicators, construct a historical data set, and divide it into a training set and a test set according to a preset ratio.
[0033] Furthermore, the Golden Eagle optimization algorithm is used to optimize the model parameters and calculate the model fitness, including the following steps:
[0034] S2241. Initialize the number and population size of golden eagles, and initialize the attack coefficient and cruise coefficient;
[0035] S2242. The golden eagle individual randomly adjusts its own position based on the position information of itself and other individuals, and updates the position information of each golden eagle individual in the population;
[0036] S2243, calculating the fitness function to initialize the population memory, and randomly selecting prey from the attack vector calculated from the population memory;
[0037] S2244, calculating the cruise vector and the step vector, and updating the fitness function of the position evaluation new position;
[0038] S2245, update the search and supply phase, and update the optimal solution and optimal position;
[0039] S2246. Determine whether the maximum number of iterations is met. If so, output the current optimal golden eagle position and the global optimal solution. If not, return to step S2242.
[0040] Furthermore, setting the optimization target of the code segment to be compiled, and obtaining the compilation position of the code segment to be compiled by building a game model and matching the uninstallation strategy set includes the following steps:
[0041] S31, respectively calculating the compilation delay and power consumption cost of the terminal device and the edge server, and calculating the total compilation cost and on-time rate of the code segment to be compiled in combination with the sensitivity weight;
[0042] S32, defining minimizing the total compilation cost and maximizing the on-time rate as optimization goals;
[0043] S33, defining the terminal device as a participant, constructing a participant set, and establishing a participant priority formula in combination with code attributes to calculate the priority of each terminal device in participating in the game;
[0044] S34. Based on the decision-making algorithm of game theory, a game model is established, and the compilation task attribute set is combined to match the uninstallation strategy set of the terminal device, and finally the compilation position of the code segment to be compiled is obtained.
[0045] Furthermore, the participant priority formula is expressed as:
[0046]
[0047] In the formula, priority i is the priority of terminal device i in participating in the game; ddl is the expected deadline of the code segment to be compiled; f i req The estimated amount of computation required to complete the code segment to be compiled for terminal device i; f i u is the computing power of terminal device i; w a is the sensitivity weight of the code segment to be compiled to the compilation delay.
[0048] Furthermore, based on the decision-making algorithm of game theory, a game model is established, and the compilation task attribute set is combined with the uninstallation strategy set of the terminal device to finally obtain the compilation position of the code segment to be compiled, including the following steps:
[0049] S341, defining an edge server as a candidate, constructing a candidate set, and the current load of each edge server in the candidate set does not exceed a load threshold;
[0050] S342, construct a decision space, sort the participants according to their priority in the game from large to small, make each participant traverse the decision space, obtain the decision of each terminal device, and then write the decision of each terminal device into the uninstallation strategy set;
[0051] S343: Based on the uninstallation policy set, identify the compilation location of each code segment to be compiled.
[0052] According to another aspect of the present invention, there is also provided a programming language compilation device based on end-edge collaboration, the device comprising:
[0053] An information acquisition module is used to obtain device information of the terminal device and status information of the edge server;
[0054] An extraction and creation module is used to extract the code segments to be compiled contained in the device information in real time, and create a compilation task attribute set based on the code attributes of the code segments to be compiled;
[0055] The strategy matching module is used to set the optimization target of the code segment to be compiled, and obtain the compilation position of the code segment to be compiled by building a game model and matching the uninstallation strategy set;
[0056] A compilation update module is used to call the compiler to compile the code segment to be compiled based on the compilation position, and dynamically update the compilation information of the compilation position according to the compilation result;
[0057] The response feedback module is used to respond to the dynamic update of the compilation information and receive the compilation result on the terminal device.
[0058] The beneficial effects of the present invention are:
[0059] 1. By comprehensively considering the computing power, load conditions and properties of the code segments to be compiled of the terminal devices and edge servers, the game theory decision algorithm is used to optimize the unloading strategy of the code segments to be compiled, and the intelligent allocation of the code segments to be compiled is realized, which can not only improve the compilation efficiency, but also balance the system load and power consumption, thereby improving the performance and reliability of the entire system; at the same time, it can improve the compilation efficiency, and the terminal devices can unload the code segments to be compiled to the resource-rich edge nodes to obtain rapid response and execution, reduce compilation time delays, and enable terminal devices to update programs more quickly and respond to real-time needs, which also helps to improve a series of industrial processes such as subsequent program execution and the circulation and application of execution results, and accelerate the operation of the entire industrial chain.
[0060] 2. By considering multiple attributes of the code segments to be compiled, a rich and accurate data basis is provided for accurately evaluating the complexity of the code segments to be compiled and optimizing the compilation process, which helps to more finely control the allocation of code segments to be compiled to further improve the optimization effect; at the same time, the scope of information is further expanded to facilitate a comprehensive evaluation of the status of terminal devices and edge servers; in addition, dynamic updates of this information can adapt to changes in real time and improve the real-time and accuracy of decisions; in addition, the present invention not only takes into account the optimization goals of each terminal device, but also takes the perspective of the entire system to maximize the use of real-time limited resources in the system to ensure a higher punctuality rate.
[0061] 3. The present invention determines the compilation delay and power consumption cost at different compilation locations (terminal device or edge server), provides specific and operational evaluation indicators for the optimization of the code segment to be compiled, helps the system select the optimal compilation location according to actual needs, and achieves a balance between compilation efficiency and energy consumption; at the same time, it clarifies the optimization goal of the code segment to be compiled, and provides a clear direction for the optimization of the code segment to be compiled. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0063] Figure 1 is a flowchart of a programming language compilation method based on end-edge collaboration according to an embodiment of the present invention;
[0064] Figure 2 It is a principle block diagram of a programming language compilation device based on end-edge collaboration according to an embodiment of the present invention.
[0065] In the figure:
[0066] 1. Information acquisition module; 2. Extraction and creation module; 3. Strategy matching module; 4. Compilation and update module; 5. Response feedback module. DETAILED DESCRIPTION
[0067] To further illustrate each embodiment, the present invention provides drawings, which are part of the disclosure of the present invention and are mainly used to illustrate the embodiments. They can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in this field should be able to understand other possible implementation methods and advantages of the present invention.
[0068] According to an embodiment of the present invention, a programming language compilation method and device based on end-edge collaboration are provided.
[0069] The present invention will now be further described with reference to the accompanying drawings and specific embodiments. Figure 1 As shown, according to an embodiment of the present invention, a programming language compilation method based on end-edge collaboration includes the following steps:
[0070] S1. Obtain device information of the terminal device and status information of the edge server.
[0071] In the description of the present invention, the device information of the terminal device includes: the computing capability of the terminal device, the current load of the terminal device, the code segment to be compiled, and the power consumption cost of the local compiled code of the terminal device.
[0072] The status information of the edge server includes: edge server computing power, edge server current load, edge server network bandwidth, edge server communication bandwidth, power consumption cost when the edge server performs computing tasks, and wireless transmission power consumption cost of the base station terminal device where the edge server is located.
[0073] S2. Extract the code segments to be compiled contained in the device information in real time, and create a compilation task attribute set based on the code attributes of the code segments to be compiled.
[0074] In the description of the present invention, based on the code attributes of the code segment to be compiled, creating a compilation task attribute set includes the following steps:
[0075] S21. Extract code attributes of the code segment to be compiled, wherein the code attributes include: length, number of lines, amount of text, number of characters (number of tokens), number of variables, number of loops, number of conditional branches, expected deadline of the code segment to be compiled, sensitivity weight of the code segment to be compiled to compilation delay, and sensitivity weight of the code segment to be compiled to power consumption cost.
[0076] S22. Define model input and model output, build a neural network model based on the code attributes of the historical code segment to be encoded and its known computational complexity, and use the Golden Eagle optimization algorithm to optimize the model parameters.
[0077] In the description of the present invention, the model input and model output are defined, the code attributes of the historical code segments to be encoded and the known computational amount thereof are combined, a neural network model is constructed, and the Golden Eagle optimization algorithm is used to optimize the model parameters, including the following steps:
[0078] S221. Define code attributes as input variables, and define the amount of calculation required to complete the code segment to be compiled as output variables.
[0079] S222. Obtain the code attributes of the historical code segments to be encoded and their known calculation amounts, perform association analysis and standardization processing, and divide them into training sets and test sets.
[0080] In the description of the present invention, obtaining the code attributes of the historical code segments to be encoded and the known computational quantities thereof, performing association analysis and standardization processing, and dividing the training set and the test set includes the following steps:
[0081] S2221. Obtain code attributes of historical code segments to be encoded as associated indicators participating in computational amount evaluation, and obtain known computational amounts of historical code segments to be encoded.
[0082] S2222. Calculate the correlation coefficients between different correlation indicators and known calculation quantities through the Pearson correlation coefficient, set a correlation threshold, select correlation indicators that meet the correlation threshold, and assign respective weight coefficients.
[0083] S2223. Integrate the known computing amount and the retained related indicators, construct a historical data set, and divide it into a training set and a test set according to a preset ratio.
[0084] S223. Select a gated recurrent unit neural network to build a neural network model, and initialize the hyperparameters of the neural network model, where the hyperparameters include a time window step, a number of neurons, a learning rate, and a number of training times.
[0085] Specifically, GRU (Gated Recurrent Unit) is a type of recurrent neural network. It improves on the traditional long-short term neural network LSTM. While inheriting the long-short term memory and gradient problem-solving capabilities of LSTM, it improves the model performance by optimizing the number of thresholds in neurons, making GRU have better fitting capabilities, while reducing model parameters and reducing the risk of overfitting.
[0086] S224. Optimize the model parameters using the Golden Eagle optimization algorithm and calculate the model fitness.
[0087] Specifically, the Golden Eagle Optimizer (GEO) is a new type of swarm intelligence optimization algorithm based on eagle hunting behavior. The algorithm solves complex optimization problems by simulating the search and attack behaviors of the golden eagle during the hunting process. The core idea of GEO is to find the optimal solution through cooperation and competition among group members. Compared with other methods, it has the characteristics of fast convergence speed and strong optimization ability. The present invention uses the Golden Eagle Optimizer to optimize the hyperparameters of the GRU algorithm (Gated Recurrent Unit Neural Network) so that it can achieve better results in the computational evaluation of the computational amount. During the operation of the Golden Eagle Optimizer, the following aspects are involved:
[0088] 1) Aggressive behavior (development phase): Aggressive behavior can be simulated by a vector starting from the current position of the golden eagle and ending with the position of the prey in the golden eagle's memory.
[0089] 2) Cruise behavior (exploration phase): The cruise vector is calculated based on the attack vector. The cruise vector is the tangent vector of the circle. In order to calculate the cruise vector, it is necessary to first calculate the equation of the tangent hyperplane. The dimensional equation of the hyperplane can be determined by any point on the hyperplane and the vector perpendicular to the hyperplane, which is called the normal vector of the hyperplane.
[0090] 3) Move to a new position: The displacement of the golden eagle consists of the attack vector and the target position.
[0091] The Golden Eagle will remember the best hunting position it has passed while cruising. When the adaptability of the new position of the Golden Eagle is lower than the memorized position, the Golden Eagle will abandon the new position and look for a new target. The Golden Eagle will focus more on global exploration in the early stage and focus on higher attack tendencies in the later stage, which makes the Golden Eagle algorithm less likely to fall into the local optimal solution.
[0092] In the description of the present invention, the Golden Eagle optimization algorithm is used to optimize the model parameters, and the model fitness is calculated, including the following steps:
[0093] S2241. Initialize the number and population size of golden eagles, and initialize the attack coefficient and cruise coefficient.
[0094] S2242. The golden eagle individual randomly adjusts its own position based on its own position information and that of other individuals, and updates the position information of each golden eagle individual in the population.
[0095] S2243. Calculate the fitness function to initialize the population memory, and randomly select prey from the attack vector calculated from the population memory.
[0096] S2244. Calculate the cruise vector and the step vector, and update the fitness function of the position evaluation new position.
[0097] S2245: Update the search and supply phase, and update the optimal solution and optimal position.
[0098] S2246. Determine whether the maximum number of iterations is met. If so, output the current optimal golden eagle position and the global optimal solution. If not, return to step S2242.
[0099] S225. Construct and optimize a neural network model using optimal model parameters, and use the training set to train the model to obtain a final neural network model for predicting the computational amount of the code segment to be compiled.
[0100] S23, inputting the code attributes extracted in real time into the neural network model to calculate the computational complexity of the code segment to be compiled.
[0101] S24, integrating the code attributes and computational complexity of the code segments to be compiled, and constructing a compilation task attribute set, wherein the expression of the compilation task attribute set is:
[0102] F={size,f req ,ddl,w a , w b}
[0103] Where F is the compilation task attribute set; size is the text size of the code segment to be compiled; f req is the estimated amount of computation required to complete the code segment to be compiled; ddl is the expected deadline for the code segment to be compiled; w a is the sensitivity weight of the code segment to be compiled to the compilation delay; w b is the sensitivity weight of the code segment to be compiled to the power consumption cost.
[0104] And w a With w b Satisfy the constraints: w a +w b =1,w a >0,w b >0.
[0105] S3. Set the optimization target of the code segment to be compiled, and obtain the compilation position of the code segment to be compiled by building a game model and matching the uninstallation strategy set.
[0106] In the description of the present invention, setting the optimization target of the code segment to be compiled, and obtaining the compilation position of the code segment to be compiled by building a game model and matching the uninstallation strategy set includes the following steps:
[0107] S31. Calculate the compilation delay and power consumption cost of the terminal device and the edge server respectively, and calculate the total compilation cost and on-time rate of the code segment to be compiled in combination with the sensitivity weight.
[0108] Specifically, the compilation delay and power consumption cost of the terminal device include the following formula:
[0109]
[0110]
[0111] Where, T s Compile delay for terminal device; i is the number of terminal device; f i req The estimated amount of computation required to complete the code segment to be compiled for terminal device i; f i u is the computing power of terminal device i; H s The power consumption cost of the terminal equipment; is the power consumption cost of the local compiled code of terminal device i.
[0112] The compilation delay and power consumption cost of the edge server include the following formula:
[0113]
[0114]
[0115] Where, T b is the compilation delay; j is the number of the edge server; The estimated amount of computation required to complete the code segment to be compiled for edge server j; f j u is the computing power of edge server j; η j H is the number of code segments to be compiled that simultaneously select edge server j as the compilation location; b The power consumption cost of the terminal equipment; is the average communication delay between edge server j and terminal device i; size is the text size of the code segment to be compiled; is the communication bandwidth of edge server j; The power consumption cost of edge server j when performing computing tasks; is the wireless transmission power consumption cost of the base station terminal device where the edge server j is located; is the communication bandwidth of edge server j.
[0116] S32. Define minimizing the total compilation cost and maximizing the on-time rate as optimization goals.
[0117] Specifically, the expression that minimizes the total compilation cost is:
[0118]
[0119] maxPu
[0120] In the formula, To minimize the total compilation cost, maxPu is to maximize the on-time rate, and I is the number of terminal devices;
[0121] The total compilation cost includes the following:
[0122] Ω=w a .T+w b .H
[0123] Where Ω is the total compilation cost, H is the power consumption cost; T is the compilation delay; w a is the sensitivity weight of the code segment to be compiled to the compilation delay; w b is the sensitivity weight of the code segment to be compiled to the power consumption cost, and w a and w b Satisfy the constraints:
[0124] W a +w b =1,w a >0,w b >0
[0125] The punctuality rate includes the following formula:
[0126]
[0127] Where, Pu is the punctuality rate; N pu The total number of compilations that completed on time, that is, the compilation delay was less than or equal to the expected deadline for the code segment to be compiled.
[0128] S33. Define the terminal device as a participant, construct a participant set, and establish a participant priority formula in combination with code attributes to calculate the priority of each terminal device in participating in the game.
[0129] In the description of the present invention, the expression of the participant priority formula is:
[0130]
[0131] In the formula, priorityi is the priority of terminal device i in participating in the game; ddl is the expected deadline of the code segment to be compiled; f i req The estimated amount of computation required to complete the code segment to be compiled for terminal device i; f i u is the computing power of terminal device i; w a is the sensitivity weight of the code segment to be compiled to the compilation delay.
[0132] S34. Based on the decision-making algorithm of game theory, a game model is established, and the compilation task attribute set is combined to match the uninstallation strategy set of the terminal device, and finally the compilation position of the code segment to be compiled is obtained.
[0133] In the description of the present invention, based on the decision algorithm of game theory, a game model is established, and the compilation task attribute set is combined to match the uninstallation strategy set of the terminal device, and finally the compilation position of the code segment to be compiled is obtained, which includes the following steps:
[0134] S341: Define the edge server as a candidate, build a candidate set, and the current load of each edge server in the candidate set does not exceed the load threshold.
[0135] S342, construct a decision space, sort the participants from high to low according to their priority in participating in the game, make each participant traverse the decision space, obtain the decision of each terminal device, and then write the decision of each terminal device into the uninstallation strategy set.
[0136] Specifically, the decision space is a set of possible offloading strategies that each terminal device may adopt, and the decision space = {α1, α2, ..., αi..., αI}, where αi∈{0, 1, 2, ...j..., J}, 0 represents local compilation, and 1 to J represent offloading to edge servers in the candidate set, respectively. There are J edge servers in the candidate set.
[0137] The decision space traversed by each participant includes:
[0138] Initialize uninstall strategy make And perform the following loop steps to traverse the decision space until Exit the loop step, and determine the decision of the terminal device based on the optimization target of the code segment to be compiled of the compilation task;
[0139] Calculate the total compilation cost and compilation delay at each location;
[0140] make
[0141] S343: Based on the uninstallation policy set, identify the compilation location of each code segment to be compiled, where the compilation location is a terminal device or an edge server.
[0142] S4. Based on the compilation position, the compiler is called to compile the code segment to be compiled, and the compilation information of the compilation position is dynamically updated according to the compilation result.
[0143] Among them, the updated compilation information includes: the computing power of the terminal device, the current load of the terminal device, and the power consumption cost of the local compiled code of the terminal device, or the computing power of the edge server, the current load of the edge server, the power consumption cost of the edge server when performing computing tasks, the network bandwidth of the edge server, the wireless transmission power consumption cost of the terminal device of the base station where the edge server is located, and the communication bandwidth of the edge server. The code segment to be compiled.
[0144] When applying, the IEC61131 code is compiled at the corresponding location. If the decision result is to compile locally, the local compiler is directly called for compilation; if the decision result is to compile at the edge, the code segment to be compiled is transmitted to the corresponding edge server via the network communication interface, and the compiler deployed therein is called for compilation; after the compilation is completed, the system information and related parameters are updated.
[0145] S5. Respond to the dynamic update of the compilation information and receive the compilation result at the terminal device.
[0146] When applied, for local compiled tasks, the compilation results can be directly retrieved after the compilation is completed; for the code segments to be compiled that are offloaded to the edge server, the compilation results are returned through the network communication interface after the compilation is completed.
[0147] like Figure 2 As shown, according to another embodiment of the present invention, a programming language compilation device based on end-edge collaboration is also provided, the device comprising:
[0148] The information acquisition module 1 is used to acquire the device information of the terminal device and the status information of the edge server.
[0149] The extraction and creation module 2 is used to extract the code segments to be compiled contained in the device information in real time, and create a compilation task attribute set based on the code attributes of the code segments to be compiled.
[0150] The strategy matching module 3 is used to set the optimization target of the code segment to be compiled, and obtain the compilation position of the code segment to be compiled by building a game model and matching the uninstallation strategy set.
[0151] The compile update module 4 is used to call the compiler to compile the code segment to be compiled based on the compile position, and dynamically update the compile information of the compile position according to the compile result.
[0152] The response feedback module 5 is used to respond to the dynamic update of the compilation information and receive the compilation result at the terminal device.
[0153] It should be noted that the main focus of the present invention is the process of compiling ST language into C language. ST has a syntax similar to that of a high-level programming language and provides rich functions and expressiveness. In PLC programming, converting ST code into C code is a common task. The purpose of this conversion is to convert ST code into executable code that is compatible with a specific PLC hardware platform. By converting ST into C code, existing C compilers and optimization tools can be used to improve the execution efficiency and maintainability of the code.
[0154] Edge computing is a distributed computing model that aims to move computing and data processing functions from traditional cloud computing centers to edge nodes close to data sources and terminal devices. The purpose of edge computing is to provide low-latency, high-bandwidth, and real-time responsive computing capabilities by placing computing resources and data storage close to terminal devices, thereby supporting applications in the Internet of Things, industrial automation, and other fields. Edge computing can greatly reduce data transmission delays, improve system reliability, and reduce dependence on cloud computing resources. In the field of industrial automation, edge computing plays an important role in real-time control and data processing. By deploying edge computing capabilities on terminal devices such as PLCs, faster response times and higher real-time performance can be achieved, thereby improving the performance and reliability of industrial automation systems.
[0155] End-edge collaboration is a working mode based on edge computing, in which the terminal device and the edge server work together to efficiently complete tasks with high performance requirements. For example, in industrial control systems, PLCs can collaborate with sensors, actuators, and other edge terminal devices to complete real-time control and data processing tasks. Through end-edge collaboration, more efficient resource utilization and intelligent decision-making can be achieved.
[0156] Edge computing clusters usually have larger memory capacity, which can meet the memory requirements of the compilation process. Edge computing clusters can also expand or shrink according to actual needs, dynamically allocate computing resources according to the load of the code segment to be compiled, and achieve better resource utilization and compilation performance.
[0157] The present invention is described below in conjunction with implementation methods of each step and specific embodiments.
[0158] In step S1, the information of the terminal devices and edge servers in the environment is collected. Specifically, the terminal devices in the industrial Internet environment are often embedded terminal devices with weak computing power. First, these terminal devices are modeled. Each terminal device has attributes such as computing, power consumption, and code segments to be compiled. The attributes of the terminal device can be represented by a triple: Among them, u i is the attribute of terminal device i, f i u is the local computing capability of terminal device i, The power consumption cost of compiling code locally for terminal device i, is the IEC61131 code segment to be compiled submitted by terminal device i in the time slot. In the environment of the present invention, there are terminal devices, and the attribute set U of I terminal devices = {u1, u2, ..., u i , ..., u I}.
[0159] For example, in one embodiment, 50 terminal devices are set. The attributes of each terminal device are different. For example, the attribute u2 of terminal device No. 2 is {800Mhz, 0.003, "~ / data / t_ei.st"}, which means that it is equipped with an embedded processor chip with a frequency of 800Mhz, and the local power consumption cost (considering energy consumption, terminal device loss, etc.) is 0.003 (per Gigacycles), and there is a task to be compiled on it located at the path "~ / data / t_ei.st".
[0160] In addition, the attributes of each server are represented by a five-tuple: Among them, f j e The edge is the computing power of server j, is the power consumption cost of server j when performing computing tasks; is the wireless transmission power consumption cost of the base station terminal equipment where server j is located; is the communication bandwidth of server j; In order to make full use of the edge computing resources in the industrial environment, the present invention constructs J edge servers available in the environment, and the attribute composition set E = {e1, e2, ..., e J}.
[0161] In one embodiment, 15 edge servers are set, and the attributes of each edge server are also different. For example, the attribute of edge server No. 3 is e3 = {3000Mhz, 0.005, 0.02, 100Mbps, 0.01s}, which specifically means that the edge server is equipped with a high-performance processor chip with a frequency of 3000Mhz, and the average power consumption cost generated during operation is 0.005 (per Gigacycles). The power consumption cost of the local compiled code of the base station terminal device where it is located is an average of 0.02 (per Gigacycles), and it is equipped with a network bandwidth of 100Mbps, and there is an average network propagation delay of 0.01s between the terminal device and the edge server.
[0162] In step S2, the compilation task attribute set of the code segment to be compiled can be determined by a five-tuple set. When applied, each terminal device in the system may submit an IEC61131 code segment to be compiled in a time slot. That is, after a preliminary analysis of the code segment to be compiled, the compilation task attribute set of the code segment to be compiled of the terminal device i can be obtained:
[0163]
[0164] In the formula, F i for The compilation task attribute collection, is the code segment to be compiled for terminal device i, size i for The amount of text; f i req To complete Estimated amount of computation required; ddl i For the desired Deadline: for Sensitivity to compilation delays; for Sensitivity to power consumption costs; and Satisfy constraints
[0165] In actual application, the compilation task attribute set of the code segment to be compiled of the terminal device No. 2 of the present invention is This means that the code segment to be compiled for terminal device No. 2 contains a series of source files that comply with the IEC61131 standard. The total file size is 19397KB, and the compilation result needs to be obtained within a delay of 500ms. The expected weights for delay and cost are 0.6 and 0.4 respectively. The predicted compilation resource requirement based on the text volume and code structure is 4.18e9 CPU cycles.
[0166] In addition, when applied, F i f i req It cannot be obtained by direct parsing or user-specified methods. A neural network model is used to complete the code segment to be compiled. The attribute analysis is completed by to f i req 's mapping.
[0167] F i The purpose is to solve the compilation The final running position is is the code segment to be compiled for terminal device i; The meaning is that if but Run locally on terminal device i; if but Runs on the edge server j.
[0168] visible, The set of components is the task to be solved: offloading strategy L. In order to solve the offloading strategy L, it is necessary to clarify the optimization goal of the entire compilation process. To this end, it is first necessary to define the compilation delay, power consumption cost, total compilation cost, on-time rate and other parameters of the compiled code segment.
[0169] (1) Compile delay: The definition of compilation delay is the time from the time when the terminal device i submits the code segment to be compiled to the time when the available target code is retrieved. It needs to be discussed in two cases according to whether it is offloaded to the edge server for compilation, that is, the compilation delay of the terminal device and the compilation delay of the edge server are calculated separately.
[0170] (2) Power consumption cost: The power consumption cost is defined as the power consumption cost of the system from the time when the terminal device i submits the code segment to be compiled to the time when the available target code is retrieved. For embedded terminal devices, excessive power consumption will not only cause higher power loss, but also cause a decrease in the terminal device's processing capacity and service level due to factors such as heat; for edge servers, the amount of power consumption also reflects the cost of renting servers, maintaining base stations and other terminal devices. The power consumption cost of terminal devices and edge servers needs to be calculated separately.
[0171] It can be seen that if the decision result is that the code segment to be compiled runs locally, there is no need to consider the additional power consumption costs caused by factors such as network transmission and edge computing, and only the power consumption generated by local computing needs to be considered; if the result is to offload to the edge server for compilation, then in addition to the power consumption generated by local computing, it is also necessary to consider the additional power consumption generated by compilation on the edge server and the power consumption costs generated during communication with terminal devices such as base stations. Different from the calculation of compilation delay, when calculating the power consumption cost, there is no need to specially consider the situation where multiple offload tasks share edge server resources, because the total power consumption cost of a code segment to be compiled will not be affected by the increase in participants.
[0172] (3) Total compilation cost: When considering the decision of each terminal device to offload tasks, it is always hoped to minimize the total compilation cost caused by compilation delay, power consumption, etc. The total compilation cost includes the following formula:
[0173] Ω=w a ·T+w b ·H
[0174] Where Ω is the total compilation cost, H is the power consumption cost; T is the compilation delay; w a is the sensitivity weight of the code segment to be compiled to the compilation delay; w b is the sensitivity weight of the code segment to be compiled to the power consumption cost, and w a and w b Satisfy the constraints: w a +w b =1,w a >0,w b >0.
[0175] When applied, the total compilation cost of terminal device i can be calculated according to the following formula:
[0176]
[0177] Among them, Ω i is the total compilation cost of terminal device i; H i is the power consumption cost of terminal device i; T i is the compilation delay of terminal device i.
[0178] (4) On-time rate: In addition to the total compilation cost, we also need to consider the constraints imposed by the task deadline parameters. For this purpose, we can define If a code segment to be compiled can be completed before its set deadline, it is said that the code segment to be compiled is completed on time. The punctuality rate (Punctuality) can be defined for all code segments to be compiled in the system as follows. The punctuality rate includes the following formula:
[0179]
[0180] Where, Pu is the punctuality rate; N pu is the total number of code segments to be compiled that are completed on time, that is, the number of code segments to be compiled whose compilation delay is less than or equal to the expected deadline of the code segments to be compiled; N is the total number of code segments to be compiled.
[0181] At this point, the present invention can define the goal of the end-edge collaborative IEC61131 compilation method as solving the offload strategy L. Further, solving the offload strategy is equivalent to solving the optimization goal of the code segment to be compiled. The optimization goal of the code segment to be compiled in step S3 includes minimizing the total compilation cost and maximizing the on-time rate:
[0182]
[0183] in, To minimize the total compilation cost, maxPu is to maximize the on-time rate, and I is the number of terminal devices.
[0184] In the industrial Internet scenario, terminal devices (such as sensors, actuators, etc.) usually need to run logic control programs to monitor and control the terminal devices. These logic control programs are usually written in the form of PLC code and need to be compiled before they can run on the terminal devices. IEC61131 is a very important standard in the field of PLC programming and is widely used in the industrial Internet industry. In a large industrial automation system, there are a large number of interconnected terminal devices distributed in different geographical locations, and each terminal device is equipped with certain storage resources and computing resources.
[0185] However, with the increasing complexity of the control program logic of massive terminal devices in the Industrial Internet and the gradual improvement of performance requirements, related problems have gradually emerged. On the one hand, the computing power of some terminal devices is very limited, which is not enough to support the complex compilation process, and it is impossible to complete the compilation of IEC61131 programs by itself. On the other hand, some terminal devices may have the complete ability to compile IEC61131 programs, but it is difficult to meet the low-latency requirements of terminal devices for real-time execution of control logic. Traditional compilation solutions such as centralized compilation and unified distribution not only have the disadvantages of low flexibility and difficulty in responding to the update requirements of terminal devices in a timely manner, but also limited resources make it difficult to support the real-time compilation requirements of massive terminal devices.
[0186] In order to fully meet the high-performance requirements of terminal devices for low latency and fast response, we focus on the program compilation link and make full use of the computing power with low compilation latency provided by the edge computing mode based on the end-edge collaborative system. The details are as follows:
[0187] For the first optimization goal, it can be understood that each terminal device tends to minimize its own total compilation cost, and the game theory-based method has certain advantages in solving this problem of considering the rational needs of each participant. Among them, potential game has good convergence, so the problem can be modeled as a potential game model first, and then solved. To this end, it is necessary to define the set of participants N of the game g , Decision Space A g and utility function
[0188] Specifically, the participant set N g It can be defined as a set of terminal devices established in step S1, each of which is a participant in the game; the decision space A g It is composed of the compilation and offloading decisions taken by each terminal device, namely A g ={α1,α2,...,αi...,αI}, where α i ∈{0, 1, 2, ..., J}, i = 1, 2, ..., I is the compilation offloading decision that each terminal device may take; for the i-th terminal device, its utility function Defined as the total compilation cost Ω for terminal device i i , that is to say where a i is the uninstallation strategy adopted by terminal device i, and a -i Then {u1, u2, ..., u i-1 ,u i+1 , ..., u I}, that is, the compilation and offloading decisions of other terminal devices in the system other than terminal device i. The utility function of each terminal device is This constitutes the set of utility functions At this point, a standard game model involving I players has been constructed
[0189] For the second optimization goal, it is necessary to maximize the system punctuality from a global perspective. It can be seen that when solving the game model, it is necessary to consider the deadline constraint at the same time, and maintain the equilibrium state of the game while ensuring the system punctuality.
[0190] According to the definition of potential game, if we can find a potential function Satisfy the following formula:
[0191]
[0192] in, is the potential function; Compile and offload decisions for the final output of terminal device i.
[0193] Then the game model G is also a potential game model. According to the convergence theorem of potential games, a pure strategy Nash equilibrium can be found that satisfies:
[0194]
[0195] in, is the compilation unloading decision finally output by other terminal devices other than terminal device i. It can be seen that no player can obtain higher benefits by unilaterally changing its own strategy, that is, the total compilation cost in the present invention. In addition, the potential game G also has the characteristic that it will converge after finite iterations. To this end, define the potential function
[0196] Where I(·) is an indicator function, which takes the value 1 when the expression is true, and takes the value 0 otherwise; T i is the compilation delay of terminal device i; H i is the power consumption cost of terminal device i.
[0197] Potential Function can be converted to:
[0198]
[0199] Potential Function The convergence theorem of potential game is satisfied, so the game model G is a potential game model at this time, which can be solved by the method of solving the potential game model.
[0200] In step S3, an algorithm based on game theory is used. In order to minimize the total compilation cost of each terminal device and ensure the overall punctuality of the system as much as possible, the code segment to be compiled of each participant needs to be preprocessed before running the potential game. Specifically, step S3 includes preprocessing (step S33) and decision generation (step S34).
[0201] For preprocessing, the participant set N g Iterate each element in and calculate the priority of each terminal device participating in the game according to the following formula:
[0202]
[0203] It can be seen that when the code segment to be compiled can be completed locally, the task will be given a lower priority, and this priority will decrease as the difference between the deadline and the local calculation completion time increases. That is, the easier it is to complete the code segment to be compiled locally, the lower its unloading priority. Conversely, when the local processing cannot be completed within the deadline, the more local calculation timeouts there are, the higher its priority. After the preprocessing process, the code segments to be compiled with higher latency weights have a higher priority in selecting stronger computing resources on the edge side, avoiding a significant drop in punctuality due to too many timeouts of the code segments to be compiled.
[0204] In step S34, each terminal device participates in the game according to its priority. There are three factors to consider when making compilation offloading decisions:
[0205] (1) A collection of compile task properties
[0206] (2) Available edge servers in the environment and their attributes:
[0207] (3) Compilation and unloading decisions for final output of terminal devices other than terminal device i
[0208] In order to improve the efficiency of the algorithm and maintain the load balance of the system, it is necessary to avoid traversing all possible operating locations. To this end, a load threshold μ is set to screen edge servers and obtain a reasonable set of unloading locations. Among them, μ∈[0,1], preferably, μ∈[0,0.7].
[0209] Specifically, the computational load of the jth edge server is θ j , then the set of unloading locations that meet the traversal conditions is {j|θ j≤μ}. Then, terminal device i traverses all possible unloading locations, i.e., α i ∈{j|θ j ≤μ}, and calculate the total compilation cost Ω of terminal device i i Initially, let Calculate the corresponding total compilation cost Ω i (0), assuming that after the traversal is completed, the final compilation and unloading decision output by terminal device i is Then, in each traversal, the total compilation cost of the round is calculated, and the update is performed if and only if the following two conditions are met:
[0210] (1)
[0211] (2) When the uninstall strategy is When , the deadline constraint can be met. When the unloading strategy is , the on-time constraint is still satisfied.
[0212] The first condition means that the new offloading strategy will bring lower total compilation cost, which is more beneficial for individual terminal devices. The second condition means that updating the offloading strategy of individual terminal devices will not affect the individual terminal devices that have already selected the offloading strategy, thereby ensuring the punctuality of the overall system.
[0213] After the traversal is completed, the final compilation and uninstallation decision of terminal device i is obtained make That represents The final compilation location is loc i .
[0214] In step S4, according to the convergence theorem of potential game, after multiple rounds of iterations are completed, if no terminal device updates the compilation and unloading decision, the system reaches a Nash equilibrium state, the iterative process terminates, and the final unloading strategy set L that needs to be solved is output.
[0215] Each terminal device i follows its compilation and uninstallation decision loc i Submit the code segment to be compiled, and then call its compilation service at the corresponding location to perform the actual IEC61131 program compilation operation. Specifically:
[0216] If loc i =0, the decision result is to compile locally, directly call the local PLC compiler to compile, and the obtained target code can be used directly;
[0217] If loc i >0 and loc i=j, the decision result is to compile at the edge, then the code segment to be compiled is transmitted to the corresponding j-th edge server through the network communication interface, the compiler deployed therein is called to perform the compilation operation and the compiled target code is returned through the network communication interface.
[0218] In step S4, after the compilation is completed, a set of real compilation performance parameters will be obtained, including the real compilation calculation amount, network transmission time, power consumption parameters and other information. This information needs to be stored and the system information is updated. According to the convergence theorem of potential game, after multiple rounds of iterations are completed, if no terminal device updates the strategy again, then the system reaches the Nash equilibrium state, the iterative process terminates, and the final unloading strategy set L that needs to be solved is also output.
[0219] In actual application, the code segment to be compiled on the No. 2 terminal device is obtained through step S3, and the final compilation and uninstallation decision is obtained. That is, the compilation position is loc2 = 0. This indicates that the code segment to be compiled on terminal device No. 2 should be compiled locally, that is, the local IEC61131 compiler is called, and the compiled code is immediately available. Another code segment to be compiled on terminal device No. 5 The compilation task attribute set is After step S3, the compilation and uninstallation decision result is: That is, the compilation location is loc5=3. This indicates that the code segment to be compiled on terminal device No. 5 should be unloaded to edge server No. 3 for execution. Terminal device No. 5 needs to transmit the IEC61131 source code to server No. 3 through the network interface, and then call the IEC61131 compiler on edge server No. 3 for compilation.
[0220] In addition, after the compilation is completed, a set of real compilation performance parameters will be obtained, including the real compilation calculation amount, network transmission time, power consumption parameters and other information. This information needs to be stored to update the system information, and at the same time, used as a historical data set to regularly update the multi-layer neural network P, so that the multi-layer neural network can achieve higher accuracy.
[0221] In step S5, when the code compilation is completed, the local compilation task can directly obtain the converted target code, while the task compiled on the edge server needs to return the compiled target code through the network communication interface. When all terminal devices obtain their expected target code, the entire compilation process ends.
[0222] When applying, the local compiler is called on terminal device 2, and its results are directly available; the code segment to be compiled on terminal device 5 is compiled by calling the IEC61131 compiler on edge server 3, and its results need to be transmitted through the network interface before use. Although it needs to be transmitted through the network interface, which causes a certain delay, the edge server has stronger computing power, so it can better ensure that the code segment to be compiled on terminal device 5 is completed before its set deadline.
[0223] To sum up, with the help of the above-mentioned technical scheme of the present invention, by comprehensively considering the computing power, load conditions and properties of the terminal device and edge server, the unloading strategy of the code segment to be compiled is optimized by using the game theory decision algorithm, and the intelligent allocation of the code segment to be compiled is realized, which can not only improve the compilation efficiency, but also balance the load and power consumption of the system, thereby improving the performance and reliability of the entire system; at the same time, it can improve the compilation efficiency, and the terminal device can unload the code segment to be compiled to the resource-rich edge node to obtain a quick response and execution, reduce the compilation time delay, and enable the terminal device to update the program more quickly and respond to real-time needs, which also helps to improve a series of industrial processes such as subsequent program execution and the circulation and application of execution results, and accelerate the operation of the entire industrial chain. By considering multiple attributes of the code segment to be compiled, a rich and accurate data basis is provided for accurately evaluating the complexity of the code segment to be compiled and optimizing the compilation process, which helps to more finely control the allocation of the code segment to be compiled to further improve the optimization effect; at the same time, the scope of information is further expanded to facilitate a comprehensive evaluation of the status of the terminal device and the edge server; in addition, dynamically updating this information can adapt to changes in real time and improve the real-time and accuracy of decision-making; in addition, the present invention not only takes into account the optimization goals of each terminal device, but also maximizes the use of real-time limited resources in the system from the perspective of the entire system to ensure a higher punctuality rate. The present invention determines the compilation delay and power consumption cost at different compilation locations (terminal device or edge server), provides specific and operational evaluation indicators for the optimization of the code segment to be compiled, helps the system select the optimal compilation location according to actual needs, and achieves a balance between compilation efficiency and energy consumption; at the same time, clarifies the optimization goals of the code segment to be compiled, and provides a clear direction for the optimization of the code segment to be compiled.
[0224] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A programming language compilation method based on end-edge collaboration, characterized in that: The method comprises the following steps: S1. Obtain device information of the terminal device and status information of the edge server; S2. extracting the code segments to be compiled contained in the device information in real time, and creating a compilation task attribute set based on the code attributes of the code segments to be compiled; S3, setting the optimization target of the code segment to be compiled, and obtaining the compilation position of the code segment to be compiled by building a game model and matching the uninstallation strategy set; S4. Based on the compilation position, call the compiler to compile the code segment to be compiled, and dynamically update the compilation information of the compilation position according to the compilation result; S5. Respond to the dynamic update of the compilation information and receive the compilation result at the terminal device.
2. The programming language compilation method based on end-edge collaboration according to claim 1, characterized in that: The device information of the terminal device includes: computing capability of the terminal device, current load of the terminal device, code segments to be compiled, and power consumption cost of the local compiled code of the terminal device; The edge server status information includes: edge server computing capacity, edge server current load, edge server network bandwidth, edge server communication bandwidth, edge server power consumption cost when executing computing tasks, and wireless transmission power consumption cost of the base station terminal device where the edge server is located.
3. The programming language compilation method based on end-edge collaboration according to claim 1, characterized in that: The step of creating a compilation task attribute set based on the code attributes of the code segment to be compiled comprises the following steps: S21, extracting code attributes of the code segment to be compiled, wherein the code attributes include: length, number of lines, amount of text, number of characters, number of variables, number of loops, number of conditional branches, expected deadline of the code segment to be compiled, sensitivity weight of the code segment to be compiled to compilation delay, and sensitivity weight of the code segment to be compiled to power consumption cost; S22. Define model input and model output, build a neural network model based on the code attributes of the historical code segments to be encoded and their known computational complexity, and use the Golden Eagle optimization algorithm to optimize model parameters; S23, inputting the code attributes extracted in real time into the neural network model to calculate the computational complexity of the code segment to be compiled; S24, integrating the code attributes and computational complexity of the code segments to be compiled, and constructing a compilation task attribute set, wherein the expression of the compilation task attribute set is: F={size,f req ,ddl,w a ,w b } Where F is the compilation task attribute set; size is the amount of text in the code segment to be compiled; f req The estimated amount of computation required to complete the code segment to be compiled; ddl is the expected deadline for the code segment to be compiled; w a is the sensitivity weight of the code segment to be compiled to the compilation delay; w b is the sensitivity weight of the code segment to be compiled to the power consumption cost.
4. The programming language compilation method based on end-edge collaboration according to claim 3, characterized in that: The steps of defining the model input and the model output, combining the code attributes of the historical code segments to be encoded and the known computational amount thereof, constructing a neural network model, and optimizing the model parameters using the Golden Eagle optimization algorithm include the following steps: S221, define the code attribute as an input variable, and the amount of calculation required to complete the code segment to be compiled as an output variable; S222, obtaining the code attributes of the historical code segments to be encoded and their known calculation amounts, performing association analysis and standardization processing, and dividing the code into training sets and test sets; S223, select a gated recurrent unit neural network to build a neural network model, and initialize the hyperparameters of the neural network model, wherein the hyperparameters include a time window step, a number of neurons, a learning rate, and a number of training times; S224, optimizing the model parameters using the Golden Eagle optimization algorithm and calculating the model fitness; S225. Construct and optimize a neural network model using optimal model parameters, and use the training set to train the model to obtain a final neural network model for predicting the computational amount of the code segment to be compiled.
5. The programming language compilation method based on end-edge collaboration according to claim 4, characterized in that: The method of obtaining the code attributes of the historical code segments to be encoded and the known computational amount thereof, performing association analysis and standardization processing, and dividing the training set and the test set comprises the following steps: S2221, obtaining code attributes of historical code segments to be encoded as associated indicators participating in calculation amount evaluation, and obtaining known calculation amounts of historical code segments to be encoded; S2222. Calculate the correlation coefficients between different correlation indicators and known calculation amounts through the Pearson correlation coefficient, set a correlation threshold, select correlation indicators that meet the correlation threshold, and assign weight coefficients to each of them; S2223. Integrate the known computing amount and the retained related indicators, construct a historical data set, and divide it into a training set and a test set according to a preset ratio.
6. The programming language compilation method based on end-edge collaboration according to claim 5, characterized in that: The method of optimizing the model parameters by using the Golden Eagle optimization algorithm and calculating the model fitness comprises the following steps: S2241. Initialize the number and population size of golden eagles, and initialize the attack coefficient and cruise coefficient; S2242. The golden eagle individual randomly adjusts its own position based on the position information of itself and other individuals, and updates the position information of each golden eagle individual in the population; S2243, calculating the fitness function to initialize the population memory, and randomly selecting prey from the attack vector calculated from the population memory; S2244, calculating the cruise vector and the step vector, and updating the fitness function of the position evaluation new position; S2245, update the search and supply phase, and update the optimal solution and optimal position; S2246. Determine whether the maximum number of iterations is met. If so, output the current optimal golden eagle position and the global optimal solution. If not, return to step S2242.
7. The programming language compilation method based on end-edge collaboration according to claim 2, characterized in that: The step of setting the optimization target of the code segment to be compiled, and obtaining the compilation position of the code segment to be compiled by building a game model and matching the uninstallation strategy set comprises the following steps: S31, respectively calculating the compilation delay and power consumption cost of the terminal device and the edge server, and calculating the total compilation cost and on-time rate of the code segment to be compiled in combination with the sensitivity weight; S32, defining minimizing the total compilation cost and maximizing the on-time rate as optimization goals; S33, defining the terminal device as a participant, constructing a participant set, and establishing a participant priority formula in combination with code attributes to calculate the priority of each terminal device in participating in the game; S34. Based on the decision-making algorithm of game theory, a game model is established, and the compilation task attribute set is combined to match the uninstallation strategy set of the terminal device, and finally the compilation position of the code segment to be compiled is obtained.
8. The programming language compilation method based on end-edge collaboration according to claim 7, characterized in that: The expression of the participant priority formula is: In the formula, priority i The priority of terminal device i in participating in the game; ddl is the expected deadline for the code segment to be compiled; f i req The estimated amount of computation required to complete the code segment to be compiled for terminal device i; f i u is the computing capability of terminal device i; w a is the sensitivity weight of the code segment to be compiled to the compilation delay.
9. The programming language compilation method based on end-edge collaboration according to claim 7, characterized in that: The decision algorithm based on game theory, establishing a game model, combining the compilation task attribute set, matching the uninstallation strategy set of the terminal device, and finally obtaining the compilation position of the code segment to be compiled includes the following steps: S341, defining an edge server as a candidate, constructing a candidate set, and the current load of each edge server in the candidate set does not exceed a load threshold; S342, construct a decision space, sort the participants according to their priority in the game from large to small, make each participant traverse the decision space, obtain the decision of each terminal device, and then write the decision of each terminal device into the uninstallation strategy set; S343: Based on the uninstallation policy set, identify the compilation location of each code segment to be compiled.
10. A programming language compilation device based on end-edge collaboration, used to implement the programming language compilation method based on end-edge collaboration according to any one of claims 1 to 9, characterized in that: The device includes: An information acquisition module is used to obtain device information of the terminal device and status information of the edge server; An extraction and creation module is used to extract the code segments to be compiled contained in the device information in real time, and create a compilation task attribute set based on the code attributes of the code segments to be compiled; The strategy matching module is used to set the optimization target of the code segment to be compiled, and obtain the compilation position of the code segment to be compiled by building a game model and matching the uninstallation strategy set; A compilation update module is used to call the compiler to compile the code segment to be compiled based on the compilation position, and dynamically update the compilation information of the compilation position according to the compilation result; The response feedback module is used to respond to the dynamic update of the compilation information and receive the compilation result on the terminal device.
