Self-adaptive sorting method and device, electronic equipment and storage medium

By performing multidimensional feature analysis and profile matching or strategy selection on the target data, the problems of insufficient multidimensional feature integration and rigid strategies in existing ranking algorithms are solved, and dynamic adaptation of adaptive ranking strategies and performance improvement are achieved.

CN121256332AActive Publication Date: 2026-01-02ZHUHAI CHENGMI TECH CO LTD +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511809632.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-03
Publication Date
2026-01-02
Estimated Expiration
2045-12-03

AI Technical Summary

Technical Problem

Existing ranking algorithms suffer from problems such as insufficient integration of multi-dimensional features, rigid strategy selection, and lack of continuous learning ability, making it difficult to dynamically adapt to data features for optimization.

Method used

By performing multi-dimensional 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 processing, the ranking strategy is dynamically adapted.

Benefits of technology

The target sorting strategy can dynamically adapt to data characteristics, improving sorting performance and robustness, and adapting to diverse and dynamically changing data scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121256332A_ABST
    Figure CN121256332A_ABST
Patent Text Reader

Abstract

The invention discloses a self-adaptive sorting method and device, electronic equipment and a storage medium, and the method comprises the steps: carrying out the feature extraction of target data, constructing a data portrait of the target data according to the extracted data length feature, sequence feature and uniformity feature, carrying out the portrait matching from a portrait template library according to the data portrait, and carrying out the recognition of the target data. Under the condition that the matching is successful, obtaining a sorting strategy of the matched portrait and taking the sorting strategy as a target sorting strategy; and under the condition that the matching is unsuccessful, 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 a 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.
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 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 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: obtaining target data to be sorted; 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; 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 feature, the order degree feature and the uniformity feature; 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 at least one candidate strategy from a preset first strategy pool, and performing sorting based on the historical score of the candidate strategy to select the candidate strategy with the highest historical score as the target sorting strategy.

[0005] According to some embodiments of the present application, the feature extraction on the target data comprises: determining the data length feature and the number of order direction changes between adjacent elements of the target data; determining a trend factor according to the data length feature and the number of order direction changes; determining the order degree feature according to the difference between the numerical value one and the trend factor.

[0006] According to some embodiments of the present application, the feature extraction on the target data comprises: determining the Shannon entropy value and the maximum possible entropy value of the target data; determining the uniformity feature according to the ratio between the Shannon entropy value and the maximum possible entropy value.

[0007] According to some embodiments of the present application, the feature extraction on the target data comprises: extracting the data length feature, the order degree feature, the uniformity feature and the numerical value range feature from the target data; the data portrait of the target data is constructed according to the data length feature, the order degree feature and the uniformity feature, comprising: the data portrait of the target data is constructed according to the data length feature, the order degree feature, the uniformity feature and the numerical value range feature.

[0008] According to some embodiments of the present application, 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, comprising: in the case of unsuccessful matching, at least one candidate strategy is generated from the preset first strategy pool; the at least one candidate strategy is screened according to the current environmental indicators; the candidate strategies after screening are sorted based on their historical scores to select the candidate strategy with the highest historical score as the target sorting strategy.

[0009] According to some embodiments of the present application, the adaptive sorting method further comprises: in the case of unsuccessful matching, the similarity between the data portrait and each portrait template in the portrait template library is determined; In a case where the similarity is greater than or equal to a preset similarity threshold, at least one candidate strategy is generated from a preset first strategy pool, and the candidate strategies are sorted based on historical scores of the candidate strategies to select a candidate strategy with the highest historical score as the target sorting strategy; In a case where the similarity is less than the similarity threshold, a target sorting strategy is randomly determined from a preset second strategy pool.

[0010] According to some embodiments of the present application, the target sorting strategy of the target data is determined based on the preset decision model, and then the method further comprises: sorting the target data based on the target sorting strategy to obtain a sorting result; obtaining experience data based on a performance indicator of the sorting result; incrementally learning the decision model based on the experience data to update historical scores of candidate strategies in the decision model.

[0011] In a second aspect, embodiments of the present application provide an adaptive sorting device, comprising: a data acquisition module configured to acquire target data to be sorted; 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 a smooth degree of a change trend between adjacent elements in the target data, and the uniformity feature being used to represent a uniformity degree of the target data in numerical distribution; a sorting decision module configured to determine 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 feature, the sequence degree feature and the uniformity feature; performing portrait matching from a preset portrait template library according to the data portrait, and in a case where the matching is successful, obtaining and taking a sorting strategy of a matched portrait as the target sorting strategy; in a case where the matching is unsuccessful, generating at least one candidate strategy from a preset first strategy pool, and sorting the candidate strategies based on historical scores of the candidate strategies to select a candidate strategy with the highest historical score as the target sorting strategy.

[0012] In a third aspect, embodiments of the present application provide 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.

[0013] In a fourth aspect, an embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, and the computer program is executed to implement the adaptive sorting method.

[0014] The embodiment of the present application has at least the following beneficial effects: The embodiment of the present application 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 a portrait template library according to the data portrait, and acquires and takes the sorting strategy of the matched portrait as the target sorting strategy in the case of successful matching; and generates at least one candidate strategy from the preset first strategy pool in the case of unsuccessful matching, and performs sorting 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, so that the target sorting strategy can dynamically adapt to the data features.

[0015] Additional aspects and advantages of the present application will be made apparent by the following description and the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS

[0016] 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: Figure 1 One of the step flowcharts of the adaptive sorting method of the embodiment of the present application; Figure 2 The schematic diagram of the fitting curve A11 of the embodiment of the present application; Figure 3 The schematic diagram of the fitting curve B11 of the embodiment of the present application; Figure 4 The second step flowchart of the adaptive sorting method of the embodiment of the present application; Figure 5 The principle block diagram of the adaptive sorting device of the embodiment of the present application; Figure 6 The principle block diagram of the electronic device of the embodiment of the present application. DETAILED DESCRIPTION

[0017] Embodiments of the present application are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference signs represent the same or similar elements or elements with the same or similar functions throughout. The embodiments described below by referring to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as a limitation of the present application.

[0018] 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" and the like are understood as including the number. If there is a description of "first", "second" and the like, it 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 the order of indicated technical features.

[0019] 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 current industry widely uses mainstream sorting algorithms, including 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.

[0020] Each of the above sorting algorithms has its own characteristics in terms of design principles, time complexity, space overhead, stability, in-place, 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; while 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 the existing order of data.

[0021] However, although existing sorting algorithms perform well in their respective application scenarios, the current technical system still has three common defects: 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; Secondly, the strategy selection mechanism is rigid: most sorting strategies adopt static rules or fixed priority strategies, which makes it difficult to make the optimal judgment under unknown or changing data patterns; Third, there is a lack of continuous learning and evolution capabilities: existing solutions usually only output the sorting results, but cannot transform the actual performance results of each sorting into reusable knowledge, resulting in the sorting performance not improving with the number of uses.

[0022] Please refer to Figure 1 This embodiment discloses an adaptive sorting method, including steps S100 to S300. It should be noted that the numbering of the steps in this embodiment is only for ease of review and understanding, and does not limit the execution order of the steps. The details of each step are described below: S100, Obtain the target data to be sorted; For example, target data typically manifests as a set of comparable numerical data, consisting of one or more numerical elements. The relative size relationships between different elements can be clearly defined through standard numerical comparison operations (such as greater than, less than, or equal to), thus providing a logical basis for ascending or descending sorting. Such target data comes from a wide range of sources and takes various forms in practical applications: for example, target data may originate from a numerical column in a database to support the ordered presentation of query results; another example is that target data may be an intermediate numerical array dynamically generated by a business module within a software system, serving as input for subsequent analysis or visualization; yet another example is that target data can be directly from interactive input from end users, such as a sequence of numerical values ​​like scores, prices, or timestamps manually entered by the user.

[0023] It is worth noting that target data often undergoes a dynamic evolution throughout its lifecycle, and its inherent distribution characteristics change significantly with operational actions. Taking a database scenario as an example, initially, a column of numerical data may exhibit a completely disordered or nearly random distribution. When a sorting instruction is received for the first time, a full sorting operation must be performed on the disordered target data. Subsequently, if a new record is inserted into the already sorted dataset (such as adding a transaction amount or user rating), triggering another sorting instruction, the target data to be processed now possesses a high degree of local or global order; that is, except for the newly added element, the rest largely maintains its original order. Therefore, the data context faced by the first and second sorting operations is fundamentally different: the former deals with high-entropy, low-structured disordered data, while the latter deals with low-entropy, highly structured, nearly ordered data.

[0024] Further, the performance of the sorting strategy is closely related to the data size. In the case of small data size (e.g., 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 quickly widen, and some algorithms may experience exponential delay due to deteriorating time complexity, while other algorithms can maintain efficient operation by effectively utilizing data characteristics. Therefore, relying solely on a fixed strategy or a single dimension judgment (e.g., only according to data length) has been difficult to meet the needs of high-performance, adaptive sorting.

[0025] S200, feature extraction is performed on the target data to obtain a data length feature, an order degree feature, and a uniformity feature, the data length feature is used to represent data items contained in the target data, the order degree feature is used to represent the smoothness of the change trend between adjacent elements in the target data, and the uniformity feature is used to represent the uniformity of the numerical distribution of the target data; For example, as described above, when facing diverse data situations and dynamically changing data sizes, the sorting strategy must have high adaptability and be able to adjust flexibly according to the inherent characteristics of the current input data. However, the prerequisite for achieving this goal is: how to accurately and structurally depict and quantify the "current data situation" to provide reliable and computable basis for subsequent intelligent decision-making. This has become one of the core technical difficulties in implementing adaptive sorting methods.

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

[0027] 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 known as the data size feature, and the time complexity of different sorting algorithms is different in sensitivity to data size. For example, a sorting algorithm with time complexity of O (n 2 The data length feature not only affects the time complexity of the sorting algorithm, but also affects the order degree feature.

[0028] The order degree feature is used to represent the smoothness of the change trend between adjacent elements in the target data, and 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: Array A=[1, 2, 4, 3, 5, 6]: its local trend sequence is "rise→rise→fall→rise→rise", and the corresponding trend identification sequence can be represented as trend sequence A1=[1, 1, 0, 1, 1], 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] has 4 trend switches.

[0029] Please refer to Figure 2 and Figure 3 , if 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 directly 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 order 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 switches, the fewer the switches, 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 unify the order degree features of target data of different data scales. The order degree feature can capture the local ordered structure in the data more finely, and is especially suitable for identifying partially ordered, segmented ordered or containing a small amount of disturbance real data.

[0030] The uniformity feature is used to represent the uniformity of the target data in the numerical distribution, and 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 to illustrate: 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).

[0031] S300, determining a target ordering strategy of the target data based on a preset decision model, wherein please refer to Figure 4 The determination process of the target ordering strategy includes: S310, constructing a data portrait of the target data according to the data length feature, the order degree feature and the uniformity feature; S320, performing image matching according to the data image from the preset image template library, and in the case of successful matching, obtaining and taking the sorting strategy of the matched image as the target sorting strategy; S330, in the case of unsuccessful matching, generating at least one candidate strategy from the 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.

[0032] For example, the decision model constructs a data image 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 image, so as to adaptively determine the corresponding target sorting strategy. Specifically, the decision model performs image matching between the data image and the image templates in the preset image template library, wherein the image template library includes but is not limited to the following image templates: Small-scale data template: when the data length feature is less than a first length threshold (for example, 50), the recursive or divide-and-conquer overhead of high-level sorting algorithms (such as quicksort, mergesort, etc.) dominates, in this context, simple sorting algorithms (such as insertion sort algorithm) have better performance in actual operation, therefore, the target sorting strategy can be determined as insertion sort; Completely or highly reverse data template: when the order degree feature is less than a first order degree threshold (for example, 0.05) and the data length feature is greater than a second length threshold (for example, 1000), the traditional quicksort is easy to degenerate to O(n 2 ) time complexity due to extremely uneven 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 used to ensure the performance lower limit of O(n log n) time complexity, which is beneficial to ensure the performance of sorting.

[0033] Highly repetitive data template: when the uniformity feature is lower than a first uniformity threshold (for example, 0.3), it indicates that there are a large number of repeated elements in the data, at this time, the traditional two-way quicksort algorithm will be inefficient due to uneven 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.

[0034] Super large external memory data template: when the data length feature exceeds the third length threshold (for example, 1000000) and the runtime detects that the available memory is less than the predetermined proportion (for example, 1 / 4) of the data length feature, because the entire data cannot be loaded into the memory at one time, at this time, the target sorting strategy can be determined as external merge sorting, that is, the target data is divided into multiple sub-blocks that can be processed in memory, and the overall sorting is completed through multi-way merging (such as based on a minimum heap) after sorting respectively, so as to reduce the disk I / O overhead.

[0035] The image templates stored in the image template library are typical data scenario 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 time complexity, space overhead, cache hit rate, and actual running time. However, in actual running process, 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 completely fall within the coverage of the preset image template library. In other words, the image template library can efficiently process common or typical data distribution situations, but cannot exhaust all possible data feature combinations.

[0036] To cope with the situation that image template matching is unsuccessful, a strategy pool containing 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 being called multiple times in historical running, and the corresponding performance value (such as average sorting time, comparison times, memory occupation or I / O operation frequency, etc. Quantifiable indicators) 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.

[0037] When the decision model cannot successfully match the data image of the target data with all 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 the past similar or related data scenarios, 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 improve the performance of sorting.

[0038] The embodiment extracts features of 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 a portrait template library according to the data portrait, and acquires and takes the sorting strategy of the matched portrait as the target sorting strategy in the case of successful matching; and in the case of unsuccessful matching, generates at least one candidate strategy from a preset first strategy pool and sorts the candidate strategies based on 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 data features.

[0039] In some application examples, step S200 of extracting features of target data to obtain a data length feature, a sequence degree feature and a uniformity feature includes: S210, determining the data length feature of the target data and the number of sequence direction changes between adjacent elements; S220, determining a trend factor according to the data length feature and the number of sequence direction changes; S230, determining the sequence degree feature according to the difference between the numerical value 1 and the trend factor.

[0040] 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 taken as 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 represented, wherein “1” represents ascending order and “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.

[0041] In some application examples, step S200 of extracting features of target data to obtain a data length feature, a sequence degree feature and a uniformity feature includes: S240, determining the Shannon entropy value and the maximum possible entropy value of the target data; S250, determining the uniformity feature according to the ratio between the Shannon entropy value and the maximum possible entropy value.

[0042] For example, 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 called 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 value distribution of the target data; otherwise, the data distribution is more concentrated or there are significant repetitions.

[0043] In some other application examples, the step S200 of feature extraction of the target data includes: S260, feature extraction of the target data to obtain the data length feature, the order degree feature, the uniformity feature, and the numerical range feature; 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: 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.

[0044] For example, 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, which is called high-density data template with minimum numerical range. The matching conditions of this portrait template are: 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 each 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 kind of data situation, traditional sorting algorithms based on element comparison (such as quicksort, mergesort, etc.) are limited by their 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 of the data 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.

[0045] 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 is sorted based on the historical score of the candidate strategy to select the candidate strategy with the highest historical score as the target sorting strategy, including: S331, in the case of unsuccessful matching, at least one candidate strategy is generated from the preset first strategy pool; S332, at least one candidate strategy is screened according to the current environment index; S333, the candidate strategies after screening are sorted based on the historical score to select the candidate strategy with the highest historical score as the target sorting strategy.

[0046] 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 needs additional O(n) space for caching temporary arrays, which may cause memory overflow or other performance degradation in the scene where the available memory is limited; similarly, some recursive sorting algorithms may also cause runtime exceptions when the stack space is insufficient. Therefore, in order to improve the practicability 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 screened according to the current environment index, the perception of the running environment is realized, and the candidate strategies that cannot be effectively run or have high risk of failure in the current running environment are excluded, thereby obtaining a candidate strategy subset adapted to the current environment. Then, the candidate strategies after screening are sorted based on their respective historical scores, for example, sorted 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 preposed environment perception can effectively avoid the failure or performance degradation of the strategy execution caused by resource constraints, which is beneficial to significantly improve the robustness, reliability and actual deployment ability of the adaptive sorting method.

[0047] In some application examples, the adaptive sorting method further includes: S340, in the case of unsuccessful matching, the similarity between the data portrait and each portrait template in the portrait template library is determined; S350, in a 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; S360, in a case where the similarity is less than the similarity threshold, randomly determining the target ranking strategy from a preset second strategy pool.

[0048] By way of example, unlike the application examples described above, in a 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.

[0049] 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.

[0050] 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.

[0051] 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.

[0052] Step S300, determining a target ranking strategy of the target data based on a preset decision model, and then comprising: S410, ranking the target data based on the target ranking strategy to obtain a ranking result; S420, obtaining and generating experience data according to a performance indicator of the ranking result; S430, incrementally learning the decision model based on the experience data to update the historical scores of each candidate strategy in the decision model.

[0053] For example, after determining the target ranking strategy applicable to the target data, the target data is subjected to a ranking operation 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, etc.), 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, etc.). 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 the data distribution or the running environment.

[0054] 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 round. 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.

[0055] Please refer to Figure 5 Based on the same technical concept as the above adaptive ranking method embodiment, the embodiment also provides an adaptive ranking device, comprising: The data acquisition module 110 is configured to acquire target data to be sorted. The feature extraction module 120 is 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 is used to represent data items contained in the target data. The sequence degree feature is used to represent a smooth degree of a change trend between adjacent elements in the target data. The uniformity feature is used to represent a uniformity degree of the target data in numerical distribution. The sorting decision module 130 is configured to determine a target sorting strategy of the target data based on a preset decision model. The determination process of the target sorting strategy includes: constructing a data portrait of the target data according to the data length feature, the sequence degree feature and the uniformity feature; performing portrait matching from a preset portrait template library according to the data portrait, and in a case of successful matching, obtaining and taking a sorting strategy of the matched portrait as the target sorting strategy; in a case of unsuccessful matching, generating at least one candidate strategy from a preset first strategy pool, and performing sorting based on historical scores of the candidate strategies to select a candidate strategy with the highest historical score as the target sorting strategy.

[0056] 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, sequence feature and uniformity feature. Portrait matching is performed from a portrait template library according to the data portrait, and in a case of successful matching, a sorting strategy of the matched portrait is obtained and taken as the target sorting strategy. In a case of unsuccessful matching, at least one candidate strategy is generated from a preset first strategy pool, and sorting is performed based on historical scores of the candidate strategies to select 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 be dynamically adapted to the data features. It should be noted that the inventive concept of this adaptive sorting device embodiment is the same as that of the adaptive sorting method embodiment described above. Contents not involved in this adaptive sorting device embodiment can be referred to the adaptive sorting method embodiment described above, and will not be described here again.

[0057] Please refer to Figure 6 The embodiment also provides an electronic device including a processor 210 and a memory 220. The memory 220 stores a computer program. When the processor 210 runs the computer program, the adaptive sorting method described above is implemented. The details of the adaptive sorting method can be referred to the above, and will not be described here again.

[0058] The embodiment extracts features of the target data, constructs a data portrait of the target data according to the extracted data length features, sequence features and uniformity features, performs portrait matching from a 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 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 data features.

[0059] The embodiment also provides a storage medium, and the storage medium stores a computer program. When the computer program is executed, the adaptive sorting method described above is implemented. Details of the adaptive sorting method can be referred to the above, and will not be described here.

[0060] The embodiment extracts features of the target data, constructs a data portrait of the target data according to the extracted data length features, sequence features and uniformity features, performs portrait matching from a 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 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 data features.

[0061] 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 sorting method, characterized in that, include: Get the target data to be sorted; Feature extraction is performed on the target data to obtain data length feature, ordinal feature and uniformity feature. The data length feature is used to characterize the data items contained in the target data. The ordinal feature is used to characterize the smoothness of the change trend between adjacent elements in the target data. The uniformity feature is used to characterize the uniformity of the numerical distribution of the target data. The target ranking strategy for the target data is determined based on a preset decision model, wherein the process of determining the target ranking strategy includes: A data profile of the target data is constructed based on the data length feature, the order feature, and the uniformity feature. Based on the data profile, a profile is matched from a preset profile template library, and if a match is successful, the sorting strategy of the matched profile is obtained and used as the target sorting strategy. If a match fails, at least one candidate strategy is generated from a preset first strategy pool, and the candidate strategies are sorted based on their historical scores, with the candidate strategy with the highest historical score being selected as the target sorting strategy.

2. The adaptive sorting method according to claim 1, characterized in that, The step of extracting features from the target data to obtain data length features, ordinal features, and uniformity features includes: Determine the data length characteristics of the target data and the number of times the order direction changes between adjacent elements; The trend factor is determined based on the data length characteristics and the number of times the order direction changes; The order feature is determined based on the difference between the numerical value and the trend factor.

3. The adaptive sorting method according to claim 1 or 2, characterized in that, The step of extracting features from the target data to obtain data length features, ordinal features, and uniformity features includes: Determine the Shannon entropy value and the maximum possible entropy value of the target data; The uniformity feature is determined based on the ratio between the Shannon entropy value and the maximum possible entropy value.

4. The adaptive sorting method according to claim 1, characterized in that, The step of extracting features from the target data to obtain data length features, ordinal features, and uniformity features includes: Feature extraction is performed on the target data to obtain data length features, ordinal features, uniformity features, and numerical range features; The step of constructing a data profile of the target data based on the data length feature, the ordinal feature, and the uniformity feature includes: A data profile of the target data is constructed based on the data length feature, the order feature, the uniformity feature, and the numerical range feature.

5. The adaptive sorting method according to claim 1, characterized in that, In the event of a failed match, at least one candidate strategy is generated from a preset first strategy pool, and these candidate strategies are sorted based on their historical scores to select the candidate strategy with the highest historical score as the target sorting strategy. If a match fails, at least one candidate strategy is generated from the preset first strategy pool; The candidate strategies are screened based on current environmental indicators; The candidate strategies are sorted based on their historical scores, and the candidate strategy with the highest historical score is selected as the target sorting strategy.

6. The adaptive sorting method according to claim 1, characterized in that, The adaptive sorting method further includes: If a match fails, determine the similarity between the data profile and each profile template in the profile template library; If the similarity is greater than or equal to a preset similarity threshold, at least one candidate strategy is generated from a preset first strategy pool, and the candidate strategies are sorted based on their historical scores, so as to select the candidate strategy with the highest historical score as the target sorting strategy. If the similarity is less than the similarity threshold, a target ranking strategy is randomly determined from a preset second strategy pool.

7. The adaptive sorting method according to claim 1 or 6, characterized in that, The process of determining the target ranking strategy for the target data based on a preset decision model further includes: The target data is sorted based on the target sorting strategy to obtain the sorting result; Acquire and generate empirical data based on the performance index data of the sorting results; The decision model is incrementally learned based on the empirical data to update the historical scores of each candidate strategy in the decision model.

8. An adaptive sorting device, characterized in that, include: The data acquisition module is used to acquire the target data to be sorted. The feature extraction module is used to extract features from the target data to obtain data length features, ordinal features, and uniformity features. The data length features are used to characterize the data items contained in the target data. The ordinal features are used to characterize the smoothness of the change trend between adjacent elements in the target data. The uniformity features are used to characterize the uniformity of the numerical distribution of the target data. A sorting decision module is used to determine a target sorting strategy for the target data based on a preset decision model, wherein the process of determining the target sorting strategy includes: A data profile of the target data is constructed based on the data length feature, the order feature, and the uniformity feature. Based on the data profile, a profile is matched from a preset profile template library, and if a match is successful, the sorting strategy of the matched profile is obtained and used as the target sorting strategy. If a match fails, at least one candidate strategy is generated from a preset first strategy pool, and the candidate strategies are sorted based on their historical scores, with the candidate strategy with the highest historical score being selected as the target sorting strategy.

9. An electronic device comprising a processor and a memory, wherein the memory stores a computer program, characterized in that, When the processor runs the computer program, it is used to implement the adaptive sorting method as described in any one of claims 1 to 7.

10. A storage medium storing a computer program, characterized in that, When the computer program is run, it implements the adaptive sorting method as described in 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

  • Object sorting method and device, equipment and storage medium

    CN117370682A

  • Strategy generation method and device, computer equipment and storage medium

    CN117931844A