A data interaction method and system for microcomputer
By calculating the data transmission stability coefficient of the microcomputer and establishing a data synchronization topology map, combined with the Q-learning algorithm, the data synchronization path is automatically planned, which solves the problem of long artificial setting in the existing technology and improves the efficiency of network deployment.
Patent Information
- Application Number
- CN202410903822.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-07-08
AI Technical Summary
In existing microcomputer systems, the data synchronization paths between microcomputers need to be manually set, especially in complex topologies, which takes a long time and lacks automatic planning solutions.
By obtaining the data transmission parameters of the microcomputer, calculating the data transmission stability coefficient, establishing a data synchronization topology map, and using the Q-learning algorithm for reinforcement learning, the optimal data synchronization path is automatically generated.
It realizes automatic planning of data synchronization paths without the need for manual setting, improves network deployment efficiency, and is suitable for a variety of scenarios, including smart home systems.
Smart Images

Figure CN118449962B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electric data interactive interconnection and transmission, and in particular to a data interactive method and system for a microcomputer. Background Art
[0002] Microcomputers usually refer to small, fully functional computer devices suitable for various scenarios. These microcomputers can realize monitoring, data collection and control, effectively improving production work or the quality of life. Data interaction between microcomputers is an indispensable function, and data synchronization is the most important part of it.
[0003] Data synchronization between microcomputers refers to the real-time or regular update of data between different microcomputers to ensure that the data between them remains consistent and up-to-date, thereby achieving collaborative work and information sharing. On this basis, the data synchronization paths between microcomputers are also very important. These paths directly affect the efficiency, stability and latency of data synchronization. Well-optimized data synchronization paths can ensure fast and reliable data transmission, reduce data transmission latency, and reduce the possibility of data loss or errors. By carefully designing the paths, the overall performance of the system can be maximized and ensure effective operation in various usage scenarios.
[0004] However, in current microcomputer systems, data synchronization paths between microcomputers often need to be manually set, which is extremely cumbersome and inconvenient. In particular, the setting of data synchronization paths under complex topological structures often consumes a lot of time. Therefore, people are in urgent need of a solution that can automatically plan data synchronization paths. Summary of the invention
[0005] Therefore, the present invention provides a data interaction method and system for microcomputers, so as to solve the problem of how to automatically plan data synchronization paths between microcomputers in the prior art.
[0006] The present invention provides a data interaction method for a microcomputer, comprising:
[0007] Acquire the data transmission parameters of each microcomputer in the target microcomputer network and the data transmission parameters of the target microcomputer, wherein the target microcomputer is a microcomputer to be added to the target microcomputer network;
[0008] According to the data transmission parameters, the data transmission stability coefficient between each two microcomputers is calculated, and the data transmission stability coefficient is used to characterize the stability of the data transmission between the two microcomputers;
[0009] Taking microcomputers as nodes, the data synchronization forwarding relationship between two microcomputers as edges, and the data transmission stability coefficient as the weight of the edge, a data synchronization topology diagram between a target microcomputer network and a target microcomputer is established;
[0010] According to the data synchronization topology diagram, the optimal Q table is obtained by reinforcement learning based on the Q-learning algorithm, where the Q table is used to characterize the stability of each microcomputer forwarding data to different microcomputers;
[0011] A target data synchronization path is determined according to the optimal Q table, and the target microcomputer is added to the target microcomputer network based on the target data synchronization path.
[0012] The present invention also provides a preferred solution: the data transmission parameters include the location coordinates, usage frequency, data collection volume, data throughput and performance evaluation value of the microcomputer.
[0013] The present invention also provides a preferred solution: the step of calculating the data transmission stability coefficient between each two microcomputers according to the data transmission parameters comprises:
[0014] The data transmission stability coefficient between two microcomputers is calculated by the following formula:
[0015] ;
[0016] in, is the data transmission stability coefficient between two microcomputers, is the natural logarithm function, is the distance between the two microcomputers, is a natural constant, is the maximum value between the usage frequencies of the two microcomputers, is the minimum value between the data throughput of the two microcomputers, is the minimum value between the performance evaluation values of the two microcomputers, is the maximum value between the data collection amounts of the two microcomputers, , , , and They are different weight coefficients respectively.
[0017] The present invention also provides a preferred solution: the data synchronization topology diagram of the target microcomputer network and the target microcomputer is established with the microcomputer as a node, the data synchronization forwarding relationship between two microcomputers as an edge, and the data transmission stability coefficient as the edge weight, including:
[0018] Acquire the data synchronization path of the target microcomputer network;
[0019] An initial topology diagram representing the data synchronization forwarding relationship of the target microcomputer network is established by taking the microcomputers in the target microcomputer network as nodes, the data synchronization paths as edges, and the data transmission stability coefficient as the edge weights;
[0020] A target node corresponding to the target microcomputer is established, and the data transmission stability coefficient is used as the edge weight. The target node is connected to all the nodes in the initial topology map to obtain a data synchronization topology map.
[0021] The present invention also provides a preferred solution: the method of obtaining an optimal Q table by performing reinforcement learning based on a Q-learning algorithm according to the data synchronization topology diagram includes:
[0022] According to the nodes in the data synchronization topology diagram, multiple states are defined, and the state corresponding to the node corresponding to the target microcomputer is defined as the target state, wherein each state corresponds to a node, and each state is used to represent that the microcomputer corresponding to the node corresponding to the state receives data;
[0023] According to the nodes in the data synchronization topology diagram, a plurality of actions are defined, each action corresponds to a node, wherein each action is used to represent forwarding data to a microcomputer corresponding to the node corresponding to the state;
[0024] Establish an initial Q table based on the state and nodes;
[0025] Define the reward value corresponding to each state;
[0026] Based on the initial Q-table, according to the reward value and the weight of the edge in the data synchronization topology graph, reinforcement learning is performed based on the Q-learning algorithm to obtain the optimal Q-table.
[0027] The present invention also provides a preferred solution: the reward value includes a first reward value, a second reward value and a third reward value; the definition of the reward value corresponding to each state includes:
[0028] Define the reward value corresponding to reaching the target state as the first reward value;
[0029] If a state cannot be achieved, the reward value of the state is defined as the second reward value;
[0030] If a state is not a target state and can be achieved, the reward value of the state is defined as the third reward value;
[0031] The first reward value and the third reward value are both positive numbers, and the first reward value is greater than the third reward value, the second reward value is a negative number, and the first reward value and the second reward value satisfy the following relationship:
[0032] ;
[0033] Among them, || is the absolute value symbol, is the first reward value, is the second reward value, The number of nodes in the data synchronization topology diagram.
[0034] The present invention also provides a preferred solution: based on the initial Q table, according to the reward value and the weight of the edge in the data synchronization topology graph, reinforcement learning is performed based on the Q-learning algorithm to obtain the optimal Q table, including:
[0035] Step 1: Based on the initial Q table, randomly select a state as the current state;
[0036] Step 2: Randomly select an action in the current state as the target action,
[0037] Step 3: Update the Q value corresponding to the target action in the current state in the initial Q table according to the edge weight, current state and target action in the data synchronization topology graph;
[0038] Step 4: Obtain the reward value of the state reached after executing the target action in the current state as the target judgment reward value. If the target judgment reward value is a positive number, the state reached after executing the target action in the current state is taken as the new current state.
[0039] Step 5: Repeat steps 2 to 4 until the current state reaches the target state;
[0040] Step 6: Repeat steps 1 to 5 until the preset end condition is reached and the optimal Q table is obtained.
[0041] The present invention also provides a preferred solution: Step 3: updating the Q value corresponding to the target action in the current state in the initial Q table according to the weight, current state and target action of the edge in the data synchronization topology graph, including:
[0042] Get the reward value of the state reached after executing the target action in the current state as the initial reward value;
[0043] According to the weight of the edge corresponding to the target action of the current state in the data synchronization topology graph, the initial reward value is corrected to obtain the target reward value;
[0044] According to the current state and target state, based on the target reward value, the Q value corresponding to the target action in the current state in the initial Q table is updated through the Bellman equation.
[0045] The present invention also provides a preferred solution: the initial reward value is corrected according to the weight of the edge corresponding to the target action in the current state in the data synchronization topology graph to obtain the target reward value, including:
[0046] Correct the initial reward value by the following formula:
[0047] ;
[0048] in, is the target reward value, is the initial reward value, is a natural constant, is the weight of the edge corresponding to the target action of the current state in the data synchronization topology graph, is the preset zoom factor.
[0049] The present invention also provides a microcomputer data interaction system, comprising:
[0050] A data preparation module, used for acquiring data transmission parameters of each microcomputer in the target microcomputer network and data transmission parameters of the target microcomputer, wherein the target microcomputer is a microcomputer to be added to the target microcomputer network;
[0051] A transmission evaluation module, used for calculating the data transmission stability coefficient between each two microcomputers according to the data transmission parameters, wherein the data transmission stability coefficient is used to characterize the stability of the data transmission between the two microcomputers;
[0052] An analysis preparation module is used to establish a data synchronization topology diagram between a target microcomputer network and a target microcomputer, taking a microcomputer as a node, a data synchronization forwarding relationship between two microcomputers as an edge, and a data transmission stability coefficient as an edge weight;
[0053] A data analysis module is used to obtain an optimal Q table by performing reinforcement learning based on a Q-learning algorithm according to a data synchronization topology diagram, wherein the Q table is used to characterize the stability of each microcomputer forwarding data to different microcomputers;
[0054] The synchronization interaction module is used to determine the target data synchronization path according to the Q table, and add the target microcomputer to the target microcomputer network based on the target data synchronization path.
[0055] The beneficial effects of adopting the above embodiment are:
[0056] The present invention provides a data interaction method for a microcomputer, which calculates the data transmission stability coefficient between each two microcomputers through data transmission parameters, then establishes a data synchronization topology diagram of a target microcomputer network and a target microcomputer through the data transmission stability coefficient, then performs reinforcement learning based on a Q-learning algorithm to obtain an optimal Q table according to the data synchronization topology diagram, and finally determines a target data synchronization path through the Q table, and adds the target microcomputer to the target microcomputer network based on the target data synchronization path, thereby realizing the joining of the target microcomputer to the network and automatically completing the planning of its data synchronization path. Compared with the prior art, the present invention establishes a data synchronization topology diagram representing the data transmission path and data transmission stability between each microcomputer through a data transmission stability coefficient, and then uses the self-learning ability of the Q-learning algorithm on the basis of the data synchronization topology diagram to realize the search and planning of the optimal path, thereby realizing the function of automatically planning the data synchronization path without the need for manual setting, which can greatly improve the efficiency of network deployment and has good practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 A method flow chart of an embodiment of a data interaction method for a microcomputer provided by the present invention;
[0058] Figure 2 for Figure 1 The method flow chart of step S104;
[0059] Figure 3 A method flow chart of an embodiment of a microcomputer data interaction system provided by the present invention. DETAILED DESCRIPTION
[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0061] Combination Figure 1 As shown, a specific embodiment of the present invention discloses a data interaction method of a microcomputer, comprising:
[0062] S101, obtaining data transmission parameters of each microcomputer in the target microcomputer network and data transmission parameters of the target microcomputer, wherein the target microcomputer is a microcomputer to be added to the target microcomputer network;
[0063] S102, calculating the data transmission stability coefficient between each two microcomputers according to the data transmission parameters, where the data transmission stability coefficient is used to characterize the stability of the data transmission between the two microcomputers;
[0064] S103, establishing a data synchronization topology diagram between a target microcomputer network and a target microcomputer, with the microcomputer as a node, the data synchronization forwarding relationship between two microcomputers as an edge, and the data transmission stability coefficient as the edge weight;
[0065] S104, performing reinforcement learning based on a Q-learning algorithm according to the data synchronization topology diagram to obtain an optimal Q table, wherein the Q table is used to characterize the stability of each microcomputer forwarding data to different microcomputers;
[0066] S105 . Determine a target data synchronization path according to the optimal Q table, and add the target microcomputer to the target microcomputer network based on the target data synchronization path.
[0067] In the above process, data transmission parameters refer to parameters related to data transmission performance. The data synchronization topology graph refers to a graph structure that represents the data synchronization path. Two connected nodes in the data synchronization topology graph indicate that there is a data forwarding path between the two corresponding microcomputers that can be used for data synchronization (the path is a virtual path in most cases, and the two microcomputers communicate wirelessly).
[0068] The Q-learning algorithm is a classic reinforcement learning method that aims to learn how to make the best decision-making strategy through interaction with the environment to maximize long-term cumulative rewards. In this algorithm, the agent does not need to know the specific model of the environment in advance, but observes the immediate rewards obtained after performing each action and updates a table called the Q-value function based on these rewards, that is, the Q table in this embodiment. The Q table evaluates the potential return of taking each action in each state, thereby helping the agent decide which action to take in any given state.
[0069] One of the main advantages of Q-learning is its simplicity and wide applicability. Since it does not require prior knowledge of the environment model, it can be applied to many real-world problems. In addition, the Q-learning algorithm gradually optimizes the agent's strategy by iteratively updating the Q-value function, and ultimately enables the agent to learn the optimal behavior strategy in an unknown environment. This learning method enables Q-learning to strike a balance between exploration and exploitation, effectively deal with complex decision-making problems, and perform well in many cases.
[0070] In the Q-learning algorithm, the Q-table (also called the Q-value function table) is a two-dimensional array that stores the Q-value of each state-action pair. Each row represents a state, and each column represents an action that can be performed in that state. Each element Q(s,a) in the Q-table represents the expected cumulative reward that can be obtained after performing action a in state s. The Q-table is continuously updated during the learning process of the algorithm so that the agent can maximize the long-term cumulative reward based on the existing experience and rewards.
[0071] Compared with the prior art, the present invention establishes a data synchronization topology diagram representing the data transmission path and data transmission stability between each microcomputer through the data transmission stability coefficient, and then, based on the data synchronization topology diagram, utilizes the self-learning ability of the Q-learning algorithm to realize the search and planning of the optimal path, thereby realizing the function of automatically planning the data synchronization path without manual setting, which can greatly improve the efficiency of network deployment and has good practicality.
[0072] The present invention can be applied to a variety of scenarios, a typical application scenario is the smart home system. For example, in this scenario, each room has a microcomputer (such as smart lamps, smart routers and other smart furniture) to control lights, temperature, security systems, etc. These microcomputers need to communicate with microcomputers in other rooms to achieve coordinated operation and data synchronization of home devices. For example, when leaving home, the microcomputer near the door can tell other microcomputers to turn off the lights and strengthen the security system.
[0073] On this basis, in a preferred embodiment, the data transmission parameters include the location coordinates of the microcomputer, the frequency of use, the amount of data collected, the data throughput and the performance evaluation value. Among them, the location coordinates are the location of the device corresponding to the microcomputer. Obviously, when the two smart home devices are far apart, the data transmission stability is poor. The frequency of use is the frequency at which the microcomputer is turned on or starts working. The lower the frequency of use, the more idle time the microcomputer has to forward data, and the better the effect can be achieved by forwarding data synchronization through it. The amount of data collected can be understood as the amount of data required for the microcomputer to perform its own functions, such as the number of temperature sensors in a smart kettle, which represents the workload of the microcomputer itself. Obviously, the lower the value, the lower the pressure of synchronous forwarding data. The data throughput is the ability of the microcomputer to forward data, and the performance evaluation value is a man-made value for evaluating the performance of the microcomputer. The value can be formulated according to actual conditions, for example, based on the size of the computer's storage space, the size of the bandwidth, the word length of the central processing unit and other factors.
[0074] Specifically, in a preferred embodiment, the above step S102, calculating the data transmission stability coefficient between every two microcomputers according to the data transmission parameters, specifically includes:
[0075] The data transmission stability coefficient between two microcomputers is calculated by the following formula:
[0076] ;
[0077] in, is the data transmission stability coefficient between two microcomputers, is the natural logarithm function, is the distance between the two microcomputers, is a natural constant, is the maximum value between the usage frequencies of the two microcomputers, is the minimum value between the data throughput of the two microcomputers, is the minimum value between the performance evaluation values of the two microcomputers, is the maximum value between the data collection amounts of the two microcomputers, , , , and They are different weight coefficients respectively.
[0078] The significance of the above formula is that a coefficient that can characterize the stability of data transmission is obtained through a variety of data transmission parameters. The first item in the above formula can calculate the distance through the coordinate data between the two microcomputers, and then take the logarithm of the distance to eliminate the marginal diminishing benefits of the distance, that is, when the distance exceeds a certain degree, the impact on the stability of data transmission tends to be the same, and it is meaningless to further increase the value of the data transmission stability coefficient. In the second item, the data transmission stability coefficient is controlled according to the frequency of use, data collection volume, data throughput and performance evaluation value. Among them, the higher the frequency of use, the lower the stability of data transmission. The larger data collection volume between the two microcomputers will affect the lower limit of the data synchronization path, and the smaller data throughput and smaller performance evaluation value between the two microcomputers will also affect the lower limit of data transmission stability.
[0079] Furthermore, the present invention can be applied not only to the search for the optimal data synchronization path of a new microcomputer network, but also to the addition of a new microcomputer to a known network.
[0080] Further, in a preferred embodiment, the above step S103, taking the microcomputer as a node, the data synchronization forwarding relationship between the two microcomputers as an edge, and the data transmission stability coefficient as the edge weight, establishes a data synchronization topology diagram between the target microcomputer network and the target microcomputer, specifically including:
[0081] Acquire the data synchronization path of the target microcomputer network;
[0082] An initial topology diagram representing the data synchronization forwarding relationship of the target microcomputer network is established by taking the microcomputers in the target microcomputer network as nodes, the data synchronization paths as edges, and the data transmission stability coefficient as the edge weights;
[0083] A target node corresponding to the target microcomputer is established, and the data transmission stability coefficient is used as the edge weight. The target node is connected to all the nodes in the initial topology map to obtain a data synchronization topology map.
[0084] The significance of the above process is that the initial topology is first established through the known data synchronization path of the known network (i.e., the target microcomputer network), and then, based on the initial topology, the target node is connected to each node in the initial topology to establish a data synchronization topology for reinforcement learning. In this way, the data synchronization topology not only contains the information of the existing optimal data synchronization path, but also includes the potential optimal data synchronization path between the target microcomputer and the target microcomputer network. The subsequent Q-learning algorithm only needs to find the optimal data synchronization path between the target microcomputer and the known target microcomputer network (i.e., find the optimal data synchronization path to the target microcomputer), without re-analyzing the entire network (i.e., establishing a complete topology with full connections between nodes), which greatly reduces the pressure of the Q-learning algorithm, reduces the amount of data to be analyzed, and significantly improves the algorithm speed.
[0085] Further, combined with Figure 2 As shown, in a preferred embodiment, the above step S104, according to the data synchronization topology diagram, performs reinforcement learning based on the Q-learning algorithm to obtain the optimal Q table, specifically includes:
[0086] S201, defining multiple states according to the nodes in the data synchronization topology diagram, and defining the state corresponding to the node corresponding to the target microcomputer as the target state, wherein each state corresponds to a node, and each state is used to represent that the microcomputer corresponding to the node corresponding to the state receives data;
[0087] S202, defining a plurality of actions according to the nodes in the data synchronization topology diagram, each action corresponding to a node, wherein each action is used to represent forwarding data to a microcomputer corresponding to the node corresponding to the state;
[0088] S203, establishing an initial Q table according to the state and nodes;
[0089] S204, defining the reward value corresponding to each state;
[0090] S205: Based on the initial Q-table, according to the reward value and the weight of the edge in the data synchronization topology graph, reinforcement learning is performed based on the Q-learning algorithm to obtain the optimal Q-table.
[0091] The Q table established through the above process is actually a square matrix, and the height and width of the Q table are equal to the number of nodes in the data synchronization topology diagram. Each row of the Q table corresponds to a state, that is, the state of "data arrives at a microcomputer corresponding to a node". Similarly, each column in the Q table corresponds to an action, that is, the action of "forwarding data to a microcomputer corresponding to a node". Obviously, because not every two nodes in the data synchronization topology diagram are connected to each other, there are also actions in the Q table that cannot be realized. For example, if there is no data synchronization path between the microcomputers corresponding to the two nodes, and there is no edge representing the path in the data synchronization topology diagram, then the state and action corresponding to the synchronization path in the Q table cannot be realized. Different from the prior art, in the present invention, when performing reinforcement learning, in addition to referring to the reward value, the weight of the edge in the data synchronization topology diagram is further referred to.
[0092] Further, in a preferred embodiment, the reward value includes a first reward value, a second reward value and a third reward value; the above step S204, defining the reward value corresponding to each state, specifically includes:
[0093] Define the reward value corresponding to reaching the target state as the first reward value;
[0094] If a state cannot be achieved, the reward value of the state is defined as the second reward value;
[0095] If a state is not a target state and can be achieved, the reward value of the state is defined as the third reward value;
[0096] The first reward value and the third reward value are both positive numbers, and the first reward value is greater than the third reward value, the second reward value is a negative number, and the first reward value and the second reward value satisfy the following relationship:
[0097] ;
[0098] Among them, || is the absolute value symbol, is the first reward value, is the second reward value, The number of nodes in the data synchronization topology diagram.
[0099] The above process defines reward values for the target state, the unachievable state, and the achievable state. The size relationship between different types of reward values makes the subsequent Q value update more intelligent. The size design between the above three types of reward values can make the achievable actions in the final Q table positive, while the unachievable actions are negative. On the one hand, it makes it easier for the computer to identify whether an action is achievable, and on the other hand, it can make the Q table converge to the optimal result more quickly.
[0100] In addition, the above design can also simplify the steps of updating the Q table, making the Q table update faster. Specifically, in a preferred embodiment, the above step S205, based on the initial Q table, according to the reward value and the weight of the edge in the data synchronization topology graph, based on the Q-learning algorithm, reinforcement learning is performed to obtain the optimal Q table, which specifically includes:
[0101] Step 1: Based on the initial Q table, randomly select a state as the current state;
[0102] Step 2: Randomly select an action in the current state as the target action,
[0103] Step 3: Update the Q value corresponding to the target action in the current state in the initial Q table according to the edge weight, current state and target action in the data synchronization topology graph;
[0104] Step 4: Obtain the reward value of the state reached after executing the target action in the current state as the target judgment reward value. If the target judgment reward value is a positive number, the state reached after executing the target action in the current state is taken as the new current state.
[0105] Step 5: Repeat steps 2 to 4 until the current state reaches the target state;
[0106] Step 6: Repeat steps 1 to 5 until the preset end condition is reached and the optimal Q table is obtained.
[0107] Compared with the prior art, step 2 and step 4 in the above process are different. In the prior art, in step 2, it is necessary to traverse the data synchronization topology map to find all executable actions. In this embodiment, the distinction of whether an action can be realized has been completed through the reward value, so in step 2, only the action needs to be randomly selected, which saves a lot of data reading and graph traversal processes, and shortens the algorithm running time. In this technology, step 4 in this embodiment can also determine whether the current state needs to be updated based on the positive or negative reward value, ensuring the stable operation of the algorithm.
[0108] Further, in a preferred embodiment, the step 3 in the above process: updating the Q value corresponding to the target action in the current state in the initial Q table according to the weight, current state and target action of the edge in the data synchronization topology graph, specifically includes:
[0109] Get the reward value of the state reached after executing the target action in the current state as the initial reward value;
[0110] According to the weight of the edge corresponding to the target action of the current state in the data synchronization topology graph, the initial reward value is corrected to obtain the target reward value;
[0111] According to the current state and target state, based on the target reward value, the Q value corresponding to the target action in the current state in the initial Q table is updated through the Bellman equation.
[0112] The above process corrects the initial reward value through the weight of the corresponding edge in the data synchronization topology (i.e., the data transmission stability coefficient between the two microcomputers), so that the result of the final updated Q table is more in line with the actual situation. For example, when the weight of the corresponding edge in the data synchronization topology is large, it means that the data transmission stability coefficient between the two microcomputers corresponding to the two nodes connected by the edge is large. At this time, the stability of data transmission between the two microcomputers is poor, so at this time, the reward value of the state achieved by the actions corresponding to the two nodes should be reduced.
[0113] Specifically, in a preferred embodiment, according to the weight of the edge corresponding to the target action of the current state in the data synchronization topology graph, the initial reward value is corrected to obtain the target reward value, which specifically includes:
[0114] Correct the initial reward value by the following formula:
[0115] ;
[0116] in, is the target reward value, is the initial reward value, is a natural constant, is the weight of the edge corresponding to the target action of the current state in the data synchronization topology graph, is the preset zoom factor.
[0117] The above formula is based on the weight of the edge corresponding to the target action of the current state in the data synchronization topology graph, that is, the data transmission stability coefficient between the two microcomputers, and controls the target reward value between 0.5 and 1 times the initial reward value. The larger the weight of the edge corresponding to the target action of the current state in the data synchronization topology graph, the smaller the final target reward value.
[0118] In practice, the Bellman method is usually used to update the Q value:
[0119] Q n (s,a)=(1-α) × Q c (s,a)+α × [R(s,a)+γ × maxQ(s',a ’ )- Q c (s,a)] ;
[0120] in, is the current state, For the target action, is the state achieved after executing the target action in the current state, is the Q value corresponding to the target action in the current state in the updated initial Q table, is the Q value corresponding to the target action in the current state in the initial Q table before updating, is the maximum Q value in the initial Q table corresponding to the state reached after executing the target action in the current state, is the preset learning rate, is the preset discount factor, is the reward value of the state reached after executing the target action in the current state. It can be used as the initial reward value in the previous article for correction, that is, using the target reward value in the previous article replace , we can get the Q value that is more in line with the actual situation after being corrected according to the weights in the data synchronization topology graph.
[0121] Further, in a preferred embodiment, the above step S105, determining the target data synchronization path according to the optimal Q table, and adding the target microcomputer to the target microcomputer network based on the target data synchronization path, specifically includes:
[0122] According to the optimal Q table, at least two optimal paths to the node corresponding to the target microcomputer are obtained;
[0123] The target microcomputer is added to the target microcomputer network according to at least two optimal paths to the node corresponding to the target microcomputer.
[0124] In this way, the target microcomputer is added to the network, and the data synchronization path of the target computer is automatically analyzed. The two paths can ensure that the new network has sufficient stability and robustness.
[0125] Combination Figure 3 As shown, the present invention also provides a data interaction system for a microcomputer, comprising:
[0126] The data preparation module 310 is used to obtain the data transmission parameters of each microcomputer in the target microcomputer network and the data transmission parameters of the target microcomputer, wherein the target microcomputer is a microcomputer to be added to the target microcomputer network;
[0127] A transmission evaluation module 320, for calculating a data transmission stability coefficient between each two microcomputers according to the data transmission parameters, wherein the data transmission stability coefficient is used to characterize the stability of the data transmission between the two microcomputers;
[0128] An analysis preparation module 330 is used to establish a data synchronization topology diagram between a target microcomputer network and a target microcomputer, using a microcomputer as a node, a data synchronization forwarding relationship between two microcomputers as an edge, and a data transmission stability coefficient as an edge weight;
[0129] The data analysis module 340 is used to perform reinforcement learning based on the Q-learning algorithm according to the data synchronization topology diagram to obtain an optimal Q table, wherein the Q table is used to characterize the stability of each microcomputer forwarding data to different microcomputers;
[0130] The synchronization interaction module 350 is used to determine the target data synchronization path according to the Q table, and add the target microcomputer to the target microcomputer network based on the target data synchronization path.
[0131] It should be noted here that the corresponding system provided in the above embodiments can implement the technical solutions described in the above method embodiments. The specific implementation principles of the above modules or units can be found in the corresponding contents in the above method embodiments, which will not be repeated here.
[0132] The present invention provides a data interaction method for a microcomputer, which calculates the data transmission stability coefficient between each two microcomputers through data transmission parameters, then establishes a data synchronization topology diagram of a target microcomputer network and a target microcomputer through the data transmission stability coefficient, then performs reinforcement learning based on a Q-learning algorithm to obtain an optimal Q table according to the data synchronization topology diagram, and finally determines a target data synchronization path through the Q table, and adds the target microcomputer to the target microcomputer network based on the target data synchronization path, thereby realizing the joining of the target microcomputer to the network and automatically completing the planning of its data synchronization path. Compared with the prior art, the present invention establishes a data synchronization topology diagram representing the data transmission path and data transmission stability between each microcomputer through a data transmission stability coefficient, and then uses the self-learning ability of the Q-learning algorithm on the basis of the data synchronization topology diagram to realize the search and planning of the optimal path, thereby realizing the function of automatically planning the data synchronization path without the need for manual setting, which can greatly improve the efficiency of network deployment and has good practicality.
[0133] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0134] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data interaction method for a microcomputer, characterized in that: include: Acquire the data transmission parameters of each microcomputer in the target microcomputer network and the data transmission parameters of the target microcomputer, wherein the target microcomputer is a microcomputer to be added to the target microcomputer network; According to the data transmission parameters, the data transmission stability coefficient between each two microcomputers is calculated, and the data transmission stability coefficient is used to characterize the stability of the data transmission between the two microcomputers; Taking microcomputers as nodes, the data synchronization forwarding relationship between two microcomputers as edges, and the data transmission stability coefficient as the weight of the edge, a data synchronization topology diagram between a target microcomputer network and a target microcomputer is established; According to the data synchronization topology diagram, the optimal Q table is obtained by reinforcement learning based on the Q-learning algorithm, where the Q table is used to characterize the stability of each microcomputer forwarding data to different microcomputers; determining a target data synchronization path according to the optimal Q table, and adding the target microcomputer to the target microcomputer network based on the target data synchronization path; Wherein, the data transmission parameters include the location coordinates, usage frequency, data collection volume, data throughput and performance evaluation value of the microcomputer; The step of calculating the data transmission stability coefficient between each two microcomputers according to the data transmission parameters comprises: The data transmission stability coefficient between two microcomputers is calculated by the following formula: ; in, is the data transmission stability coefficient between two microcomputers, is the natural logarithm function, is the distance between the two microcomputers, is a natural constant, is the maximum value between the usage frequencies of the two microcomputers, is the minimum value between the data throughput of the two microcomputers, is the minimum value between the performance evaluation values of the two microcomputers, is the maximum value between the data collection amounts of the two microcomputers, , , , and They are different weight coefficients respectively; The method of establishing a data synchronization topology diagram between a target microcomputer network and a target microcomputer with a microcomputer as a node, a data synchronization forwarding relationship between two microcomputers as an edge, and a data transmission stability coefficient as an edge weight includes: Acquire the data synchronization path of the target microcomputer network; An initial topology diagram representing the data synchronization forwarding relationship of the target microcomputer network is established by taking the microcomputers in the target microcomputer network as nodes, the data synchronization paths as edges, and the data transmission stability coefficient as the edge weights; Establish a target node corresponding to the target microcomputer, use the data transmission stability coefficient as the edge weight, connect the target node with all the nodes in the initial topology map, and obtain a data synchronization topology map; The method of obtaining the optimal Q table by performing reinforcement learning based on the Q-learning algorithm according to the data synchronization topology graph includes: According to the nodes in the data synchronization topology diagram, multiple states are defined, and the state corresponding to the node corresponding to the target microcomputer is defined as the target state, wherein each state corresponds to a node, and each state is used to represent that the microcomputer corresponding to the node corresponding to the state receives data; According to the nodes in the data synchronization topology diagram, a plurality of actions are defined, each action corresponds to a node, wherein each action is used to represent forwarding data to a microcomputer corresponding to the node corresponding to the state; Establish an initial Q table based on the state and nodes; Define the reward value corresponding to each state; Based on the initial Q-table, according to the reward value and the weight of the edge in the data synchronization topology graph, reinforcement learning based on the Q-learning algorithm is used to obtain the optimal Q-table; The reward value includes a first reward value, a second reward value and a third reward value; the definition of the reward value corresponding to each state includes: Define the reward value corresponding to reaching the target state as the first reward value; If a state cannot be achieved, the reward value of the state is defined as the second reward value; If a state is not a target state and the state can be achieved, the reward value of the state is defined as a third reward value; The first reward value and the third reward value are both positive numbers, and the first reward value is greater than the third reward value, the second reward value is a negative number, and the first reward value and the second reward value satisfy the following relationship: ; in, is the absolute value symbol, is the first reward value, is the second reward value, is the number of nodes in the data synchronization topology diagram; The method of obtaining the optimal Q table by performing reinforcement learning based on the Q-learning algorithm according to the reward value and the weight of the edge in the data synchronization topology graph based on the initial Q table includes: Step 1: Based on the initial Q table, randomly select a state as the current state; Step 2: Randomly select an action in the current state as the target action, Step 3: Update the Q value corresponding to the target action in the current state in the initial Q table according to the edge weight, current state and target action in the data synchronization topology graph; Step 4: Obtain the reward value of the state reached after executing the target action in the current state as the target judgment reward value. If the target judgment reward value is a positive number, the state reached after executing the target action in the current state is taken as the new current state. Step 5: Repeat steps 2 to 4 until the current state reaches the target state; Step 6: Repeat steps 1 to 5 until the preset end condition is reached and the optimal Q table is obtained.
2. The data interaction method of a microcomputer according to claim 1, characterized in that: The step 3: updating the Q value corresponding to the target action in the current state in the initial Q table according to the weight of the edge in the data synchronization topology graph, the current state and the target action, includes: Get the reward value of the state reached after executing the target action in the current state as the initial reward value; According to the weight of the edge corresponding to the target action of the current state in the data synchronization topology graph, the initial reward value is corrected to obtain the target reward value; According to the current state and target state, based on the target reward value, the Q value corresponding to the target action in the current state in the initial Q table is updated through the Bellman equation.
3. The data interaction method of a microcomputer according to claim 2, characterized in that: The method of correcting the initial reward value according to the weight of the edge corresponding to the target action in the current state in the data synchronization topology graph to obtain the target reward value includes: Correct the initial reward value by the following formula: ; in, is the target reward value, is the initial reward value, is a natural constant, is the weight of the edge corresponding to the target action of the current state in the data synchronization topology graph, is the preset zoom factor.
4. A data interaction system for a microcomputer, characterized in that: include: A data preparation module, used for acquiring data transmission parameters of each microcomputer in the target microcomputer network and data transmission parameters of the target microcomputer, wherein the target microcomputer is a microcomputer to be added to the target microcomputer network; A transmission evaluation module, used for calculating the data transmission stability coefficient between each two microcomputers according to the data transmission parameters, wherein the data transmission stability coefficient is used to characterize the stability of the data transmission between the two microcomputers; An analysis preparation module is used to establish a data synchronization topology diagram between a target microcomputer network and a target microcomputer, taking a microcomputer as a node, a data synchronization forwarding relationship between two microcomputers as an edge, and a data transmission stability coefficient as an edge weight; A data analysis module is used to obtain an optimal Q table by performing reinforcement learning based on a Q-learning algorithm according to a data synchronization topology diagram, wherein the Q table is used to characterize the stability of each microcomputer forwarding data to different microcomputers; A synchronization interaction module, used to determine a target data synchronization path according to the Q table, and add a target microcomputer to a target microcomputer network based on the target data synchronization path; Wherein, the data transmission parameters include the location coordinates, usage frequency, data collection volume, data throughput and performance evaluation value of the microcomputer; The step of calculating the data transmission stability coefficient between each two microcomputers according to the data transmission parameters comprises: The data transmission stability coefficient between two microcomputers is calculated by the following formula: ; in, is the data transmission stability coefficient between two microcomputers, is the natural logarithm function, is the distance between the two microcomputers, is a natural constant, is the maximum value between the usage frequencies of the two microcomputers, is the minimum value between the data throughput of the two microcomputers, is the minimum value between the performance evaluation values of the two microcomputers, is the maximum value between the data collection amounts of the two microcomputers, , , , and are different weight coefficients respectively; The method of establishing a data synchronization topology diagram between a target microcomputer network and a target microcomputer with a microcomputer as a node, a data synchronization forwarding relationship between two microcomputers as an edge, and a data transmission stability coefficient as an edge weight includes: Acquire the data synchronization path of the target microcomputer network; An initial topology diagram representing the data synchronization forwarding relationship of the target microcomputer network is established by taking the microcomputers in the target microcomputer network as nodes, the data synchronization paths as edges, and the data transmission stability coefficient as the edge weights; Establish a target node corresponding to the target microcomputer, use the data transmission stability coefficient as the edge weight, connect the target node with all the nodes in the initial topology map, and obtain a data synchronization topology map; The method of obtaining the optimal Q table by performing reinforcement learning based on the Q-learning algorithm according to the data synchronization topology graph includes: According to the nodes in the data synchronization topology diagram, multiple states are defined, and the state corresponding to the node corresponding to the target microcomputer is defined as the target state, wherein each state corresponds to a node, and each state is used to represent that the microcomputer corresponding to the node corresponding to the state receives data; According to the nodes in the data synchronization topology diagram, a plurality of actions are defined, each action corresponds to a node, wherein each action is used to represent forwarding data to a microcomputer corresponding to the node corresponding to the state; Establish an initial Q table based on the state and nodes; Define the reward value corresponding to each state; Based on the initial Q-table, according to the reward value and the weight of the edge in the data synchronization topology graph, reinforcement learning based on the Q-learning algorithm is used to obtain the optimal Q-table; The reward value includes a first reward value, a second reward value and a third reward value; the definition of the reward value corresponding to each state includes: Define the reward value corresponding to reaching the target state as the first reward value; If a state cannot be achieved, the reward value of the state is defined as the second reward value; If a state is not a target state and the state can be achieved, the reward value of the state is defined as a third reward value; The first reward value and the third reward value are both positive numbers, and the first reward value is greater than the third reward value, the second reward value is a negative number, and the first reward value and the second reward value satisfy the following relationship: ; in, is the absolute value symbol, is the first reward value, is the second reward value, is the number of nodes in the data synchronization topology diagram; The method of obtaining the optimal Q table by performing reinforcement learning based on the Q-learning algorithm according to the reward value and the weight of the edge in the data synchronization topology graph based on the initial Q table includes: Step 1: Based on the initial Q table, randomly select a state as the current state; Step 2: Randomly select an action in the current state as the target action, Step 3: Update the Q value corresponding to the target action in the current state in the initial Q table according to the edge weight, current state and target action in the data synchronization topology graph; Step 4: Obtain the reward value of the state reached after executing the target action in the current state as the target judgment reward value. If the target judgment reward value is a positive number, the state reached after executing the target action in the current state is taken as the new current state. Step 5: Repeat steps 2 to 4 until the current state reaches the target state; Step 6: Repeat steps 1 to 5 until the preset end condition is reached and the optimal Q table is obtained.
