Adaptive sequencing method and device, electronic equipment and computer readable storage medium

By employing multidimensional feature analysis and dynamic strategy selection, this method addresses the shortcomings of existing sorting algorithms in terms of comprehensive perception of multidimensional features and strategy rigidity, thereby achieving high efficiency and robustness in the adaptive sorting method.

CN121256332BActive Publication Date: 2026-04-10ZHUHAI CHENGMI TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-03
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing ranking algorithms lack the ability to comprehensively perceive multi-dimensional features, have rigid strategy selection mechanisms, lack continuous learning and evolution capabilities, and are difficult to dynamically adapt to data features for optimization.

Method used

By performing multidimensional feature analysis on the target data, including data length features, ordinal features, and uniformity features, a data profile is constructed. Ranking strategies are then matched in the profile template library or the candidate strategies with the highest historical scores are selected from the strategy pool. Combined with environmental indicators and similarity adjustments, a ranking strategy is dynamically selected.

Benefits of technology

It achieves the adaptability of the target sorting strategy, enabling efficient sorting in diverse and dynamically changing data scenarios, thus improving sorting performance and robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121256332B_ABST
    Figure CN121256332B_ABST
Patent Text Reader

Abstract

The application discloses a kind of self-adapting sequencing method, device, electronic equipment and computer readable storage medium, including the feature extraction to target data, and according to the data length feature, order feature and uniformity feature extracted to the data portrait of target data is constructed, according to data portrait is carried out portrait matching from portrait template library, and in the case where matching succeeds, the sequencing strategy of matching portrait is obtained and is used as target sequencing strategy;And in the case where matching is unsuccessful, at least one candidate strategy is generated from the first strategy pool of preposition, and sequencing is carried out based on the historical score of candidate strategy, to select the highest candidate strategy of historical score as target sequencing strategy.Such, target data can be analyzed in multidimensional feature, to make target sequencing strategy can dynamically adapt data feature.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, and particularly relates to an adaptive sorting method and device, electronic equipment and a computer readable storage medium. BACKGROUND

[0002] As a core basis of computer science (especially computer and auxiliary equipment repair), sorting operations are widely used in databases, real-time computing and big data analysis. Existing algorithms such as quicksort, TimSort and counting sort are efficient in specific scenarios (such as random, partially ordered or small range data), but generally have problems such as insufficient comprehensive multi-dimensional features, rigid strategy selection and lack of continuous learning ability. For example, methods based on data size ignore distribution complexity, multi-algorithm systems rely on static rules, and commercial implementations such as Java Collections.sort use fixed combinations, making it difficult to dynamically adapt to data features for optimization. SUMMARY

[0003] The present application aims to at least solve one of the technical problems existing in the prior art. To this end, the present application provides an adaptive sorting method, device, electronic equipment and computer readable storage medium, which can analyze multi-dimensional features of target data to enable dynamic adaptation of target sorting strategies to data features.

[0004] In a first aspect, an embodiment of the present application provides an adaptive sorting method, comprising:

[0005] obtaining target data to be sorted;

[0006] performing feature extraction on the target data to obtain a data length feature, an order degree feature and a uniformity feature, the data length feature being used to represent data items contained in the target data, the order degree feature being used to represent the smoothness of the change trend between adjacent elements in the target data, and the uniformity feature being used to represent the uniformity of the target data in numerical distribution;

[0007] determining a target sorting strategy for the target data based on a preset decision model, wherein the determination process of the target sorting strategy comprises:

[0008] constructing a data portrait of the target data according to the data length feature, the order degree feature and the uniformity feature;

[0009] performing portrait matching from a preset portrait template library according to the data portrait, and in the case of successful matching, obtaining and setting the sorting strategy of the matched portrait as the target sorting strategy;

[0010] In case of unsuccessful matching, at least one candidate strategy is generated from a preset first strategy pool, and the candidate strategies are ranked based on historical scores of the candidate strategies to select a candidate strategy with the highest historical score as the target ranking strategy.

[0011] According to some embodiments of the present application, the feature extraction on the target data includes:

[0012] The data length feature and the number of changes in the order direction between adjacent elements of the target data are determined.

[0013] A trend factor is determined according to the data length feature and the number of changes in the order direction.

[0014] An order degree feature is determined according to the difference between the numerical value one and the trend factor.

[0015] According to some embodiments of the present application, the feature extraction on the target data includes:

[0016] The Shannon entropy value and the maximum possible entropy value of the target data are determined.

[0017] An evenness feature is determined according to the ratio between the Shannon entropy value and the maximum possible entropy value.

[0018] According to some embodiments of the present application, the feature extraction on the target data includes:

[0019] The feature extraction on the target data includes a data length feature, an order degree feature, an evenness feature, and a numerical value range feature.

[0020] The data portrait of the target data is constructed according to the data length feature, the order degree feature, and the evenness feature.

[0021] The data portrait of the target data is constructed according to the data length feature, the order degree feature, the evenness feature, and the numerical value range feature.

[0022] According to some embodiments of the present application, in case of unsuccessful matching, at least one candidate strategy is generated from a preset first strategy pool, and the candidate strategies are ranked based on historical scores of the candidate strategies to select a candidate strategy with the highest historical score as the target ranking strategy.

[0023] In case of unsuccessful matching, at least one candidate strategy is generated from a preset first strategy pool.

[0024] screening the at least one candidate strategy according to the current environment index;

[0025] sorting based on the historical scores of the screened candidate strategies to select a candidate strategy with the highest historical score as the target sorting strategy.

[0026] According to some embodiments of the present application, the adaptive sorting method further comprises:

[0027] In the case of unsuccessful matching, determining the similarity between the data portrait and each portrait template in the portrait template library;

[0028] In the case that the similarity is greater than or equal to a preset similarity threshold, generating at least one candidate strategy from a preset first strategy pool, and sorting based on the historical scores of the candidate strategies to select a candidate strategy with the highest historical score as the target sorting strategy;

[0029] In the case that the similarity is less than the similarity threshold, randomly determining a target sorting strategy from a preset second strategy pool.

[0030] According to some embodiments of the present application, the method of determining the target sorting strategy for the target data based on the preset decision model further comprises:

[0031] sorting the target data based on the target sorting strategy to obtain a sorting result;

[0032] obtaining and generating experience data according to the performance indicators of the sorting result;

[0033] incrementally learning the decision model based on the experience data to update the historical scores of each candidate strategy in the decision model.

[0034] In a second aspect, embodiments of the present application provide an adaptive sorting device, comprising:

[0035] a data acquisition module configured to acquire target data to be sorted;

[0036] a feature extraction module configured to perform feature extraction on the target data to obtain a data length feature, a sequence degree feature, and a uniformity feature, the data length feature being used to represent data items contained in the target data, the sequence degree feature being used to represent the smoothness of the change trend between adjacent elements in the target data, and the uniformity feature being used to represent the uniformity of the target data in numerical distribution;

[0037] a sorting decision module configured to determine a target sorting strategy for the target data based on a preset decision model, wherein the determination process of the target sorting strategy comprises:

[0038] construct a data portrait of the target data according to the data length feature, the order degree feature and the uniformity feature;

[0039] perform portrait matching from a preset portrait template library according to the data portrait, and in a case of successful matching, acquire and take a sorting strategy of the matched portrait as the target sorting strategy;

[0040] in a case of unsuccessful matching, generate at least one candidate strategy from a preset first strategy pool, and sort based on historical scores of the candidate strategies to take a candidate strategy with the highest historical score as the target sorting strategy.

[0041] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, the memory storing a computer program, and the processor being configured to implement the adaptive sorting method described above when running the computer program.

[0042] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, the computer readable storage medium storing a computer program, and the computer program being configured to implement the adaptive sorting method described above when running.

[0043] The embodiments of the present application have at least the following beneficial effects:

[0044] The embodiments of the present application perform feature extraction on target data, and construct a data portrait of the target data according to the extracted data length feature, order feature and uniformity feature, perform portrait matching from a portrait template library according to the data portrait, and in a case of successful matching, acquire and take a sorting strategy of the matched portrait as the target sorting strategy; and in a case of unsuccessful matching, generate at least one candidate strategy from a preset first strategy pool, and sort based on historical scores of the candidate strategies to take a candidate strategy with the highest historical score as the target sorting strategy. In this way, multi-dimensional feature analysis can be performed on the target data, so that the target sorting strategy can dynamically adapt to the data features.

[0045] Additional aspects and advantages of the present application will be given in part in the following description, become apparent from the following description, or be understood through practice of the present application. BRIEF DESCRIPTION OF DRAWINGS

[0046] The above and / or additional aspects and advantages of the present application will become apparent and be readily understood from the following description, taken in conjunction with the accompanying drawings, in which:

[0047] Figure 1 One of the step flowcharts of the adaptive sorting method of the embodiments of the present application;

[0048] Figure 2 The schematic diagram of the fitting curve A11 of the embodiments of the present application;

[0049] Figure 3 a fitting curve B11 of an embodiment of the present application;

[0050] Figure 4 a second step flow chart of an adaptive sorting method of an embodiment of the present application;

[0051] Figure 5 a principle block diagram of an adaptive sorting device of an embodiment of the present application;

[0052] Figure 6 a principle block diagram of an electronic device of an embodiment of the present application. DETAILED DESCRIPTION

[0053] Embodiments of the present application are described in detail below with reference to the attached drawings, which show by way of example, embodiments in which the same or similar elements have the same or similar reference numbers. The embodiments described below are examples only, and are not to be understood as limiting the present application.

[0054] In the description of the present application, the meaning of "several" is one or more, the meaning of "multiple" is two or more, greater than, less than, more than, etc. are understood as not including the number, "above", "below", "within", etc. are understood as including the number. If there is a description of "first", "second", etc. is only used for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features or implicitly indicating the order of indicated technical features.

[0055] In the field of data processing and high-performance computing, sorting is a basic and critical operation, and its efficiency directly affects the overall performance of the system. The mainstream sorting algorithms widely used in the industry at present include bubble sort, insertion sort, selection sort, quicksort, merge sort, heap sort, counting sort, bucket sort, radix sort, and TimSort, etc. Among them, TimSort is a hybrid stable sorting algorithm combining merge sort and insertion sort. The algorithm divides the data into "run" (continuous ascending or descending sequence), and the descending run is flipped to ascending. The minimum subsequence length is determined by calculating the dynamic threshold minrun (32-64), and the short sequence uses binary insertion sort optimization. The stack structure is maintained in the merge phase to manage the run, and the balance condition x1>x2+x3 or x1>x2 is forced to be met during merging, and the gallop mode is used to skip sorted elements to reduce the merging amount. TimSort achieves efficient sorting by analyzing the internal order of the data, and has been widely applied in the standard library of mainstream programming languages such as Python and Java.

[0056] Each of the above sorting algorithms has its own characteristics in terms of design principles, time complexity, space overhead, stability, in-place property, and sensitivity to data distribution. For example, comparison-based algorithms (such as quicksort and mergesort) are suitable for general scenarios, but their performance is significantly affected by the order of input data. Non-comparison-based algorithms (such as counting sort and radix sort) can achieve linear time complexity under certain data conditions (such as limited value range and integer type), showing significant advantages. In addition, some algorithms have good adaptive ability, such as insertion sort for nearly ordered data and TimSort for locally ordered sequences, while others are stable but lack flexibility, such as heap sort which guarantees O(n log n) performance in the worst case but cannot take advantage of existing data order.

[0057] However, despite the good performance of existing sorting algorithms in their respective applicable scenarios, the current technical system still has three common defects:

[0058] First, the multi-dimensional data feature comprehensive perception ability is insufficient: traditional methods usually only rely on a single dimension (such as data size n) or simple rules (such as "n < 10 use insertion sort") for strategy selection, and fail to systematically quantify and integrate multiple internal features of data, resulting in one-sided decision-making basis;

[0059] Second, the strategy selection mechanism is rigid: most sorting strategies use static rules or fixed priority strategies, making it difficult to make optimal judgments under unknown or changing data patterns;

[0060] Third, there is a lack of continuous learning and evolution ability: existing solutions usually only output sorting results, and cannot convert the actual performance results of each sorting into reusable knowledge, resulting in the inability to improve sorting performance with the number of uses.

[0061] Please refer to Figure 1 The embodiment discloses an adaptive sorting method, including S100~S300. It should be noted that the step labels in this embodiment are only for the convenience of understanding, and do not limit the execution order of the steps. The content of each step is described in detail as follows:

[0062] S100, obtaining target data to be sorted;

[0063] Exemplarily, the target data usually presents as a set of comparable numerical data, which is composed of one or more numerical elements, and the relative size of different elements can be explicitly distinguished by standard numerical comparison operations (such as greater than, less than or equal to), thereby providing a logical basis for ascending or descending order. Such target data has a wide range of sources and various forms in practical application scenarios: for example, the target data may be derived from a numerical column in a database to support the ordered presentation of query results; for another example, the target data may be an intermediate numerical array dynamically generated by a business module in a software system, serving as input for subsequent analysis or visualization processing; for another example, the target data may be interactive input directly from an end user, such as a sequence of numerical values such as scores, prices or timestamps manually entered by the user.

[0064] Notably, the target data often undergoes dynamic evolution in its life cycle, and the inherent distribution characteristics of the target data change significantly with the operation behavior. Taking the database scenario as an example, in the initial state, the numerical data in a column may present a completely disordered or approximately random distribution state; when the first sorting instruction is received, a full sorting operation needs to be performed on the disordered target data. Subsequently, if a new record is inserted into the sorted data set (such as a new transaction amount or user score), the sorting instruction is triggered again, and at this time, the target data to be processed as a whole has a high degree of local or global order, i.e., the rest of the data maintains the original order except for the newly added element. As can be seen, there is a substantial difference between the first sorting and the second sorting in terms of data situation: the former deals with high-entropy, low-structured disordered data, and the latter deals with low-entropy, high-structured nearly ordered data.

[0065] Further, the performance of the sorting strategy is closely related to the data size. In the case of small data size (such as limited number of elements), the differences between various sorting algorithms in terms of execution time, resource consumption, etc. are often not significant; however, as the data size continues to grow, the performance gap between different sorting strategies will rapidly widen, and some algorithms may experience exponential delay due to poor time complexity, while other algorithms can maintain efficient operation by effectively utilizing the data characteristics. Therefore, it is difficult to meet the high-performance and adaptive sorting requirements by relying only on fixed strategies or single-dimensional judgments (such as only relying on data length).

[0066] S200, performing feature extraction on the target data to obtain a data length feature, an order degree feature and a uniformity feature, the data length feature being used to represent the data items contained in the target data, the order degree feature being used to represent the smoothness of the change trend between adjacent elements in the target data, and the uniformity feature being used to represent the uniformity of the target data in numerical distribution;

[0067] Exemplarily, as mentioned above, in the face of diversified data situations and dynamically changing data scales, the sorting strategy must have a high degree of adaptability, and can be flexibly adjusted according to the internal characteristics of the current input data. However, the premise of achieving this goal is: how to accurately and structurally depict and quantify the "current data situation", so as to provide reliable and computable basis for subsequent intelligent decision-making. This has become one of the core technical difficulties of realizing adaptive sorting methods.

[0068] Therefore, the embodiment proposes to construct a data portrait of the target data through a multi-dimensional feature space. In the construction process, data length features, order degree features and uniformity features are introduced to jointly describe the basic portrait of the data situation.

[0069] Among them, as one of the basic features of data, the data length feature is used to represent the data items contained in the target data, which can be obtained by counting the number of numerical elements in the target data. The data length feature is also called the data scale feature. The time complexity of different sorting algorithms is different in sensitivity to data scale. For example, the sorting algorithm with time complexity of O(n 2 ) may be better than the sorting algorithm with time complexity of O(n log n) under small data scale. In addition to affecting the time complexity of the sorting algorithm, the data length feature also affects the order degree feature.

[0070] The order degree feature is used to represent the smoothness of the change trend between adjacent elements in the target data. The core idea is that the fewer the trend switches, the more ordered the data, and the higher the order degree. Take arrays A and B as examples for illustration:

[0071] Array A=[1, 2, 4, 3, 5, 6]: its local trend sequence is "rise→rise→fall→rise→rise", and the corresponding trend sequence A1=[1, 1, 0, 1, 1] can be represented, where "1" represents ascending order, and "0" represents descending order, and there are 2 trend switches; Array B=[2, 1, 6, 2, 5, 4]: its trend sequence is "fall→rise→fall→rise→fall", and the corresponding trend sequence B1=[0, 1, 0, 1, 0] can be represented, and there are 4 trend switches.

[0072] Please refer to Figure 2 and Figure 3If the above trend sequence is regarded as a discrete signal and fitted as a continuous curve (such as curve A11 and curve B11), it can be observed intuitively that the fluctuation frequency of curve A11 is significantly lower than that of curve B11, showing higher smoothness. It can be inferred that the overall orderliness of array A is better than that of array B. Based on this, the order degree feature can be defined as a normalized index negatively correlated with the number of trend switching times, and the fewer the switching times, the higher the order degree; the order degree of a completely monotonic sequence reaches the maximum value, while the order degree of a frequently oscillating sequence tends to the minimum value. In the normalization calculation process of the order degree feature, the data length feature can be introduced to uniformly quantify the order degree features of target data of different data scales. The order degree feature can capture local ordered structures in data more finely, and is especially suitable for identifying partially ordered, segmented ordered or real data containing a small amount of disturbance.

[0073] The uniformity feature is used to represent the uniformity of the target data in the numerical distribution. The frequency distribution of each unique value in the target data is calculated based on the information entropy theory; then the Shannon entropy of the distribution is calculated and normalized to the interval [0, 1], and the denominator of the normalization is the theoretical maximum entropy under the current number of unique values (i.e. the entropy value when all values appear only once). The following takes two arrays C and D as examples for illustration:

[0074] Array C = [1, 1, 2, 3, 4, 3, 3]: contains 4 unique values {1, 2, 3, 4}, among which the value "3" appears 3 times, "1" appears 2 times, and the rest appears 1 time. The frequency distribution is significantly uneven, the Shannon entropy is low, and the uniformity is low after normalization; Array D = [1, 16, 2, 15, 7, 3, 12]: contains 7 unique values, and each value appears only once. The frequency is completely balanced, the Shannon entropy reaches the theoretical maximum, and the uniformity after normalization is 1.0 (the highest).

[0075] S300, determining a target sorting strategy of the target data based on a preset decision model, wherein please refer to Figure 4 The determination process of the target sorting strategy includes:

[0076] S310, constructing a data portrait of the target data according to the data length feature, the order degree feature and the uniformity feature;

[0077] S320, performing portrait matching from a preset portrait template library according to the data portrait, and in the case of successful matching, obtaining and taking the sorting strategy of the matched portrait as the target sorting strategy;

[0078] S330, in the case of unsuccessful matching, generating at least one candidate strategy from a preset first strategy pool, and sorting based on the historical scores of the candidate strategies to select the candidate strategy with the highest historical score as the target sorting strategy.

[0079] Exemplarily, the decision model constructs a data portrait of the target data according to the data length feature, the order degree feature and the uniformity feature, and identifies the current data context based on the data portrait, so as to adaptively determine the corresponding target sorting strategy. Specifically, the decision model performs portrait matching between the data portrait and a portrait template in a preset portrait template library, wherein the portrait template library includes but is not limited to the following portrait templates:

[0080] Small-scale data template: when the data length feature is less than a first length threshold (e.g., 50), since the recursion or divide-and-conquer overhead of advanced sorting algorithms (such as quicksort, mergesort, etc.) dominates, in this context, a simple sorting algorithm (such as the insertion sorting algorithm) has better performance in actual operation, and therefore the target sorting strategy can be determined as insertion sorting.

[0081] Completely or highly reverse order data template: when the order degree feature is less than a first order degree threshold (e.g., 0.05) and the data length feature is greater than a second length threshold (e.g., 1000), the traditional quicksort is prone to degrade the time complexity to O(n 2 ) due to extremely unbalanced partitioning; in this context, the target sorting strategy is determined as: first performing a linear time reversal operation on the data, and then using mergesort; in this way, the worst input is converted into the optimal input (completely ordered) through the low-overhead reversal operation, and then the performance advantage of mergesort is utilized to ensure the performance lower limit of O(n log n), which is conducive to ensuring the performance of sorting.

[0082] Highly repetitive data template: when the uniformity feature is lower than a first uniformity threshold (e.g., 0.3), it indicates that there are a large number of repeated elements in the data, and at this time the traditional two-way quicksort algorithm will be inefficient due to unbalanced partitioning; therefore, the target sorting strategy can be determined as three-way quicksort, which divides the "less than", "equal to" and "greater than" three intervals to efficiently process repeated values.

[0083] Super-large-scale external storage data template: when the data length feature exceeds a third length threshold (e.g., 1000000) and the runtime detects that the available memory is less than a predetermined proportion (e.g., 1 / 4) of the data length feature, since the entire data cannot be loaded into the memory at one time, at this time, the target sorting strategy can be determined as external mergesort, that is, the target data is divided into multiple memory-processable sub-blocks, which are sorted respectively and then the overall sorting is completed through multi-way merging (such as based on the minimum heap) to reduce the disk I / O overhead.

[0084] The image templates stored in the image template library are typical data context templates summarized and refined based on a large amount of historical running data and actual application scenarios. The corresponding sorting strategies have been repeatedly verified in various measured environments, and have good stability and reliability in terms of time complexity, space overhead, cache hit rate, and actual running time consumption. However, in actual operation, the target data to be sorted often shows high diversity, dynamics and unpredictability, which makes it difficult for the data image of the target data to fall completely within the coverage of the preset image template library. In other words, although the image template library can efficiently process common or typical data distribution situations, it cannot exhaust all possible data feature combinations.

[0085] To cope with the situation that image template matching is unsuccessful, a strategy pool including various basic sorting algorithms and different combinations of sorting algorithms can be constructed. The first part (referred to as the first strategy pool) of the strategy pool has each strategy called multiple times in historical operation, and the corresponding performance value (such as quantifiable indicators such as average sorting time consumption, comparison times, memory occupation or I / O operation frequency, etc.) is better than the preset performance threshold, indicating that the strategy has actual usability and performance advantage in specific or generalized scenarios, and has passed the performance verification mechanism.

[0086] When the decision model cannot successfully match the data image of the target data with all the templates in the image template library, at least one candidate strategy is generated from the first strategy pool, and sorting evaluation is performed based on the historical score of the candidate strategy, wherein the historical score is a weighted score index calculated based on the comprehensive performance of the candidate sorting strategy in past similar or related data contexts, which can comprehensively reflect the historical running efficiency, stability and applicability of the candidate sorting strategy. By sorting the candidate strategies from high to low according to the historical score, the candidate strategy with the best historical performance can be determined, and the corresponding candidate strategy is used as the target sorting strategy of the target data. In this way, when facing unknown or complex data distribution characteristics, the target sorting strategy with high performance guarantee can be adaptively output, which is beneficial to improving the performance of sorting.

[0087] The embodiment extracts features of the target data, and constructs a data image of the target data according to the extracted data length feature, order feature and uniformity feature. According to the data image, image matching is performed from the image template library, and in the case of successful matching, the sorting strategy of the matched image is obtained and used as the target sorting strategy. In the case of unsuccessful matching, at least one candidate strategy is generated from the preset first strategy pool, and sorting is performed based on the historical score of the candidate strategy to select the candidate strategy with the highest historical score as the target sorting strategy. In this way, multi-dimensional feature analysis can be performed on the target data to enable the target sorting strategy to dynamically adapt to data features.

[0088] In some application examples, the step S200 of extracting features from the target data includes extracting a data length feature, a sequence degree feature, and a uniformity feature.

[0089] S210, determining the data length feature of the target data and the number of sequence direction changes between adjacent elements.

[0090] S220, determining a trend factor according to the data length feature and the number of sequence direction changes.

[0091] S230, determining the sequence degree feature according to the difference between the numerical value one and the trend factor.

[0092] For example, the mathematical relationship of the sequence degree feature is: sequence degree feature = 1 - (number of sequence direction changes / data length feature), wherein the ratio between the number of sequence direction changes and the data length feature is the trend factor, that is, the trend factor is determined according to the number of sequence direction changes and the data length feature. In one application example, array A = [1, 2, 4, 3, 5, 6]: the local trend sequence is "rise→rise→fall→rise→rise", and the corresponding trend sequence A1 = [1, 1, 0, 1, 1] can be expressed, wherein "1" represents ascending order, "0" represents descending order, and there are 2 trend switches, that is, the number of sequence direction changes is 2, and the data length feature is the number of elements of array A, that is, 6, so the sequence degree feature = 1 - (2 / 6) ≈ 0.67; in another application example, array B = [2, 1, 6, 2, 5, 4]: the trend sequence is "fall→rise→fall→rise→fall", and the corresponding trend sequence B1 = [0, 1, 0, 1, 0], and there are 4 trend switches, that is, the number of sequence direction changes is 4, and the data length feature is also 6, so the sequence degree feature = 1 - (4 / 6) ≈ 0.33.

[0093] In some application examples, the step S200 of extracting features from the target data includes extracting a data length feature, a sequence degree feature, and a uniformity feature.

[0094] S240, determining the Shannon entropy value and the maximum possible entropy value of the target data.

[0095] S250, determining the uniformity feature according to the ratio between the Shannon entropy value and the maximum possible entropy value.

[0096] Exemplarily, the uniformity feature is calculated based on information entropy theory. Specifically, first, the Shannon entropy of each unique value in the target data is calculated according to the frequency of occurrence of the unique value, and the Shannon entropy is used to represent the uncertainty or information confusion degree of the data distribution; then, the theoretical maximum entropy value under the current number of unique values is determined, that is, the Shannon entropy corresponding to the assumption that all unique values appear with equal probability (that is, each value appears only once and is completely uniformly distributed), which is referred to as the maximum possible entropy; finally, the Shannon entropy value and the maximum possible entropy value are normalized, and the ratio of the two is calculated to obtain the uniformity feature. The ratio is between 0 and 1, and the closer the value is to 1, the more uniform the numerical distribution of the target data; otherwise, the data distribution is more concentrated or there are significant repetitions.

[0097] In some other application examples, the step S200 of feature extraction on the target data to obtain the data length feature, the order degree feature and the uniformity feature includes:

[0098] S260, feature extraction is performed on the target data to obtain the data length feature, the order degree feature, the uniformity feature and the numerical range feature;

[0099] Correspondingly, the step S310 of constructing the data portrait of the target data according to the data length feature, the order degree feature and the uniformity feature includes:

[0100] S311, constructing the data portrait of the target data according to the data length feature, the order degree feature, the uniformity feature and the numerical range feature.

[0101] Exemplarily, the numerical range feature is used to represent the difference between the maximum value and the minimum value of the target data. The numerical range feature can reflect the distribution width of the target data in the numerical domain. In the portrait template library, there is a portrait template for high-density, narrow numerical range data, referred to as high-density data template with minimum numerical range. The matching conditions of the portrait template are that the ratio of the numerical range feature to the data length feature is less than a preset first threshold (for example, 0.01), indicating that the numerical space occupied by a unit data item is extremely small and the data is highly dense in a limited interval; and the uniformity feature is greater than a preset second uniformity threshold (for example, 0.8), indicating that the values are relatively uniformly distributed in the numerical interval and there is no obvious concentrated or sparse area. In this type of data situation, traditional sorting algorithms based on element comparison (such as quicksort, mergesort, etc.) are limited by the theoretical lower bound Ω (n log n) and are difficult to perform well, while non-comparison sorting algorithms such as counting sort can take advantage of the small numerical range and dense distribution to achieve an approximate linear time complexity (close to O (n)) sorting operation by directly mapping the value domain to the index space, significantly reducing the actual running overhead. Therefore, the target sorting strategy can be determined as counting sort to fully utilize the data distribution characteristics to improve the sorting efficiency.

[0102] In some application examples, step S330, in the case of unsuccessful matching, at least one candidate strategy is generated from the preset first strategy pool, and the candidate strategies are sorted based on their historical scores to select the candidate strategy with the highest historical score as the target sorting strategy, including:

[0103] S331, in the case of unsuccessful matching, at least one candidate strategy is generated from the preset first strategy pool;

[0104] S332, at least one candidate strategy is filtered according to the current environment index;

[0105] S333, the candidate strategies after filtering are sorted based on their historical scores to select the candidate strategy with the highest historical score as the target sorting strategy.

[0106] For example, the current environment index refers to the real-time performance parameters of the running environment when the sorting task is executed, including but not limited to available memory capacity, CPU load, cache size, disk I / O bandwidth, or concurrent thread number, and other system resource state information. These environment indexes directly affect the actual execution efficiency and feasibility of different sorting algorithms. For example, although the merge sorting algorithm has a stable O(n log n) time complexity, the merge sorting algorithm usually requires additional O(n) space for caching temporary arrays, which may cause memory overflow or other performance degradation in the case of limited available memory; similarly, some recursive sorting algorithms may also cause runtime exceptions when the stack space is insufficient. Therefore, in order to improve the practicality and executability of the sorting strategy selection, after the unsuccessful portrait template matching and the generation of at least one candidate sorting strategy from the first strategy pool, the candidate strategies are filtered according to the current environment index, which can realize the perception of the running environment and filter out candidate strategies that cannot be effectively run or have high risk of failure in the current running environment, thereby obtaining a candidate strategy subset adapted to the current environment. Then, the candidate strategies after filtering are sorted based on their respective historical scores, for example, according to the comprehensive performance in the past similar data and environment combinations, and the candidate strategy with the highest historical score is selected as the final target sorting strategy. In this way, the advantages of the historical performance optimization strategy are retained, and the pre-posed environment perception can effectively avoid the failure of strategy execution or the performance drop caused by resource constraints, which is beneficial to significantly improve the robustness, reliability and actual deployment ability of the adaptive sorting method.

[0107] In some application examples, the adaptive sorting method further includes:

[0108] S340, in the case of unsuccessful matching, the similarity between the data portrait and each portrait template in the portrait template library is determined;

[0109] S350, in the case where the similarity is greater than or equal to a preset similarity threshold, generating at least one candidate strategy from a preset first strategy pool, and sorting based on historical scores of the candidate strategies to select a candidate strategy with the highest historical score as a target ranking strategy;

[0110] S360, in the case where the similarity is less than the similarity threshold, randomly determining the target ranking strategy from a preset second strategy pool.

[0111] By way of example, unlike the application examples described above, in the case where the portrait template matching is unsuccessful, in order to further improve the intelligent level and adaptability of strategy selection, the similarity between the data portrait and each portrait template is determined to quantify the closeness of the current data context and the known typical context, and a differentiated candidate strategy is generated accordingly. It should be noted that the calculation of the similarity can be achieved by using various distance measurement methods, such as Euclidean distance, cosine similarity, Mahalanobis distance, or weighted feature matching score, etc. The similarity threshold can be dynamically adjusted according to the running stage (such as the initial exploration stage, the later stable running stage) or the business needs, in order to balance the stability and exploration of strategy selection.

[0112] Specifically, when the similarity is greater than or equal to the preset similarity threshold, it indicates that although the precise matching condition has not been reached, the target data still has a high correlation with a certain type of verified data context. At this time, at least one candidate ranking strategy is generated from the first strategy pool, and the strategies stored in the first strategy pool are all verified strategies with sufficient historical running times and stable performance. The subsequent processing procedure is the same as the application examples described above, for example, the candidate strategies are screened for environmental adaptability according to the current environmental indicators (such as available memory, CPU load, etc.), and strategies that do not meet the resource constraints are excluded; the historical scores of the screened strategies are sorted, and the strategy with the highest score is selected as the target ranking strategy for execution, thereby reusing a high-reliability ranking strategy in a similar data context.

[0113] When the similarity is less than the preset similarity threshold, it indicates that the combination of data distribution characteristics presented by the target data is relatively rare in historical experience, and the corresponding data context has high novelty, lacking a suitable ranking strategy that has been fully verified. In this case, in order to avoid the strategy selection from being stuck and to maintain appropriate exploration ability, a ranking strategy can be randomly selected from a second strategy pool (the second part of the strategy pool) as the target ranking strategy. The second strategy pool is used to store exploratory strategies, including but not limited to: strategies with fewer call times in historical running, strategies with performance that have not yet formed stable statistical conclusions, or new introduced but not yet fully verified ranking algorithms and their combinations.

[0114] The embodiment based on similarity performs hierarchical processing, which not only ensures the ranking performance and stability in a conventional data context, but also maintains the ability to actively explore when facing unknown data distribution characteristics, is conducive to accumulating running data in new contexts, and thus enhances the continuous optimization capability of the portrait template library and the strategy pool.

[0115] Step S300, determining a target ranking strategy of the target data based on a preset decision model, and then comprising:

[0116] S410, ranking the target data based on the target ranking strategy to obtain a ranking result;

[0117] S420, obtaining and generating experience data according to a performance indicator of the ranking result;

[0118] S430, incrementally learning the decision model based on the experience data to update the historical scores of each candidate strategy in the decision model.

[0119] For example, after determining the target ranking strategy applicable to the target data, the ranking operation is performed on the target data based on the target ranking strategy to obtain a corresponding ranking result. In order to further enhance the continuous learning capability and environmental adaptability of the decision model, the performance indicators of this ranking process are synchronously collected, and structured experience data is generated. The experience data includes the feature data of the target data (such as the order degree feature, the uniformity feature, the data length feature, and the numerical range feature), the target ranking strategy, and the corresponding performance indicators (such as the sorting time consumption, the memory peak, the comparison operation frequency, the cache miss rate, or the I / O operation frequency). The experience data is used for incrementally learning the decision model to dynamically update the historical scores of each candidate ranking strategy in the decision model. The update mechanism introduces a knowledge update mechanism based on time weight, that is, the newly obtained experience data is given a higher weight than the historical experience data, so as to ensure that the decision model can timely respond to the change trend of data distribution or running environment.

[0120] In a specific application example, the knowledge update mechanism based on time weight is realized by configuring a forgetting factor, for example, the forgetting factor is configured as a value in the interval (0, 1), and is configured to be dynamically adjusted (for example, gradually increased to accelerate the decay of old knowledge) with running time or learning rounds. For the historical score of any candidate strategy in a certain data context, the update formula can be expressed as: new weight = old experience data weight x forgetting factor + new experience data weight x (1-forgetting factor). In this way, the historical score retains the long-term statistical trend while gradually weakening the influence of obsolete data, making the decision model more sensitive to recent performance, thereby improving the timeliness and accuracy of strategy recommendation.

[0121] Please refer to Figure 5, based on the same technical concept of the adaptive sorting method embodiments, the embodiment further provides an adaptive sorting device, comprising:

[0122] The data acquisition module 110 is configured to acquire target data to be sorted.

[0123] The feature extraction module 120 is configured to perform feature extraction on the target data to obtain a data length feature, a degree of order feature, and a uniformity feature. The data length feature is used to represent data items contained in the target data. The degree of order feature is used to represent the smoothness of the change trend between adjacent elements in the target data. The uniformity feature is used to represent the uniformity of the numerical distribution of the target data.

[0124] The sorting decision module 130 is configured to determine a target sorting strategy for the target data based on a preset decision model. The determination process of the target sorting strategy includes:

[0125] According to the data length feature, the degree of order feature, and the uniformity feature, a data portrait of the target data is constructed.

[0126] According to the data portrait, an image matching is performed from a preset image template library. If the matching is successful, a sorting strategy of the matched image is obtained and used as the target sorting strategy.

[0127] If the matching is unsuccessful, at least one candidate strategy is generated from a preset first strategy pool, and sorting is performed based on the historical scores of the candidate strategies to select the candidate strategy with the highest historical score as the target sorting strategy.

[0128] In this embodiment, feature extraction is performed on the target data, and a data portrait of the target data is constructed according to the extracted data length feature, degree of order feature, and uniformity feature. An image matching is performed from an image template library according to the data portrait. If the matching is successful, a sorting strategy of the matched image is obtained and used as the target sorting strategy. If the matching is unsuccessful, at least one candidate strategy is generated from a preset first strategy pool, and sorting is performed based on the historical scores of the candidate strategies to select the candidate strategy with the highest historical score as the target sorting strategy. In this way, multi-dimensional feature analysis can be performed on the target data to enable the target sorting strategy to dynamically adapt to the data features. It should be noted that the inventive concept of the adaptive sorting device embodiment is the same as that of the adaptive sorting method embodiments described above. The contents not involved in the adaptive sorting device embodiment can be referred to the adaptive sorting method embodiments described above, and will not be described here.

[0129] Please refer to Figure 6The embodiment also provides an electronic device, including a processor 210 and a memory 220, the memory 220 storing a computer program, and the processor 210 is used to implement the adaptive sorting method when running the computer program. The details of the adaptive sorting method can be referred to the above, and will not be repeated here.

[0130] The embodiment extracts features of the target data, constructs a data portrait of the target data according to the extracted data length feature, sequence feature and uniformity feature, performs portrait matching from the portrait template library according to the data portrait, and in the case of successful matching, acquires and takes the sorting strategy of the matched portrait as the target sorting strategy; and in the case of unsuccessful matching, generates at least one candidate strategy from the preset first strategy pool, and sorts based on the historical scores of the candidate strategies to select the candidate strategy with the highest historical score as the target sorting strategy. In this way, multi-dimensional feature analysis can be performed on the target data, so that the target sorting strategy can dynamically adapt to the data features.

[0131] The embodiment also provides a computer readable storage medium, the computer readable storage medium storing a computer program, and the computer program is used to implement the adaptive sorting method when running. The details of the adaptive sorting method can be referred to the above, and will not be repeated here.

[0132] The embodiment extracts features of the target data, constructs a data portrait of the target data according to the extracted data length feature, sequence feature and uniformity feature, performs portrait matching from the portrait template library according to the data portrait, and in the case of successful matching, acquires and takes the sorting strategy of the matched portrait as the target sorting strategy; and in the case of unsuccessful matching, generates at least one candidate strategy from the preset first strategy pool, and sorts based on the historical scores of the candidate strategies to select the candidate strategy with the highest historical score as the target sorting strategy. In this way, multi-dimensional feature analysis can be performed on the target data, so that the target sorting strategy can dynamically adapt to the data features.

[0133] The embodiment of the application is described in detail above in combination with the drawings, but the application is not limited to the above embodiment, and various changes can be made within the knowledge of those skilled in the art without departing from the purpose of the application.

Claims

1. An adaptive ranking method, characterized by, The method comprises the following steps: obtaining target data to be sorted; performing feature extraction on the target data to obtain data length features, order degree features and uniformity features, the data length features being used to represent data items contained in the target data, the order degree features being used to represent the smoothness of the change trend between adjacent elements in the target data, and the uniformity features being used to represent the uniformity of the target data in numerical distribution; determining a target sorting strategy of the target data based on a preset decision model, wherein the determination process of the target sorting strategy comprises: constructing a data portrait of the target data according to the data length features, the order degree features and the uniformity features; performing portrait matching from a preset portrait template library according to the data portrait, and in the case of successful matching, obtaining and taking the sorting strategy of the matched portrait as the target sorting strategy; in the case of unsuccessful matching, generating a candidate strategy from a preset first strategy pool, screening the candidate strategy according to a current environment index, and sorting the candidate strategies based on the historical scores of the screened candidate strategies to select the candidate strategy with the highest historical score as the target sorting strategy, wherein the current environment index refers to the real-time performance parameters of the running environment when the sorting task is executed.

2. The adaptive ranking method of claim 1, wherein, The feature extraction on the target data to obtain the data length features, the order degree features and the uniformity features comprises: determining the data length features of the target data and the number of order direction changes between adjacent elements; determining a trend factor according to the data length features and the number of order direction changes; determining the order degree features according to the difference between the numerical value and the trend factor.

3. The adaptive ranking method of claim 1 or 2, wherein, The feature extraction on the target data to obtain the data length features, the order degree features and the uniformity features comprises: determining the Shannon entropy value and the maximum possible entropy value of the target data; determining the uniformity features according to the ratio between the Shannon entropy value and the maximum possible entropy value.

4. The adaptive ranking method of claim 1, wherein, The feature extraction on the target data to obtain the data length features, the order degree features and the uniformity features comprises: performing feature extraction on the target data to obtain the data length features, the order degree features, the uniformity features and the numerical range features; The construction of the data portrait of the target data according to the data length features, the order degree features and the uniformity features comprises: constructing the data portrait of the target data according to the data length features, the order degree features, the uniformity features and the numerical range features.

5. The adaptive ranking method of claim 1, wherein, The determination of the target sorting strategy of the target data based on the preset decision model further comprises: sorting the target data based on the target sorting strategy to obtain a sorting result; generating experience data based on the performance index data of the sorting result; performing incremental learning on the decision model based on the experience data to update the historical scores of the candidate strategies in the decision model.

6. A method of adaptive ranking, characterized by, The method comprises the following steps: obtaining target data to be sorted; characteristics, the data length characteristic is used to represent data items contained in the target data, the order degree characteristic is used to represent a smooth degree of a change trend between adjacent elements in the target data, and the uniformity characteristic is used to represent a uniform degree of the target data on a numerical value distribution; determine a target sorting strategy of the target data based on a preset decision model, wherein a determination process of the target sorting strategy comprises: construct a data portrait of the target data according to the data length characteristic, the order degree characteristic and the uniformity characteristic; perform portrait matching from a preset portrait template library according to the data portrait, and in a case of successful matching, acquire and take a sorting strategy of a matched portrait as the target sorting strategy; in a case of unsuccessful matching, determine a similarity between the data portrait and each portrait template in the portrait template library; in a case that the similarity is greater than or equal to a preset similarity threshold, generate a candidate strategy from a preset first strategy pool, screen the candidate strategy according to a current environment index, and sort the candidate strategy based on historical scores of the screened candidate strategy to select a candidate strategy with the highest historical score as the target sorting strategy, the current environment index refers to a real-time performance parameter of a running environment when a sorting task is executed; in a case that the similarity is less than the similarity threshold, randomly determine a target sorting strategy from a preset second strategy pool.

7. The adaptive ranking method of claim 6, wherein, The determination of the target sorting strategy based on the preset decision model further comprises: sort the target data based on the target sorting strategy to obtain a sorting result; acquire and generate experience data according to performance index data of the sorting result; perform incremental learning on the decision model based on the experience data to update historical scores of each candidate strategy in the decision model.

8. An adaptive sequencing apparatus, characterized by, comprises: a data acquisition module configured to acquire target data to be sorted; a feature extraction module configured to extract features of the target data to obtain data length characteristics, order degree characteristics and uniformity characteristics, the data length characteristics are used to represent data items contained in the target data, the order degree characteristics are used to represent a smooth degree of a change trend between adjacent elements in the target data, and the uniformity characteristics are used to represent a uniform degree of the target data on a numerical value distribution; a sorting decision module configured to determine a target sorting strategy of the target data based on a preset decision model, wherein a determination process of the target sorting strategy comprises: construct a data portrait of the target data according to the data length characteristic, the order degree characteristic and the uniformity characteristic; perform portrait matching from a preset portrait template library according to the data portrait, and in a case of successful matching, acquire and take a sorting strategy of a matched portrait as the target sorting strategy; In the case of unsuccessful matching, a candidate strategy is generated from a preset first strategy pool, the candidate strategy is screened according to a current environment index, and the screened candidate strategies are sorted based on historical scores to select a candidate strategy with the highest historical score as the target ranking strategy, wherein the current environment index refers to a real-time performance parameter of a running environment when a ranking task is executed.

9. An electronic device comprising a processor and a memory, said memory having stored therein a computer program, characterized in that, The processor, when running the computer program, is configured to implement the adaptive ranking method according to any one of claims 1 to 7.

10. A computer-readable storage medium having stored therein a computer program, characterized in that, The computer program, when run, implements the adaptive ranking method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data sorting method and device, electronic equipment and storage medium

    CN112732766A

  • Dynamic environment-oriented self-adaptive online sorting method and system

    CN114861093A