Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be further described in detail below by way of examples with reference to the accompanying drawings, and it should be understood that the detailed description herein is merely a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention, but all other embodiments obtained by persons of ordinary skill in the art without making any inventive effort are within the scope of the present invention.
The application scene of the algorithm is provided for traffic police, so that traffic police departments can control the global state of roads and specific accident conditions of road sections. Although some highway early warning systems exist on the market, the service objects of the systems are mostly drivers, and the functions are single. For example, a conventional intelligent alarm early warning system can enable a driver to quickly know the specific position of the driver when the expressway alarms, and remind the rear vehicles to avoid by sending out an audible and visual alarm after the alarm, but a traffic police department cannot know the whole running state and specific accident situation of the expressway according to the system. Another type of early warning system is specific to the influence of the meteorological environment on the road, but ignores the running state of the road itself.
Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart depicts operations (or steps) as a sequential process, many of the operations (or steps) can be performed in parallel, concurrently, or at the same time. Furthermore, the order of the operations may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figures; the processes may correspond to methods, functions, procedures, subroutines, and the like.
The technical scheme of the invention is further specifically described below through examples and with reference to the accompanying drawings.
Example 1
A three-color early warning method for a high-speed road section is shown in fig. 1, and comprises the following steps:
s1, uploading event data, traffic operation data and vehicle monitoring information are collected.
S2, constructing judgment matrixes, calculating corresponding feature vectors of the judgment matrixes, namely factor weight vectors, determining road section early warning score related factors and weight relative values among the factors, uniformly treating all uploaded events as the same factor, combining the factors with traffic running factors and vehicle monitoring factors, calculating road section safety early warning scores to determine the safety early warning grades of road sections, and calculating specific deduction conditions of all indexes to determine main early warning indexes of the road sections.
Constructing a judgment matrix, and introducing a matrix judgment scale to enable the importance of each element in the matrix to be quantitatively displayed: the importance of (2) is 1 to 12, the larger the number is, the more the number isThe more important.
A. Traffic accident > b reverse/reverse > c abnormal stop > d overspeed vehicle > e abnormal creep > f pedestrian/non-motor vehicle intrusion > g outdoor flame/tunnel flame = h outdoor smoke/tunnel smoke = i.foggy day > j traffic jam > k construction violation = l road construction = m road obstacle > n.flow rating > o.cart occupancy > p.vehicle speed standard deviation.
Calculating corresponding feature vectors of each judgment matrix, namely factor weight vectors: the road section early warning obtains classified factor weight vectors:
W1=[0.5139, 0.2801, 0.1003, 0.069, 0.0366]
Factor weight vector of road section early warning misclassification:
W2=[0.2304,0.1784,0.1361,0.1024,0.0758,0.0546,0.0376,0.0376,0.0376,0.0259,0.0178,0.0178,0.0178,0.0128,0.0097,0.0078]
S3, determining a fuzzy comment set and determining score vectors of comments. The step of determining the fuzzy comment set specifically comprises the steps of dividing the early warning level and the level of each bottom factor into 3 levels, namely the fuzzy comment set of the early warning level is as follows:
and determining a classification factor level classification rule of the road section early warning and a classification rule of the road section early warning failure classification factor level, and determining a fuzzy comment set of each factor according to the early warning level.
No early warning is needed [1, 0, 0]
First-level early warning [0.1, 0.6, 0.3]
Secondary early warning [0, 0, 1]
And determining the score vector of the comment, quantifying the comment, determining the score interval of the comment, and then determining the score vector of the comment according to the score interval of the comment.
S = (100, 50, 0)
And S4, establishing a grading early warning model of the road section dangers and carrying out multi-period safety evaluation.
Calculating the safety grade score of each period of the road section, and carrying out fuzzy comprehensive evaluation modeling by combining the weight vector determined by the analytic hierarchy process and a fuzzy comment set, wherein the fuzzy evaluation is as follows:
wherein W1 is a factor weight vector of the road section early warning classification, A is a matrix formed by fuzzy comment sets corresponding to the road section early warning classification factors,The factor in R is evaluated for blur.
Based on the score vector of the fuzzy evaluation, quantitatively processing the comment, and determining the score of the road section safety grade, thereby determining the early warning comment based on the score interval of the comment:
Wherein R is fuzzy evaluation,In order to fuzzily evaluate the factors in R,Is the transpose of the comment score vector.
The road section early warning score is calculated, as shown in fig. 2, the road section safety grade score in the first n periods is taken, and the road section safety early warning score is calculated based on the exponential weighted average:
…
Wherein,A road segment safety precaution score representing the nth period,Representing the parameters of the adjustment that are to be made,Representing the actual road segment safety level score value of the nth period.
Comparing the road section early warning score with the road section safety grade score, correcting the parameters, and whenAnd (3) withWhen the difference of (a) exceeds the error threshold a, the cycle number n is modified to changeRepeatedly attempting to modify the cycle number n and recordingAnd (3) withIf the difference is gradually reduced, continuing to attempt to modify the cycle number; if the difference becomes larger, the cycle number n at which the error is minimum is stopped and recorded.
Calculating the score loss of each factor in each period, quantitatively processing the comment on the basis of the score vector of the fuzzy evaluation on the basis of the score loss of each factor of the road section, determining the safety score of each factor of the road section, subtracting the safety score from the full score, multiplying the safety score by the index weight,
Wherein,For the fuzzy comment set corresponding to the factor i,For the transposition of the score vector of the comment,And (5) giving a weight corresponding to the W2 factor i in the road section early warning unclassified factor weight vector.
Determining the whole early-warning state of the road, and determining the whole early-warning state of the road by the road section early-warning state duty ratio of the road:
Wherein, warn_h represents the ratio threshold of the number of the high-risk road segments in the road, and warn_l represents the ratio threshold of the number of the low-risk road segments in the road. And finally outputting the road section early warning record list.
The data requirements of the algorithm of the application consist of vehicle monitoring, traffic operation data and uploading event data. The vehicle monitoring comprises overspeed vehicle number, suspected parking vehicle number and large vehicle duty ratio; the traffic operation data comprises road section speed standard deviation and road section flow grade; the uploading event data includes accidents that may occur in the road section, such as reverse/reverse, road construction and abnormal creep. The functional requirement of the algorithm is to establish a hierarchical early warning model of road section dangers based on the data of the three aspects.
The specific implementation algorithm comprises 5 steps: and (3) carrying out feature extraction analysis, determining the weight of each factor, calculating the safety grade score of each period of the road section, calculating the early warning score of the road section, and determining the integral early warning state of the road. The feature extraction analysis is mainly used for determining factors influencing the state of the road section, and comprises all data items in vehicle monitoring, traffic running and uploading event data. It should be noted that the overspeed vehicle number needs to be combined with the overspeed vehicle number in the vehicle monitoring and the abnormal overspeed event number in the uploading event data, and the abnormal creep is the sum of the suspected parking number in the vehicle monitoring and the abnormal creep event number in the uploading event number. And after determining the factors influencing the road section state, obtaining the weight of each factor by a single-layer analytic hierarchy process, wherein three factors with the maximum weight are traffic accidents, reversing/reversing and abnormal stopping.
The third step starts with a business module of the algorithm. First, the security level score of each period of the road section is calculated. From the previously obtained weights of the factors and the specific values of the corresponding data items, we can obtain a security level score for each factor. For example, if a traffic accident occurs in a certain road section in a certain period, the score of the traffic accident factor of the road section in the period is 0. Assuming that the weight of the traffic accident is 0.4 and that no other accident occurs in the road section in the period, the road section runs smoothly without overspeed and parking of the vehicle, the safety class score of the road section is 60 points.
The fourth step predicts the security level score of the next cycle, referred to herein as the road segment early warning score, using an exponentially weighted average of the security level scores of the road segment history cycles. An advantage of exponentially weighted averaging over other prediction methods is that it exploits already occurring events and current states to reasonably estimate future states for the future. For example, when an exponential weighted average is used to predict the temperature of a future day, since the temperature does not change abruptly and sharply, the exponential weighted average can better capture the trend of temperature change over the past several days and give each historical data a weight, the closer the time is, the greater the weight is, the more forward the weight is. Similarly to the temperature, the change trend of the link state does not change drastically in a short time, so that the prediction can be performed using an exponentially weighted average. After the early warning scores of all the road sections in the road are obtained, the current overall early warning state of the road can be given through the duty ratio of each early warning state.
Example 2
1. Functional requirements
And establishing a grading early warning model of the road section dangers based on the uploading event data, the traffic operation data and the vehicle monitoring information.
2. Data demand
Vehicle monitoring
Traffic operation data
Uploading event data
3. Algorithm flow
As shown in fig. 1
4. Calculation process
4.1. Determining the weight of each influencing factor
4.1.1. Determining a road section early warning score related factor and a weight relative value among the factors:
And (3) uniformly considering all uploading events as the same factor, and combining the traffic running factors and the vehicle monitoring factors (used for calculating the road section safety early warning score so as to determine the safety early warning classification of the road section).
4.1.2. The road section early warning obtains classified factor weight vectors:
W1 = [0.5139, 0.2801, 0.1003, 0.069, 0.0366]
4.1.3. Determining a road section loss correlation factor and a weight relative value among the factors:
All uploading events are regarded as independent factors and combined with the traffic running factors and the vehicle monitoring factors (used for calculating specific deduction conditions of all indexes so as to determine main early warning indexes of the road section).
A. Traffic accident > b reverse/reverse > c abnormal stop > d overspeed vehicle > e abnormal creep > f pedestrian/non-motor vehicle intrusion > g outdoor flame/tunnel flame = h outdoor smoke/tunnel smoke = i fog day > j traffic jam > k construction violation = l road construction = m road obstacle > n.flow rating > o.vehicle occupancy > p.vehicle speed standard deviation
4.1.3. Factor weight vector classified during road section early warning:
W2=[0.2304,0.1784,0.1361,0.1024,0.0758,0.0546,0.0376,0.0376,0.0376,0.0259,0.0178,0.0178,0.0178,0.0128,0.0097,0.0078]
TABLE 1 weight versus value Table between loss of correlation factors
4.2. Determining fuzzy comment sets
Considering the feasibility of an early warning model, dividing the early warning level and the level of each underlying factor into 3 levels, namely, the fuzzy comment set of the early warning level is V= { no early warning, primary early warning, secondary early warning }
4.2.1. Road section early warning classification factor level division rules:
TABLE 2 road segment early warning classification factor level division rule table
4.2.2. Road section early warning misclassification factor level division rule:
TABLE 3 road section early warning misclassification factor level division rule table
4.2.3. Determining fuzzy comment sets of all factors according to the early warning level:
No early warning is needed [1, 0, 0]
First-level early warning [0.1, 0.6, 0.3]
Secondary early warning [0, 0, 1]
4.3. Calculating early warning score of road section
4.3.1. Fuzzy evaluation modeling
And carrying out fuzzy comprehensive evaluation modeling by combining the weight vector determined by the analytic hierarchy process with a fuzzy comment set, wherein the fuzzy evaluation is as follows:
R = W1 * A = (r1, r2, r3)
wherein W1 is a classified factor weight vector obtained by road section early warning, and A is a matrix formed by fuzzy comment sets corresponding to road section early warning classification factors.
4.3.2. Calculating a road segment safety class score
Based on the score vector of the fuzzy evaluation, quantitatively processing the comment, and determining the score of the road section safety grade, thereby determining the early warning comment based on the score interval of the comment:
wherein R is fuzzy evaluation, wherein R is fuzzy evaluation,In order to fuzzily evaluate the factors in R,Is the transpose of the comment score vector.
4.3.3. Calculating road section safety early warning score
Taking the road section safety grade scores in the first n periods (5 minutes to one period), and calculating the road section safety early warning score based on the exponential weighted average:
…
Wherein,A road segment safety precaution score representing the nth period,Representing the parameters of the adjustment that are to be made,Representing the actual road segment safety level score value of the nth period.
4.3.4. Comparing the road section early warning score with the road section safety grade score, and correcting the parameters
Comparing the road section early warning score with the road section safety grade score, correcting the parameters, and whenAnd (3) withWhen the difference of (a) exceeds the error threshold a, the cycle number n is modified to changeRepeatedly attempting to modify the cycle number n and recordingAnd (3) withIf the difference is gradually reduced, continuing to attempt to modify the cycle number; if the difference becomes larger, the cycle number n at which the error is minimum is stopped and recorded.
4.3.5. Determining the safety pre-warning level of a road section
According toAnd (5) combining score vectors of the comments to determine the road section risk early warning level.
4.3.6. Quantitatively processing the comments and determining the score interval of the comments:
4.4. calculating the score loss of each factor in each period
4.4.1. Calculating the loss of each factor in each period in the road section early warning loss classification
The loss of each factor of the road section is divided into score vectors based on fuzzy evaluation, the quantification processing is carried out on the Pinghu, the safety score of each factor of the road section is determined, the safety score is subtracted by the full score, and then the index weight is multiplied.
Wherein,For the fuzzy comment set corresponding to the factor i,For the transposition of the score vector of the comment,And (5) giving a weight corresponding to the W2 factor i in the road section early warning unclassified factor weight vector.
4.4.2. Calculating early warning score loss of each factor
And calculating early warning score loss of each factor of the road section based on exponential weighted average according to factor score loss in n periods, wherein the calculation process is similar to the road section safety early warning score.
4.4.3. Determining a road section primary early warning factor
The main early warning factors are the factors with the highest early warning score in early warning time division factors, and are the main reasons for early warning of each level of a road section.
4.5. Determining the whole early warning state of a road
The adult early-warning state of a road is determined by the road section early-warning state duty ratio constituting the road.
Wherein, warn_h represents the ratio threshold of the number of the high-risk road segments in the road, and warn_l represents the ratio threshold of the number of the low-risk road segments in the road.
5. Process of implementation
5.1. Demand data processing
(1) Initializing basic information:
traversing basic information such as roads, road segments and the like.
(2) Acquiring and processing vehicle passing data:
And acquiring the passing data in the period by a method of acquiring the last period time with the current time as the end time according to the cron expression.
Merging the rollback data stored before to the data set of the current period, and clearing the rollback data set to prepare for accumulation again.
(3) Calculating the number of vehicles in transit:
And if the passing data set is not empty, extracting the license plate number of each vehicle, and calculating the total number of the passing vehicles after removing the repetition.
(4) Creating a road record:
An object is created, and related information such as the current date, the number of vehicles in transit, a unique identification (uuid), a time stamp, etc. is filled in and added to the list of the set of records of vehicles in transit.
(5) Road segment-based grouping of passing data:
the traffic data is grouped by road sections (bayonet numbers + directions) using stream operations, facilitating subsequent analysis by road sections.
5.2. Algorithm implementation
5.2.1. Analyzing road segment index
(1) And traversing all road section information, and constructing unique keys of a starting point and a terminal point for each road section.
(2) Checking whether there is a match between the driving data and the start point and the end point of the road section
(3) If matching data exists, data analysis is performed, including but not limited to road section average speed analysis and early warning information analysis:
5.2.1.1. high-speed road section passing calculation logic
The analysis of the vehicle passing data of the high-speed road section is processed, and the functions of vehicle running speed, vehicle classification statistics, running path abnormality detection and the like are provided.
(1) Data verification and initialization:
firstly, checking whether the upstream card port passing data and the downstream card port passing data are empty, and if any one is empty, directly returning.
And initializing a data set for storing the passing analysis result of each vehicle.
(2) Upstream bayonet data packet:
Upstream passing data is grouped by license plate number and vehicle type combination using stream operations to facilitate subsequent matching with downstream data.
(3) Vehicle type counting and lane change detection:
Three counters are initialized: the number of large vehicles, the number of small vehicles and the number of lane-changing vehicles.
Traversing the downstream drive-through data, for each record:
A unique identification of the license plate number plus the vehicle type is generated.
And judging whether the identified vehicle exists in the upstream data, and if not, skipping the current cycle.
The time difference for the vehicle to pass through the two bayonets is calculated and converted to seconds.
If the time difference is negative, indicating that the data may be erroneous, the recording is skipped.
The corresponding counter is incremented according to the type of vehicle.
It is checked and recorded whether the vehicle is changing lanes while running (i.e., entrance and exit lane numbers are different).
The average speed of the vehicle over the road segment is calculated and recorded.
And encapsulating the processed data into an object and storing the object into a data set.
Paired data items are removed from the upstream and downstream passing data sets to reduce comparisons in subsequent cycles.
(4) Data integrity check:
After the traversal is finished, if the data set is still empty, the fact that no vehicle is successfully paired is indicated, and the fact that the high-speed road section has no paired passing records is indicated by the abnormality in throwing.
(5) Sorting and returning analysis results:
the unsuccessfully paired passing data is marked as requiring rollback processing (although this step in the code is annotated, this portion of the data should theoretically be processed for further analysis or subsequent processing).
Creating and populating a result object, comprising:
The vehicles passing in pairs and their average speeds are mapped into a data set.
Unpaired passing data list rollback sets.
Number of carts, number of carts and number of lane changing vehicles.
5.2.1.2. Analysis road section index and vehicle speed early warning calculation logic
The traffic conditions (such as standard deviation, highest speed and lowest speed) of the road are quantized through complex logic processing, traffic state grades are divided according to traffic flow characteristics, a necessary early warning mechanism is triggered, and detailed data support is provided for traffic management and planning.
(1) Calculating a standard deviation of the vehicle speed:
All vehicle sets are traversed and the sum of squares of the deviations of each vehicle speed from the average speed is calculated.
Dividing the sum of squares of the deviations by the number of vehicles and squaring to obtain the standard deviation of the vehicle speed.
(2) Obtaining maximum and minimum speeds:
and sorting collect sets according to the speeds, wherein the sorting basis is the speed of the vehicle.
And taking the speed values of the first element and the last element after sorting, and backfilling the speed values into the object attribute.
(3) Calculating average travel time and road section tolerance time:
The average velocity is converted to meters per second (multiplied by the free flow velocity).
Calculating the average travel time: road segment length divided by average speed.
The dynamic window time ranges (minimum and maximum allowed times) are calculated.
Calculating the road section tolerance time: average travel time plus minimum allowed time minus maximum allowed time.
(4) Calculating a travel time ratio:
the average speed is converted to meters per second.
Logic: and comparing the average travel time of the road section with the free flow travel time to determine the travel time ratio. If the average travel time is longer, the ratio is equal to the average travel time divided by the free time of flight; otherwise default to 1, indicating in the free flow state.
(5) Judging traffic state and setting early warning information:
judging the traffic state according to the average speed:
and if the average speed is greater than the unblocked threshold, setting the unblocked state.
If the creep event information is between the creep threshold value and the smoothness threshold value, setting the creep event information as a creep state, and generating the creep event information.
If the congestion event information is between the congestion threshold value and the creep threshold value, setting the congestion event information to be in a light congestion state, and generating the congestion event information.
Otherwise, setting the system to a serious congestion state and generating serious congestion event information.
An event information object is generated, including an event type, a name, a timestamp, etc., and added to the pre-warning information queue.
(6) Setting the number of overspeed and low-speed vehicles:
the number of overspeed vehicles and the number of low-speed vehicles of the road section are set into the object according to the input parameters and the pre-counted overspeed (overSpeed) and low-speed (lowSpeed) vehicle maps.
(7) Packaging the result and returning:
all calculation and analysis results are packaged into an object and returned to this object at the end of the function as a composite output of the road segment data is processed by the function.
5.2.1.3. Computing early warning comment
And acquiring monitoring weights in traffic cycle configuration, analyzing and processing given road section index data, calculating scores of different dimensions (road section safety, traffic operation, vehicle monitoring and environmental influence) and comprehensive total scores, judging early warning grades according to the scores, and finally packaging the information to an object for return.
5.2.1.3.1. Road segment safety dimension
And calculating a attribution degree matrix of the road safety dimension according to the road section basic information.
(1) Reading configuration and parameter variables:
The number of lanes, the turning radius, the absolute value of the gradient, the defect rate, whether the road is a bridge tunnel or not and the accident rate are obtained from the incoming road section basic information object.
And obtaining preset values of edge monitoring, including maximum values, minimum values and default values of various security attributes.
(2) Creating a result array:
according to the comparison result, a two-dimensional array of 6x3 is constructed, wherein each row represents a road surface characteristic (number of lanes, turning radius, absolute gradient value, defect rate, bridge and tunnel identification, accident rate), and each column corresponds to a score of attribution degree grade. The matrix comprehensively reflects the safety conditions of various indexes of the input pavement.
(3) Calculating attribution degree of each dimension:
And judging the condition of each safety attribute, comparing the attribute value with a preset threshold value, grading the attribute according to the comparison result, and mapping the attribution grades into an array form for storage.
Number of lanes: in terms of their number, with configured maximum and minimum values.
Radius of turning: and comparing the preset maximum turning radius and the preset minimum turning radius according to the size.
Gradient, defect rate and accident rate: the ranking is also determined based on the value compared to a threshold.
Bridge tunnel identification: if the bridge tunnel identification is consistent with the preset bridge tunnel identification, special treatment is performed.
(4) Summarizing the results:
and storing the security attribution result of each attribute into a two-dimensional array edge, wherein each row of the array corresponds to a security dimension, and three values in each row represent attribution level details under the dimension.
(5) And (5) returning a result:
And finally returning to the two-dimensional array containing six different-dimensional security attributions. The comprehensive evaluation result of each safety dimension of the pavement is comprehensively reflected.
Through the steps, according to the preset monitoring configuration, a attribution degree matrix reflecting risks or safety levels of all safety dimensions of the road surface is calculated and returned, and data support can be provided for subsequent road safety evaluation and management.
5.2.1.3.2. Traffic running dimension
And calculating a attribution degree matrix of the traffic running dimension based on the road section index information.
(1) Reading configuration and parameter variables:
And acquiring traffic operation safety early warning threshold and default configuration information, wherein the configuration information comprises preset parameters such as the maximum value and the minimum value of the free flow speed ratio. Traffic operation related information such as standard value, saturation level and the like.
A 3x3 double-dimensional array traffic is initialized for storing the calculated home degree result.
(2) Process free flow rate duty cycle (avgFreeFlowVelocityRtio):
And comparing the free flow speed ratio with the maximum value and the minimum value in the configuration, determining the attribution grade of the traffic state according to avgFreeFlowVelocityRtio and comparing the free flow speed ratio with the preset maximum value and the preset minimum value, and acquiring an attribution grade array of the corresponding grade from the configuration and filling the attribution grade array into the first row of traffic. The attribution degree level is divided into three types: attributionegreeNo (not up to standard), attributionegreeOne (general), attributionegreeTwo (good), and store the value of the corresponding attribution into traffic [0 ].
(3) Default settings for early warning status:
And directly setting the traffic [1] as a default state vector {1, 0, 0} without early warning, which indicates that the early warning level is not considered or defaults to be normal.
(4) Process saturation (saturationLevel):
And judging whether the saturation in the input is null or not, and if so, using a default value in the configuration.
And determining the attribution level of the saturation according to the comparison of the saturation and the maximum value and the minimum value in the configuration, and storing the result into a traffic 2.
(5) And (5) returning a result:
After the processing of all the dimensions is completed, the double-dimension array traffic containing the attribution degree information of the traffic operation dimension is finally returned.
The function comprehensively analyzes two key indexes (free flow speed ratio and saturation) of traffic data, and belongs traffic states to predefined levels based on the indexes to provide quantitative references for traffic management or analysis.
5.2.1.3.3. Vehicle monitoring dimension
And calculating a attribution degree matrix of the vehicle dimension based on the road section index information.
The traffic conditions of the specific road section are systematically evaluated through the set threshold value by comprehensively considering various vehicle running states and expressed in a numerical form, and the traffic conditions can be used as a data base for further analysis or decision support.
(1) Acquiring configuration and parameters:
And acquiring a vehicle monitoring value, a attribution degree threshold value of the monitoring level and a default value from the global traffic circulation configuration.
And acquiring various index values in the object, such as the ratio of the large vehicles, the number of overspeed vehicles, the number of low-speed vehicles, the number of lane changes and the lane change rate.
(2) Calculating attribution degree of each dimension:
And determining the attribution degree grade (no, primary or secondary) according to the comparison of the vehicle duty ratio and the configured minimum value and maximum value. And determining attribution degree grades (0, 1 and 2) according to comparison of the cart proportion and preset minimum and maximum values, converting attribution degree values of the corresponding grades into double-precision arrays, and filling the double-precision arrays into the first row of the result two-dimensional arrays.
And the number of the overspeed vehicles is the same, and the attribution degree grade is determined according to comparison of the overspeed vehicles and the corresponding threshold value. And determining the attribution level after comparison, and updating the second row of the result array.
And judging the attribution degree level of the low-speed vehicles according to the low-speed/illegal stop values. And determining the attribution level according to the value interval, and updating the third row of the result array.
And (5) the lane change rate, namely determining the attribution degree grade according to the number of the lane change vehicles and the duty ratio. And performing null value inspection and range judgment on the lane change frequency, and filling the last row of the attribution degree array according to the situation.
(3) Constructing a result array:
For each dimension, a two-dimensional array vehicle of 4 rows and 3 columns is populated with values corresponding to the attribution level.
(4) And (5) returning a result:
the function finally returns to this two-dimensional array, where each row represents a different vehicle behavior index, and each column may correspond to a different aspect of the index (although specific details are not shown in the code).
Through the processing, a two-dimensional array of 4 rows and 3 columns is obtained, each row represents a attribution degree coefficient of one dimension, and the coefficient reflects the running state of the vehicle in the corresponding dimension, so that the traffic condition of the road section is assisted to be analyzed.
5.2.1.3.4. Environmental impact dimension
And calculating a attribution degree matrix of influence of weather conditions on the road section according to the road section basic information.
The attribution degree matrix of the influence of the comprehensive key weather parameters can be used as a data basis for further analysis or decision support, such as traffic flow prediction, maintenance measure arrangement and the like.
(1) Parameter acquisition and default value processing:
the function receives a weather early warning threshold and a parameter of a default value type, and the object comprises real-time weather observation data of a road section, including rainfall, snowfall, visibility and wind speed.
For each of these parameters, if the incoming value is null, the function will be replaced with a default value preset in the configuration object traffic index configuration class. This ensures that even if some observed data is missing, there is basic data available for evaluation.
(2) Home degree evaluation logic:
For each weather factor, the function determines its attribution level by making the following decisions and stores the results to the corresponding locations of the two-dimensional array:
Rainfall: and (3) grading treatment according to comparison between the minimum rainfall and the configured maximum rainfall.
Snowfall amount: and similar attribution degree judgment is carried out according to the snowfall with the rainfall processing logic.
Visibility: the visibility is attributed to "no influence" when the visibility reaches the maximum value, and "serious influence" when the visibility is lower than the minimum value, and the rest is "light influence", wherein the criterion is that the visibility is high or low, and the lower influence is probably larger.
Wind speed: the processing logic is the same as the rainfall and snowfall, and high wind speeds may mean higher risk or impact.
(3) Home degree mapping:
the attribution degree grade is converted into a specific numerical value array to be stored, the arrays respectively correspond to four dimensions in a two-dimensional array weather, and each dimension represents the attribution degree evaluation result of a weather factor.
(4) And (5) returning a result:
finally, the function returns to the two-dimensional array weather of four rows and three columns, and each row of the array corresponds to three attribution grade values of one weather factor (rainfall, snowfall, visibility and wind speed) respectively, so that the influence of road weather on traffic conditions can be further analyzed.
5.2.1.3.5. Performing matrix operation
And constructing a two-level fuzzy evaluation matrix, namely multiplying the attribution degree of each dimension by a corresponding weight matrix to respectively obtain R1-R4, and representing the weighted scores of different dimensions.
And constructing a first-level comment, namely further fusing the results of R1-R4 to form a higher-level evaluation matrix vector.
And (3) calculating a comprehensive score, namely combining the first-level evaluation matrix and the higher-level weight, and calculating a final score R.
5.2.1.3.6. Calculating reciprocal factors and scoring
For each dimension and composite score, the reciprocal factor of its weight is calculated.
The reciprocal and weight are used to calculate each dimension score, including road safety, traffic, vehicle, weather scores, and overall score.
5.2.1.3.7. Determining an early warning level
And determining the early warning level of the road section according to the total score and returning the numerical object.
The whole function realizes a set of conversion flow from original road section index data to comprehensive early warning evaluation information, relates to data processing in multiple dimensions and complex mathematical operation, provides the safety early warning evaluation information of the road section for highway management, and helps a decision maker to know the condition of the road section and take corresponding measures.
5.2.2. Analyzing road overall index
Comprehensive indexes of the expressway are analyzed, including, but not limited to, average travel speed, travel time ratio, delay time ratio and the like.
(1) Initializing and summing VKT (Vehicle Kilometers Traveled, vehicle travel mileage):
the function receives a road segment index list as a parameter.
The VKT values of all segments are accumulated securely, ensuring atomicity of operation in a multi-threaded environment.
(2) Calculating the average stroke speed:
traversing each road section, and multiplying the average speed of the road section by the proportion of the VKT of the road section to the total VKT to accumulate to obtain the average travel speed of the whole road. This process takes into account the effect of the traffic flow of the road segment on the average speed.
(3) Travel time ratio to delay time ratio calculation:
a weighted average of the travel time ratio (i.e., the ratio of the actual travel time to the theoretical travel time in the free-stream state) of each road segment is calculated, wherein the weight is the VKT duty cycle of the road segment.
The same method calculates the delay time ratio, but it is necessary to additionally check whether the delay time ratio and VKT of the road section are empty.
(4) And (5) calculating the congestion length:
Judging whether the road sections belong to a congestion state (not basically smooth or unblocked), accumulating the lengths of the congestion road sections, and finally calculating the proportion of the congestion length to the total length (converted into kilometers to be expressed) so as to evaluate the congestion degree of the road
(5) Calculating the average speed of the cart:
Similar to the average travel speed calculation method, the calculation is performed for the average speed of the large vehicle.
(6) Calculating the traffic state proportion:
A map is initialized to record the proportions of the various traffic conditions, and all condition values are traversed to set them to an initial value of 0.
And grouping the road segment sets, aggregating the road segments according to the traffic level, and then calculating the proportion of the total length of each level road segment to the total length.
And storing the calculated proportions of each level into a map initialized before so as to facilitate subsequent checking and use.
(7) Outputting comprehensive index information:
The calculated indexes (such as average speed, travel time ratio, delay time ratio, traffic state ratio, congestion length, etc.) are set to a new road index information object.
Returning to the object, wherein the comprehensive evaluation index of the whole expressway is contained.
5.2.3. Further analysis of events
The function is mainly used for processing expressway data, and comprises the steps of initializing basic information, acquiring and processing vehicle passing data, analyzing road sections and road indexes, and the core purpose of the function is to identify and early warn potential road problems by analyzing historical traffic data.
(1) Parameter resolution and time calculation
Inputting parameters: accept cron expression (time rule for determining periodic task execution), elastic search client instance, integer variable T (representing number of cycles analyzed), integer variable cycle (current cycle identification), string uuid (unique identifier).
Calculating start and end times: and calculating the current end time of the execution period and the corresponding period time length according to the cron expression, and further calculating the analysis start time.
(2) Index and data acquisition
And extracting road index information and event information according to the index array and the time range.
(3) Data preprocessing and grouping
Grouping by period: firstly, the extracted data are grouped according to the period of each data by using a streaming operation to form two hash sets, wherein keys are periods, and the values are lists of all road indexes or event information in the periods.
(4) Road index and event fusion analysis
Traversing period: traversing specified T cycles from the current cycle to the past in reverse.
Integrating road indexes: for each cycle, if there is road index data, these data are traversed, link early warning index objects are created and related information is filled, including link ID, large vehicle proportion, number of low speed vehicles, flow level, etc.
Processing event data: similarly, event data is processed, first grouped according to edge IDs, then subdivided according to event types, and the number of events of each type is counted.
(5) Result summarization and storage
Trend information list generation: further sorting of the data in the hash set by a function may include sorting, filtering, and the like.
Constructing a road trend index: generating higher level road trend index information based on the above list by analyzing pre-warning road and road network metrics may involve summarizing or analyzing individual road segment trends.
Data persistence: and respectively writing the processed trend information and the road trend index back to the elastic search database to realize the persistent storage of the data.
Additional treatment: the calling function performs some additional event processing or conversion that is not explicitly described in the subject flow.
The function aims to generate road early warning information by collecting, grouping and fusion analysis of road indexes and event data in a specified time period so as to support traffic management and decision.
5.2.4. Preserving data
And finally, respectively writing the processed data back into the database to realize the persistent storage of the data.
The on-road vehicle record, road segment index, expressway index, early warning information score is inserted into the elastic search.
The whole process involves complex data processing logic, and embodies understanding and application of big data processing and early warning system development.
The specific embodiments described herein are offered by way of example only to illustrate the spirit of the invention. The foregoing examples illustrate only a few embodiments of the invention, which are described in detail and are not to be construed as limiting the scope of the invention. It should be noted that various modifications or additions to the described embodiments or substitutions thereof can be made by one skilled in the art without departing from the spirit of the invention or exceeding the scope of the invention as defined by the accompanying claims. It will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the spirit of the invention. Accordingly, the scope of protection of the present invention is to be determined by the appended claims.