A method and system for scheduling sorting algorithms in a sparse matrix solving process
By extracting sparse matrix features and using a machine learning model to select the optimal sorting algorithm, the problem of low selection efficiency of sparse matrix sorting algorithms in the existing technology is solved, the intelligentization and automation of sparse matrix solving is realized, and the calculation efficiency is significantly improved.
Patent Information
- Application Number
- CN202410834893.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-06-26
AI Technical Summary
In scientific computing and engineering computing, the selection of existing sparse matrix sorting algorithms relies on static analysis and preset parameters, and cannot adaptively select the optimal sorting algorithm based on different sparse matrix structures, resulting in a waste of time when solving large-scale sparse matrices.
By extracting the features of the sparse matrix and inputting them into the pre-trained machine learning model, the most suitable sorting algorithm is automatically selected, the machine learning model is used to establish the mapping relationship between the matrix features and the sorting algorithm, and the optimal sorting algorithm is executed to improve the sparse matrix Solving efficiency.
An intelligent selection sorting algorithm based on the sparse matrix structure is implemented, which significantly reduces human intervention and subjectivity, and improves sparse matrix solving efficiency and computing performance. Experimental results show that the solution time is reduced by 56.12% compared with traditional methods.
Smart Images

Figure CN118378074B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of scientific computing and engineering computing, and in particular to a method and system for scheduling a sorting algorithm in a sparse matrix solving process. Background Art
[0002] In the fields of scientific computing and engineering computing, sparse matrices are widely used in solving various practical problems. The simple definition of a sparse matrix is that when the proportion of the number of non-zero elements in the entire matrix is less than a certain value, when the value is 5%, the matrix can be considered sparse. This type of matrix is more common in many fields such as finite element analysis, fluid mechanics, image processing, quantum physics, and nanomaterial computing. In the applications of these fields, it is crucial to effectively store and quickly solve sparse matrices, and the efficient solution of sparse matrix problem solving depends more on appropriate matrix sorting algorithms. Sparse matrix sorting is generally speaking to exchange the positions of non-zero elements in the matrix to improve data locality. The main purpose is to reduce the filling caused by factorization. The choice of different sorting algorithms has a direct impact on the storage, computational efficiency, and memory usage of sparse matrices. However, in practical applications, the selection of a suitable sparse matrix sorting algorithm still faces many challenges. At present, there are many sparse matrix sorting algorithms. Common sparse matrix sorting algorithm selection methods are based on static analysis and preset parameters. However, due to the characteristics of sparse matrices, different matrix structures are suitable for different sorting algorithms. Therefore, when faced with solving large-scale sparse matrices, if the preset sorting algorithm parameters are not the optimal sorting algorithm, it will result in a huge waste of time. Therefore, how to adaptively select the optimal sorting algorithm according to the structure of different sparse matrices is a problem worth studying. Summary of the invention
[0003] Technical problem to be solved by the present invention: In view of the above-mentioned problems in the prior art, a method and system for scheduling a sorting algorithm in the process of solving a sparse matrix is provided. The present invention aims to automatically and intelligently select the most suitable sparse matrix sorting algorithm by analyzing the characteristics of the sparse matrix and combining a machine learning model, thereby improving the efficiency of solving the sparse matrix and enhancing the efficiency and performance in scientific computing and engineering computing.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0005] A method for scheduling a sorting algorithm during a sparse matrix solution process comprises the following steps:
[0006] S101, extracting matrix features of an input sparse matrix when the operation module performs sparse matrix solving;
[0007] S102, inputting the extracted matrix features into a pre-trained machine learning model to obtain an optimal sorting algorithm in a preset sorting algorithm set, wherein the machine learning model is pre-trained to establish a mapping relationship between the matrix features of the input sparse matrix and the optimal sorting algorithm in the sorting algorithm set; the optimal sorting algorithm refers to a sorting algorithm with the shortest sorting time or a sorting algorithm with the shortest sorting time and the least memory usage;
[0008] S103, executing the optimal sorting algorithm through the operation module to sort the input sparse matrix.
[0009] Optionally, when extracting matrix features of the input sparse matrix in step S101, the extracted matrix features include the sparse matrix dimension after standardization, the number of non-zero elements in the sparse matrix, the proportion of non-zero elements in the sparse matrix, the maximum number of non-zero elements in a sparse matrix row, the minimum number of non-zero elements in a sparse matrix row, the average number of non-zero elements in each row of the sparse matrix, the standard deviation of the number of non-zero elements in each row of the sparse matrix, the maximum value of the sparse matrix node degree, the minimum value of the sparse matrix node degree, the average value of the sparse matrix node degree, the bandwidth of the sparse matrix, and part or all of the sparse matrix profile.
[0010] Optionally, before step S102, the step of training the machine learning model is also included:
[0011] S201, obtaining sparse matrix samples;
[0012] S202, extracting matrix features of sparse matrix samples, and obtaining preset sorting indicators of each sparse matrix sample under each sorting algorithm in a preset sorting algorithm set, and finding the corresponding optimal sorting algorithm according to the preset sorting indicator to construct an optimal sorting algorithm label; constructing a data set with the matrix features of each sparse matrix sample and its optimal sorting algorithm label, and dividing the data set into a training set and a test set;
[0013] S203, constructing multiple machine learning models, sending the training sets to various machine learning models for training, and optimizing network parameters of various machine learning models during training;
[0014] S204, selecting accuracy as an evaluation indicator of the machine learning model, then sending the test set to various machine learning models for testing to obtain the accuracy of various machine learning models, and selecting the machine learning model with the highest accuracy among the machine learning models as the final trained machine learning model.
[0015] Optionally, when constructing multiple machine learning models in step S203, multiple machine learning models are constructed, including some or all of a random forest algorithm model, a decision tree algorithm model, a logistic regression algorithm model, a Bayesian algorithm model, a support vector machine, a multilayer perceptron, and a K nearest neighbor algorithm model.
[0016] Optionally, in step S203, sending the training set to different machine learning models for training and optimizing the network parameters of the machine learning models during training includes using a grid search method to optimize the network parameters of various machine learning models, including: for each machine learning model, determining all network parameters of the machine learning model and their possible values, and then generating different parameter grid combinations based on the possible values of all network parameters by enumerating them, and then traversing the parameter grid combinations in sequence, and using a cross-validation method to train the machine learning model to optimize the network parameters of the machine learning model.
[0017] Optionally, when extracting the matrix features of the input sparse matrix when the operation module performs sparse matrix solution in step S101, it also includes identifying the input sparse matrix, and only when the input sparse matrix is a symmetric sparse matrix or a square matrix in an asymmetric matrix, the matrix features of the input sparse matrix are extracted and step S102 is jumped; otherwise, it ends and exits.
[0018] In addition, the present invention also provides a system for scheduling a sorting algorithm during a sparse matrix solution process, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the method for scheduling a sorting algorithm during a sparse matrix solution process.
[0019] In addition, the present invention also provides a computer-readable storage medium, in which a computer program is stored. The computer program is programmed or configured to execute the method of scheduling a sorting algorithm in the sparse matrix solution process through a processor.
[0020] In addition, the present invention also provides a computer program product, including a computer program, which is programmed or configured to execute the method of scheduling a sorting algorithm in the sparse matrix solution process through a processor.
[0021] Compared with the prior art, the present invention mainly has the following advantages: the present invention includes extracting the matrix features of the input sparse matrix when the operation module performs sparse matrix solution, inputting the matrix features into a pre-trained machine learning model to obtain the optimal sorting algorithm in a preset sorting algorithm set, and executing the optimal sorting algorithm to sort the input sparse matrix through the operation module. In the sorting algorithm selection stage of the sparse matrix solution process, the most suitable sorting algorithm for the matrix can be predicted according to the statistical features of the input matrix, thereby reducing human intervention and subjectivity in the selection process. At the same time, the machine learning model can accurately predict the optimal sorting algorithm of different sparse matrix structures through training samples, thereby greatly improving the efficiency of sparse matrix solution. In addition, the machine learning method can continuously learn and improve. With the accumulation of more data and the optimization of the model, its sorting selection ability and effect will continue to improve, and it has certain scalability. The results of relevant experiments show that compared with the traditional method of using a fixed selection of the more commonly used AMD sorting algorithm, the machine learning model prediction method used in the present invention can significantly reduce the time required to solve the sparse matrix, and the prediction time of the model is almost negligible, so it can effectively improve the efficiency of sparse matrix solution, and improve the efficiency and performance in scientific and engineering calculations. The method for scheduling the sorting algorithm in the sparse matrix solution process of the present invention is to use machine learning to select the sparse matrix sorting algorithm, which can accurately predict the optimal sorting algorithm for different sparse matrix structures, and has the advantages of automation and intelligence. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 The figure is a basic flow chart of a method according to a first embodiment of the present invention.
[0023] Figure 2 Schematic diagram of the model training principle of the machine learning model in Example 1 of the present invention.
[0024] Figure 3 This is a flow chart of optimizing model parameters using the grid search method in Embodiment 1 of the present invention.
[0025] Figure 4 These are the accuracy test results of various machine learning models in Example 1 of the present invention. DETAILED DESCRIPTION
[0026] Embodiment 1:
[0027] like Figure 1 As shown, the method for scheduling the sorting algorithm during the sparse matrix solution process of this embodiment includes the following steps:
[0028] S101, extracting matrix features of an input sparse matrix when the operation module performs sparse matrix solving;
[0029] S102, inputting the extracted matrix features into a pre-trained machine learning model to obtain an optimal sorting algorithm in a preset sorting algorithm set, wherein the machine learning model is pre-trained to establish a mapping relationship between the matrix features of the input sparse matrix and the optimal sorting algorithm in the sorting algorithm set;
[0030] S103, executing the optimal sorting algorithm through the operation module to sort the input sparse matrix.
[0031] In step S101 of this embodiment, when extracting the matrix features of the input sparse matrix, the extracted matrix features include the sparse matrix dimension after standardization, the number of non-zero elements in the sparse matrix, the proportion of non-zero elements in the sparse matrix, the maximum number of non-zero elements in the sparse matrix row, the minimum number of non-zero elements in the sparse matrix row, the average number of non-zero elements in each row of the sparse matrix, the standard deviation of the number of non-zero elements in each row of the sparse matrix, the maximum value of the sparse matrix node degree, the minimum value of the sparse matrix node degree, the average value of the sparse matrix node degree, the bandwidth of the sparse matrix and the profile of the sparse matrix. For a dimension of The bandwidth of a sparse matrix refers to the maximum distance from the non-zero element position of each row of the matrix to the main diagonal, which is expressed as follows:
[0032] ,
[0033] In the above formula, represents the bandwidth of the sparse matrix, To obtain the maximum value, Indicates OK The elements of the columns are not zero. The outline of the sparse matrix refers to the sum of the distances from the leftmost non-zero element position of each row to the diagonal, which is expressed by the following formula:
[0034] ,
[0035] In the above formula, Represents the outline of a sparse matrix, N is the number of rows, Specifically, in step S101 of this embodiment, the matrix features of the input sparse matrix are extracted by using a Python script, but there is no doubt that the matrix features of the input sparse matrix extracted in step S101 of this embodiment do not depend on a specific programming language.
[0036] It should be noted that the preset sorting algorithm set in step S102 can select the required sorting algorithm as needed. For example, as an optional implementation, the preset sorting algorithm set in step S102 of this embodiment includes AMD, SCOTCH, AMF, QAMD, ND and RCM sorting algorithms, wherein AMD, SCOTCH, AMF, QAMD sorting algorithms are sorting algorithms provided by the Mumps solver, AMD, AMF, QAMD are different variants of the same algorithm, and ND and RCM sorting algorithms are additional sorting algorithms.
[0037] The optimal sorting algorithm can select one or more sorting indicators as needed, for example, common sorting indicators include sorting time, memory usage, computing resource usage, I / O usage, etc. For example, as an optional implementation, the sorting time is used as the sorting indicator in this embodiment, and the optimal sorting algorithm in step S102 refers to the sorting algorithm with the shortest sorting time.
[0038] The machine learning model can adopt the required machine learning model as needed. As an optional implementation, this embodiment adopts a method of training and selecting the best machine learning model from multiple machine learning models, such as Figure 2 As shown, before step S102, the step of training the machine learning model is also included:
[0039] S201, obtaining a sparse matrix sample; the sparse matrix sample can be generated as needed or obtained from a known data source. For example, as an optional implementation, in this embodiment, the first 2000 matrices are downloaded from the Florida matrix data set and the matrices after matrix screening are used as sparse matrix samples;
[0040] S202, extracting matrix features of sparse matrix samples, and obtaining preset sorting indicators of each sparse matrix sample under each sorting algorithm in a preset sorting algorithm set, and finding the corresponding optimal sorting algorithm according to the preset sorting indicator to construct an optimal sorting algorithm label; constructing a data set with the matrix features of each sparse matrix sample and its optimal sorting algorithm label, and dividing the data set into a training set and a test set; after extracting the matrix features of the sparse matrix samples in this embodiment, it is also necessary to obtain the optimal sorting algorithm label of the matrix. According to the characteristics of different sorting algorithms, this embodiment mainly divides the matrix sorting algorithms into the following four categories: 1. Reduced bandwidth sorting algorithm (RCM) C ), 2. Reduced filling sorting algorithm (AMD C ), 3. Sorting algorithm based on graph partitioning (ND C ), 4. Reduced filling and sorting algorithm based on graph partition coupling (SCOTCH) C ). AMD, AMF, QAMF are AMD CDifferent variants of the class algorithm, in order to simplify the example description, this embodiment finally selects the most widely used sorting algorithm in each class as RCM C , AMD C ND C ,SCOTCH C The representatives of the four types of sorting algorithms are RCM, AMD, ND, and SCOTCH. After selecting the sorting algorithm, Mumps is used as the solver. On the same server platform, under different sparse matrix sorting algorithms, the matrix sorting time with the shortest and the least memory usage is counted and recorded, and then the sparse matrix sorting algorithm with the best solution time for each matrix is extracted using a Python script, and finally a total of 936 sparse matrix samples are obtained; the entire data set is divided into a training set and a test set according to a ratio of 8:2, and the number of samples in the training set and the test set are 748 and 188 respectively. In order to avoid the influence of scale differences between the same features on the model, speed up the convergence of the model, and improve the accuracy of the model, this embodiment also includes the use of the StandardScaler data processing function built into the sklearn library during the training of the machine learning model to standardize the statistical features of the matrix. The StandardScaler data processing function uses the formula (X-mean) / std to make the eigenvalue near 0 and the variance 1, where X is the input data, mean is the average value of the data, and std is the standard deviation of the data;
[0041] S203, constructing multiple machine learning models, sending the training set to various machine learning models for training and optimizing the network parameters of various machine learning models during training; wherein the multiple machine learning models can adopt the required machine learning models as needed. As an optional implementation method, the multiple machine learning models constructed in this embodiment include random forest algorithm model, decision tree algorithm model, logistic regression algorithm model, Bayesian algorithm model, support vector machine, multilayer perceptron and K nearest neighbor algorithm model;
[0042] S204, select accuracy as the evaluation indicator of the machine learning model, then send the test set to various machine learning models for testing to obtain the accuracy of various machine learning models, and select the machine learning model with the highest accuracy among the machine learning models as the final trained machine learning model (i.e. Figure 2 In this embodiment, the trained model is evaluated using a 20% test set, and the accuracy of the random forest algorithm model, decision tree algorithm model, logistic regression algorithm model, Bayesian algorithm model, support vector machine, multilayer perceptron and K nearest neighbor algorithm model is as follows: Figure 4 See Figure 4It can be seen that the accuracy of the random forest algorithm model in this embodiment is 86.7%, which is the best effect. Therefore, the random forest algorithm model is selected as the final trained machine learning model.
[0043] In step S203 of this embodiment, when sending the training set to different machine learning models for training and optimizing the network parameters of the machine learning models during training, a grid search method is used to optimize the network parameters of various machine learning models, including: for each machine learning model, all network parameters of the machine learning model and their possible values are determined, and then the possible values of all network parameters are enumerated to generate different parameter grid combinations, and then the parameter grid combinations are traversed in sequence, and the machine learning model is trained and evaluated by cross-validation, so as to finally obtain the best network parameters (best parameters), thereby obtaining the best machine learning model (best model). Figure 3 This is a flowchart for optimizing model parameters using the grid search method. During the model training process, in order to obtain better model prediction results, the grid search method is used to tune the model parameters. For a certain algorithm model, firstly, the possible values of some hyperparameters that the algorithm needs to optimize are given. These values may be combined to form a grid. For example, suppose there are two hyperparameters a and b, and their values may be [a1, a2] and [b1, b2] respectively. Then the combination of the parameter grid is (a1, b1), (a1, b2), (a2, b1), (a2, b2). Then, these parameter combinations are traversed in turn, and the model is trained using the currently traversed parameters. K-fold cross validation is used during training, and accuracy is used as the evaluation indicator of the model. Finally, the hyperparameter with the highest accuracy is selected as the final hyperparameter combination configuration. The simple idea of cross-validation is to divide the data set into K subsets of similar size, with the elements in the subsets mutually exclusive. Each time, the union of k-1 subsets is used as the training set, and the remaining subsets are used as the test set. Thus, k sets of training sets and test sets can be obtained for k training and testing. Finally, the model with the best evaluation effect and the optimal hyperparameter combination of the current model are used for prediction.
[0044] In step S101 of this embodiment, when the matrix features of the input sparse matrix are extracted when the operation module performs sparse matrix solution, it also includes identifying the input sparse matrix, and only when the input sparse matrix is a symmetric sparse matrix or a square matrix in an asymmetric matrix can the matrix features of the input sparse matrix be extracted and step S102 be jumped; otherwise, it ends and exits.
[0045] In order to verify the performance of the method for scheduling the sorting algorithm in the sparse matrix solution process of this embodiment, this embodiment conducts experiments on some sparse matrix samples combined with different sorting algorithms, using RCM C , AMD C NDC ,SCOTCH C RCM, AMD, ND, and SCOTCH sorting algorithms under four types of sorting algorithms. Finally, some matrices with more than 100,000 non-zero elements were selected and the time to solve them using the Mumps solver under different sorting algorithms is shown in Table 1. The prediction results, prediction time, and true labels of the matrices in Table 1 using the trained machine learning model are shown in Table 2, where nnz is the number of non-zero elements in the sparse matrix, dimension is the dimension of the sparse matrix, and matrix name is the name of the sparse matrix.
[0046] Table 1: Matrix solution time under different sorting algorithms
[0047]
[0048] Table 2: Model prediction results and prediction time
[0049]
[0050] As shown in Table 1 and Table 2, there are significant differences in the time taken to solve different sparse matrices using the Mumps solver. The method of this embodiment can accurately predict and obtain the optimal sorting algorithm.
[0051] In summary, sparse matrices are widely used in many fields, and the selection of their sorting algorithms has an important impact on the utilization of computing resources and the speed of problem solving. In view of the fact that the selection of traditional sorting algorithms depends on human experience selection, there are problems of strong subjectivity and low efficiency. The method for scheduling the sorting algorithm in the sparse matrix solution process of this embodiment uses a machine learning method to construct a sorting algorithm prediction model. In the sorting algorithm selection stage of the sparse matrix solution process, it can predict the most suitable sorting algorithm for the matrix according to the input matrix statistical feature value. Through systematic steps, the intelligent and automatic selection of sorting algorithms is realized, and the subjectivity in human intervention and selection process is reduced. At the same time, the machine learning model can accurately predict which sorting algorithm performs best under a specific matrix structure through training samples, thereby greatly improving the efficiency of sparse matrix solution. In addition, the machine learning method can continuously learn and improve. With the accumulation of more data and the optimization of the model, its sorting selection ability and effect will continue to improve, and it has certain scalability. The experimental results show that for the matrices in the test set, compared with the traditional method that has been using the AMD sorting algorithm, the machine learning model prediction method can reduce the solution time by 56.12%, and the prediction time of the model is almost negligible, so it can effectively improve the efficiency of sparse matrix solution, and improve the efficiency and performance in scientific computing and engineering computing. The method for scheduling the sorting algorithm in the sparse matrix solution process of this embodiment is to use machine learning to select the sorting algorithm of the sparse matrix, which can accurately predict the optimal sorting algorithm for different sparse matrix structures, and has the advantages of automation and intelligence.
[0052] In addition, the present embodiment also provides a system for scheduling a sorting algorithm during a sparse matrix solution, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute a method for scheduling a sorting algorithm during the sparse matrix solution. In addition, the present embodiment also provides a computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, wherein the computer program is programmed or configured to execute the method for scheduling a sorting algorithm during the sparse matrix solution through a processor. In addition, the present embodiment also provides a computer program product, comprising a computer program, wherein the computer program is programmed or configured to execute the method for scheduling a sorting algorithm during the sparse matrix solution through a processor.
[0053] Embodiment 2:
[0054] This embodiment is basically the same as the first embodiment, and the main difference is that the sorting time and memory usage are used as sorting indicators in this embodiment, and the optimal sorting algorithm in step S102 refers to the sorting algorithm with the shortest sorting time and the least memory usage. Since multiple sorting indicators are involved, the priorities of different sorting indicators can be set, and then the selection of the sorting algorithm with the shortest sorting time and the least memory usage can be realized according to the priorities. It can also realize the selection of the optimal sorting algorithm for the sorting algorithm with the shortest sorting time and the least memory usage. Similarly, other types of sorting indicators can be further replaced or expanded, or other dimension elimination methods other than priority can be used to realize the fusion of multiple sorting indicators, which can also achieve the technical effect of the first embodiment, and will not be repeated here.
[0055] In addition, the present embodiment also provides a system for scheduling a sorting algorithm during a sparse matrix solution, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute a method for scheduling a sorting algorithm during the sparse matrix solution. In addition, the present embodiment also provides a computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, wherein the computer program is programmed or configured to execute the method for scheduling a sorting algorithm during the sparse matrix solution through a processor. In addition, the present embodiment also provides a computer program product, comprising a computer program, wherein the computer program is programmed or configured to execute the method for scheduling a sorting algorithm during the sparse matrix solution through a processor.
[0056] Those skilled in the art should understand that the embodiments of the present application may provide methods, systems or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the functions in the process. Figure 1 A process or multiple processes and / or boxes Figure 1These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0057] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. A method for scheduling a sorting algorithm in a sparse matrix solving process, characterized in that: The steps include: S101, extracting matrix features of an input sparse matrix when the operation module performs sparse matrix solving, the matrix features are used in the field of image processing, and the matrix features include all of the sparse matrix dimension after standardization, the number of non-zero elements in the sparse matrix, the proportion of non-zero elements in the sparse matrix, the maximum number of non-zero elements in a sparse matrix row, the minimum number of non-zero elements in a sparse matrix row, the average number of non-zero elements in each row of the sparse matrix, the standard deviation of the number of non-zero elements in each row of the sparse matrix, the maximum value of the sparse matrix node degree, the minimum value of the sparse matrix node degree, the average value of the sparse matrix node degree, the bandwidth of the sparse matrix, and the profile of the sparse matrix; S102, inputting the extracted matrix features into a pre-trained machine learning model to obtain an optimal sorting algorithm in a preset sorting algorithm set, wherein the machine learning model is pre-trained to establish a mapping relationship between the matrix features of the input sparse matrix and the optimal sorting algorithm in the sorting algorithm set; the optimal sorting algorithm refers to a sorting algorithm with the shortest sorting time and the least memory usage; S103, executing the optimal sorting algorithm through the operation module to sort the input sparse matrix; In step S101, when the matrix features of the input sparse matrix are extracted when the operation module performs sparse matrix solving, the input sparse matrix is also identified, and only when the input sparse matrix is a symmetric sparse matrix or a square matrix in an asymmetric matrix, the matrix features of the input sparse matrix are extracted and the process jumps to step S102; otherwise, the process ends and exits; Before step S102, the following steps are also included to train the machine learning model: S201, obtaining sparse matrix samples; S202, extracting matrix features of sparse matrix samples, and obtaining preset sorting indicators of each sparse matrix sample under each sorting algorithm in a preset sorting algorithm set, and finding the corresponding optimal sorting algorithm according to the preset sorting indicator to construct an optimal sorting algorithm label; constructing a data set with the matrix features of each sparse matrix sample and its optimal sorting algorithm label, and dividing the data set into a training set and a test set; S203, constructing multiple machine learning models, sending the training sets to different machine learning models for training, and optimizing network parameters of the machine learning models during training; S204, selecting accuracy as an evaluation indicator of the machine learning model, then sending the test set to various machine learning models for testing to obtain the accuracy of the various machine learning models, and selecting the machine learning model with the highest accuracy among the machine learning models as the final machine learning model; In step S203, the training set is sent to different machine learning models for training and the network parameters of the machine learning models are optimized during training, including using a grid search method to optimize the network parameters of various machine learning models, including: for each machine learning model, all network parameters of the machine learning model and their possible values are determined, and then different parameter grid combinations are generated according to the possible values of all network parameters. Then, the parameter grid combinations are traversed in sequence, and the machine learning model is trained in a cross-validation manner to optimize the network parameters of the machine learning model.
2. The method for scheduling a sorting algorithm in a sparse matrix solving process according to claim 1, characterized in that: When constructing multiple machine learning models in step S203, multiple machine learning models are constructed, including some or all of the random forest algorithm model, decision tree algorithm model, logistic regression algorithm model, Bayesian algorithm model, support vector machine, multilayer perceptron and K nearest neighbor algorithm model.
3. A system for scheduling a sorting algorithm in a sparse matrix solving process, comprising a microprocessor and a memory connected to each other, characterized in that: The microprocessor is programmed or configured to execute the method for scheduling a sorting algorithm in the sparse matrix solution process of claim 1 or 2.
4. A computer-readable storage medium having a computer program stored therein, characterized in that: The computer program is programmed or configured to execute the method for scheduling a sorting algorithm in the sparse matrix solution process of claim 1 or 2 through a processor.
5. A computer program product, comprising a computer program, characterized in that The computer program is programmed or configured to execute the method for scheduling a sorting algorithm in the sparse matrix solution process of claim 1 or 2 through a processor.
Citation Information
Patent Citations
Solver recommendation method and system, chip, equipment, medium and program product
CN114764588A
Sparse matrix solving method, system, equipment and medium
CN117786299A
