Disclosure of Invention
The invention aims to provide an application method, an application device and a storage medium of an intelligent gateway, which are used for solving the problems that the existing intelligent gateway is statically allocated, and resource allocation is fixed and cannot be adjusted according to real-time requirements under the condition of large data processing, so that resources are wasted or resources are insufficient in the process of demand.
In order to achieve the above object, the present invention provides an application method of an intelligent gateway, including the following steps:
s1, determining specific requirements and targets for traffic data acquisition to confirm gateway attributes, acquiring and transmitting the traffic data through end-side equipment, and transmitting the acquired traffic data to an edge intelligent gateway by the end-side equipment;
S2, traffic data from different terminal side devices are collected and aggregated, a cloud database for storing the data is created, and data preprocessing is carried out on the data in the cloud database;
S3, the edge intelligent gateway analyzes the preprocessed traffic data according to an anomaly detection algorithm model and identifies traffic data anomalies;
S4, based on the data analysis result, the edge intelligent gateway transmits an instruction to control the sensor to collect traffic data through the gateway management unit, and based on the dynamic resource allocation unit, the self-adaptive configuration of the gateway is realized.
As a further improvement of the present technical solution, in S1, the gateway attribute is confirmed to be used for selecting a suitable sensor for collecting traffic data, and the gateway attribute at least includes a physical interface attribute, a security attribute, a communication protocol support, a remote management capability and scalability.
As a further improvement of the technical scheme, in the step S2, the data preprocessing is used for cleaning, eliminating noise, processing missing values and abnormal values, reducing errors and deviations caused by low-quality data in the data analysis process, and improving the quality and applicability of the data.
As a further improvement of the technical scheme, in S3, the anomaly detection algorithm model is based on an isolated forest algorithm, and the algorithm formula is:
Where E (h, n) represents the path length of the traffic data point in the orphan tree; h (H-1) represents the average path length of the binary tree with height H-1; h represents the height of the orphan tree; n represents the total number of collected traffic data; n-1 represents the total number of collected traffic data-1;
The anomaly calculation formula is:
Wherein S (x, n, h) represents an anomaly score of traffic data x, x representing traffic data at a specific time; e (h, n) represents the path length of traffic data in the orphan tree; c (n) represents a constant for regularization, which depends on the size of the total number of traffic data.
The calculation of the anomaly score is adjusted by introducing weights, and the anomaly calculation formula after the weights are introduced is as follows:
ω represents an adjustment factor of the path length weight; adjusting the value of ω to control the influence degree of the path length E (h, n) on the anomaly score, wherein when ω is a positive value, the influence of the path length on the anomaly score is enhanced; when ω is a negative value, the influence of the path length on the anomaly score is weakened; when ω is zero, the effect of the path length on the anomaly score is eliminated, with only the constant c (n) acting.
As a further improvement of the present technical solution, in S4, the dynamic resource allocation unit dynamically allocates the traffic sensor resources based on the learning-enhanced multi-arm gambling algorithm, and the specific allocation steps are as follows:
s4.1, determining monitoring requirements of all areas by analyzing traffic data, historical traffic modes and a prediction model;
s4.2, resource allocation is carried out by considering the emergency degree of traffic conditions, the importance of areas and the monitoring capability of sensors;
S4.3, optimizing the distribution of resources according to different monitoring requirements and resource constraints based on a multi-arm gambling machine algorithm of reinforcement learning, and ensuring the optimization of the overall monitoring effect.
As a further improvement of the technical scheme, the multi-arm gambling machine algorithm for reinforcement learning is specifically as follows:
The probability formula for the selection sensor:
Wherein at represents the sensor selected at time step t; c represents an exploration parameter; t represents the number of time steps; qt (i) is an expected prize estimate for sensor i at time step t, representing the expected revenue situation of the intelligent gateway for the selected sensor i; nt (i) represents the number of times sensor i was selected before time step t, representing the cumulative number of times sensor i was selected in the past by the intelligent gateway;
The deployment formula of the sensor is:
Wherein Qt represents the motion value estimate at time step t; qt+1 represents the motion value estimate at time step t+1; qt+1(At) represents the motion value estimate corresponding to sensor at selected at time step t+1; qt(At) represents the motion value estimate corresponding to sensor at selected at time step t; nt(At) represents the number of times sensor at was selected before time step t; rt represents the actual benefit of the intelligent gateway in terms of the quality of the monitoring data obtained by the sensor At, the improvement of the efficiency of the traffic system and the enhancement of the safety in the time step t;
Since only the best known sensor formulation is selected, other opportunities for possibly better sensor formulation are missed, but if sensor formulation is performed too frequently, the best known formulation scheme is underutilized, so that the formulation formula of the sensor is optimized through a greedy strategy, and the optimized formulation formula is as follows:
Qt+1(At)=Qt(At)+a[Rt―Qt(At)];
wherein a represents a learning rate;
Wherein;
Specifically, f (at) represents the actual benefit value of the monitoring data obtained by sensor at at time step t;t Representing random noise terms.
As a further improvement of the technical scheme, the gateway management unit comprises an equipment interface state acquisition module, an equipment management module and a command issuing module;
The device interface state acquisition module is used for acquiring device interface state information, so that the device management module can monitor the device in real time;
the device management module is used for managing various physical devices connected to the edge intelligent gateway and ensuring the effective operation of the devices in the edge environment;
The command issuing module is used for sending a control command to the sensor equipment, receiving an allocation command sent by the dynamic resource allocation unit and realizing remote control and management allocation of the sensor equipment.
In another aspect, the present invention provides an intelligent gateway apparatus, comprising a sensor, a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method for applying an intelligent gateway as described in any one of the preceding claims when the computer program is executed by the processor.
As a further improvement of the technical scheme, the sensor at least comprises a traffic flow sensor, a traffic camera, a traffic signal sensor, a road state sensor and a traffic weather sensor.
In another aspect, the invention provides an intelligent gateway storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of any of the preceding claims.
Compared with the prior art, the invention has the beneficial effects that:
1. In the application method, the device and the storage medium of the intelligent gateway, the algorithm optimization is carried out on the sensor allocation through the greedy strategy, so that the waste of sensor resources can be reduced, the too frequent sensor resource reallocation is avoided, the unnecessary resource waste is reduced, and the utilization efficiency of the sensor resources is improved.
2. According to the application method, the device and the storage medium of the intelligent gateway, the edge intelligent gateway utilizes the dynamic resource allocation unit, so that the resource allocation of the gateway can be flexibly configured according to real-time traffic data acquisition requirements, and in the data acquisition process, the gateway can be adaptively adjusted according to factors such as data quantity and sensor types, so that the optimal utilization of resources and the efficient operation of a system are ensured.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1:
referring to fig. 1, the present embodiment provides an application method of an intelligent gateway, including the following steps:
S1, determining specific requirements and targets of traffic data acquisition, wherein the requirements and targets comprise information such as traffic flow, traffic jam conditions, vehicle positioning and the like; the gateway attribute is confirmed to be used for selecting a proper sensor for collecting traffic data, the gateway attribute at least comprises a physical interface attribute, a security attribute, communication protocol support, remote management capability and expandability, the purpose of the gateway attribute is to select a proper sensor for collecting traffic data, traffic flow, vehicle running speed and direction information are collected, the traffic data are collected and transmitted through end side equipment, further, the end side equipment refers to terminal equipment connected to an edge computing network, namely the sensor for collecting the traffic data, and the end side equipment transmits the collected traffic data to an edge intelligent gateway;
the edge intelligent gateway is used for connecting, controlling and managing communication between the terminal side equipment and the cloud service, processing and analyzing data transmitted by the terminal side equipment, and simultaneously carrying out preliminary processing and filtering on the data, relieving the pressure of the cloud, providing security enhancement and local decision making capability, and realizing real-time processing and feedback on the data; the terminal side equipment confirms acquisition equipment information according to the application scene, and confirms gateway attributes of the intelligent gateway according to the acquisition equipment;
S2, collecting and aggregating traffic data from different terminal side devices, creating a cloud database for storing the data, and carrying out data preprocessing on the data in the cloud database, wherein the data preprocessing reduces errors and deviations caused by low-quality data in the data analysis process by cleaning, eliminating noise and processing missing values and abnormal values, so as to improve the quality and applicability of the data;
Collecting data from different devices via various communication protocols; integrating data from different devices, creating a cloud database for storing the data, and providing a basis for subsequent data processing and analysis; preliminary preprocessing is carried out on the polymerized data, such as data cleaning, denoising and the like, so as to improve the accuracy and reliability of subsequent analysis; aggregation refers to merging data from multiple end-side devices into a cloud database for more comprehensive data analysis and processing;
S3, the edge intelligent gateway analyzes the preprocessed traffic data according to an anomaly detection algorithm model, detects abnormal conditions in the traffic data, such as suddenly increased traffic flow and abnormal vehicle behaviors, identifies abnormal conditions of the traffic data, quickly identifies abnormal traffic data, and responds in time to improve the running efficiency and safety of a traffic system;
S4, based on the result of data analysis, the edge intelligent gateway transmits an instruction to control the sensor to collect traffic data through the gateway management unit, and based on the dynamic resource allocation unit, the self-adaptive configuration of the gateway is realized; the single gateway can be connected with a plurality of sensors of various types according to the number of channels, and issues instructions to control the sensors to collect traffic data;
according to the change of traffic conditions, the intelligent gateway can dynamically allocate traffic sensor resources to ensure that key areas are properly monitored and managed; the deployment position of the traffic sensor is adjusted according to the requirement so as to more accurately monitor traffic conditions and identify potential problems in advance; a sensor allocation strategy is formulated according to the priority of traffic management, so that the key area is timely monitored and managed, and the safe and efficient operation of a traffic system is ensured;
The edge intelligent gateway is used for transmitting the processed and screened data to the cloud system, the cloud system comprises a platform and a traffic control command center, and the cloud database is integrated in the cloud system; the intelligent gateway can coordinate and manage various traffic sensors and devices, and data are summarized and transmitted into the cloud system for analysis and processing.
In this embodiment, the anomaly detection algorithm model is based on an isolated forest algorithm, and the algorithm formula is:
Where E (h, n) represents the path length of the traffic data point in an isolated tree structure, where the path length represents the number of edges traversed from the root node to the leaf node containing traffic data, the path length may be used to measure how isolated the current traffic data is relative to other traffic data, and in an isolated forest algorithm, a shorter path length means that the current traffic data is more likely to be an outlier; h (H-1) represents the average path length of the binary tree with height H-1; h represents the height of the orphan tree; n represents the total number of collected traffic data; n-1 represents the total number of collected traffic data-1;
The anomaly calculation formula is:
Wherein S (x, n, h) represents an anomaly score of traffic data x, x representing traffic data at a specific time; e (h, n) represents the path length of traffic data in the orphan tree; c (n) represents a constant for regularization;
data points with higher anomaly scores may correspond to traffic events or anomalies, such as traffic jams, traffic accidents, abnormal vehicle travel patterns; conversely, a data point with a lower anomaly score is more likely to represent normal traffic flow or behavior; through analysis of the anomaly score and threshold setting, the anomaly condition in the traffic data can be further identified and processed;
the calculation of the anomaly score is adjusted by introducing the weight, so that the adjusted anomaly detection score can better meet the expected requirement, the anomaly detection effect is improved, and the anomaly calculation formula after the weight is introduced is as follows:
ω represents an adjustment factor of the path length weight; adjusting the value of ω to control the influence degree of the path length E (h, n) on the anomaly score, wherein when ω is a positive value, the influence of the path length on the anomaly score is enhanced; when ω is a negative value, the influence of the path length on the anomaly score is weakened; when ω is zero, the effect of the path length on the anomaly score is eliminated, with only the constant c (n) acting.
Further, in the present embodiment, the calculation formula of the regularized constant c (n) is:
and γ represents an Euler-Ma Xieluo Nib constant; n represents the total number of collected traffic data.
In this embodiment, the dynamic resource allocation unit dynamically allocates traffic sensor resources based on the learning-enhanced multi-arm gambling algorithm, and the specific allocation steps are as follows:
s4.1, determining monitoring requirements of all areas by analyzing traffic data, historical traffic modes and a prediction model;
s4.2, resource allocation is carried out by considering the emergency degree of traffic conditions, the importance of areas and the monitoring capability of sensors;
S4.3, optimizing the distribution of resources according to different monitoring requirements and resource constraints based on a multi-arm gambling machine algorithm of reinforcement learning, and ensuring the optimization of the overall monitoring effect.
The multi-arm gambling machine algorithm for reinforcement learning specifically comprises the following steps:
The probability formula for the selection sensor:
Wherein at represents the sensor selected at time step t; c represents an exploration parameter; t represents the number of time steps; qt (i) is an expected prize estimate for sensor i at time step t, representing the expected revenue situation of the intelligent gateway for the selected sensor i; nt (i) represents the number of times sensor i was selected before time step t, representing the cumulative number of times sensor i was selected in the past by the intelligent gateway;
The deployment formula of the sensor is:
Wherein Qt represents an action value estimate at time step t, specifically, an action value estimate refers to an estimate of the return or value expected to be obtained for a certain sensor selected under a specific condition; qt+1 represents the motion value estimate at time step t+1; qt+1(At) represents the motion value estimate corresponding to sensor at selected at time step t+1; qt(At) represents the motion value estimate corresponding to sensor at selected at time step t; nt(At) represents the number of times sensor at was selected before time step t; rt represents the actual benefit of the intelligent gateway in terms of the quality of the monitoring data obtained by the sensor At, the improvement of the efficiency of the traffic system and the enhancement of the safety in the time step t; by continually updating the estimate of the benefit to each sensor, a more optimal resource allocation decision is made in the future.
In this embodiment, since only the best sensor allocation is selected, other possible better sensor allocation opportunities are missed, but if the sensor allocation is performed too frequently, the best sensor allocation scheme is not utilized, so that the allocation formula of the sensor is optimized through a greedy strategy, and the optimized allocation formula is as follows:
Qt+1(At)=Qt(At)+a[Rt―Qt(At)];
wherein a represents a learning rate;
further, the calculation step of the optimized blending formula specifically comprises the following steps:
For each time step t, the following steps are performed:
① . Selecting a random action according to the probability epsilon, and selecting a currently known optimal action according to the probability 1-epsilon; wherein epsilon represents the probability of exploration when selecting a sensor, epsilon is a number between 0 and 1, and is used for controlling the trade-off for exploration and utilization, when selecting an action, a random action is selected with probability epsilon, and the currently known optimal action is selected with probability 1-epsilon;
② . A bonus Rt that performs the selected action and observes environmental feedback;
③ . Using update formula Qt+1(At)=Qt(At)+a[Rt―Qt(At), update the selected action value estimate Qt;
④ . The selection count N is incremented and the above operation is repeated until the expected number of iterations is reached.
Wherein;
Specifically, f (at) represents the actual benefit value of the monitoring data obtained by sensor at at time step t;t Representing random noise terms for simulating uncertainty or randomness of rewards, representing random fluctuations in actual profits of the intelligent gateway from the quality of the monitored data obtained by the sensor at, the improvement in efficiency of the traffic system and the safety enhancement at time step t.
Specifically, in this embodiment, the gateway management unit includes an equipment interface status acquisition module, an equipment management module, and a command issuing module;
The device interface state acquisition module is used for acquiring device interface state information, wherein the device interface state information comprises whether the device is normally connected to the edge intelligent gateway, whether data flows from the device to the gateway or from the gateway to the device, acquiring data acquired by the sensor, whether instructions sent by a cloud or other controllers exist, and whether the instructions are successfully transmitted to the device; the equipment management module can monitor the equipment in real time;
The device management module is used for managing various physical devices connected to the edge intelligent gateway and ensuring the effective operation of the devices in the edge environment; the equipment management module is responsible for tasks such as registration identification, monitoring state, data acquisition and transmission, fault diagnosis, safety management and the like of equipment, and collects data from connected sensors and transmits the data to the cloud system;
The command issuing module is used for sending a control command to the sensor equipment, receiving an allocation command sent by the dynamic resource allocation unit and realizing remote control and management allocation of the sensor equipment.
Example 2:
The embodiment provides an intelligent gateway device, which comprises a sensor, a storage, a processor and a computer program stored in the storage and capable of running on the processor, wherein the processor realizes the steps of the application method of any one of the intelligent gateways when executing the computer program.
The sensor comprises at least:
The traffic flow sensor is used for detecting the quantity and the flowing condition of vehicles on a road;
the traffic camera is used for capturing traffic conditions on roads, analyzing traffic data through a computer vision technology and providing real-time traffic monitoring and analysis reports;
the traffic signal sensor is used for monitoring the state of the traffic signal lamp and helping to optimize the traffic signal control system so as to reduce traffic jam and improve road traffic efficiency;
the road state sensor is used for monitoring the state of a road;
The traffic weather sensor is used for monitoring weather conditions in the traffic transportation process.
Through the sensor, the edge intelligent gateway can collect, analyze and process traffic data, and provide real-time traffic monitoring, analysis and management.
The present embodiment also provides an intelligent gateway storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method of any of the preceding claims.
The foregoing has shown and described the basic principles, principal features and advantages of the invention. It will be understood by those skilled in the art that the present invention is not limited to the above-described embodiments, and that the above-described embodiments and descriptions are only preferred embodiments of the present invention, and are not intended to limit the invention, and that various changes and modifications may be made therein without departing from the spirit and scope of the invention as claimed. The scope of the invention is defined by the appended claims and equivalents thereof.