Software package compiling method and electronic device

By constructing a dependency graph and using the fish swarm algorithm to optimize the compilation order of software packages, the problems of high compilation failure rate and low efficiency in existing technologies are solved, and efficient and stable software package compilation is achieved.

CN120929088BActive Publication Date: 2025-12-16INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511462970.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-14
Publication Date
2025-12-16
Estimated Expiration
2045-10-14

AI Technical Summary

Technical Problem

Existing software package compilation methods do not consider dependencies, resulting in high compilation failure rates and low efficiency. Furthermore, lower-level packages may be compiled after higher-level packages, leading to dependency issues.

Method used

Construct a dependency graph, use the fish swarm algorithm to determine the compilation order of software packages, and move through the dependency graph using the fish swarm algorithm to select the target path for compilation.

Benefits of technology

It improves the success rate and efficiency of package compilation, avoids multiple repeated compilations, optimizes the compilation order, and reduces the risk of resource contention and getting trapped in local optima.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120929088B_ABST
    Figure CN120929088B_ABST
Patent Text Reader

Abstract

The application provides a software package compiling method and an electronic device, which can be applied to the field of software testing. The software package compiling method comprises the following steps: constructing a dependency graph based on a software package set to be compiled, the dependency graph comprising nodes and dependency relationships between the nodes; selecting multiple nodes from the dependency graph as initial positions of multiple fishes in a fish swarm algorithm, wherein the number of the multiple fishes is a preset value; based on the fish swarm algorithm, making the multiple fishes move to a next node in the dependency graph according to the dependency relationships between the nodes from the respective initial positions, obtaining a moving path of each fish, and the moving path representing a sorting result of the nodes in the dependency graph; selecting a target path from the moving paths of the multiple fishes according to the dependency relationships between the nodes in the moving path; and compiling the software packages in the software package set according to the target path.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of software testing, and more particularly, to a software package compilation method and an electronic device. BACKGROUND

[0002] There can be a dependency relationship between multiple software packages, for example, another software package can be successfully compiled only after a software package is completed. However, the related software compilation method usually does not consider the dependency relationship and the compilation order between the software packages, but starts a unified compilation process for all software packages, and the software packages are compiled in parallel or out of order during the compilation process, resulting in many software packages that fail to compile, and thus multiple repeated compilations of all software packages are required until the compilation is successful, resulting in a long compilation time and low compilation efficiency. SUMMARY

[0003] In view of the above problems, the present application provides a software package compilation method and an electronic device.

[0004] According to a first aspect of the present application, a software package compilation method is provided, comprising: constructing a dependency relationship graph based on a set of software packages to be compiled, the dependency relationship graph comprising nodes and dependency relationships between the nodes, wherein a node represents a software package, and a dependency relationship between nodes represents whether the compilation or installation of a software package corresponding to one node depends on the compilation or installation of a software package corresponding to another node; selecting multiple nodes from the dependency relationship graph as initial positions of multiple fish in a fish swarm algorithm, wherein the number of the multiple fish is a preset value; based on the fish swarm algorithm, causing the multiple fish to move from their respective initial positions to the next node in the dependency relationship graph according to the dependency relationships between the nodes, obtaining a moving path of each fish, and the moving path represents a sorting result of the nodes in the dependency relationship graph; selecting a target path from the moving paths of the multiple fish according to the dependency relationships between the nodes in the moving path; and compiling the software packages in the set of software packages according to the target path.

[0005] A second aspect of the present application provides an electronic device, comprising: one or more processors; a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.

[0006] A third aspect of the present application further provides a computer-readable storage medium having a computer program or instructions stored thereon, wherein the computer program or instructions are executed by a processor to implement the steps of the above method.

[0007] A fourth aspect of the present application further provides a computer program product comprising a computer program or instructions, wherein the computer program or instructions are executed by a processor to implement the steps of the above method. BRIEF DESCRIPTION OF DRAWINGS

[0008] The above and other objects, features and advantages of the present application will become more apparent from the following description when taken in conjunction with the accompanying drawings, in which:

[0009] Figure 1 An application scenario diagram of a software package compiling method and an electronic device according to an embodiment of the present application is shown;

[0010] Figure 2 A flowchart of a software package compiling method according to an embodiment of the present application is shown;

[0011] Figure 3 A schematic diagram of a moving path of a fish school according to an embodiment of the present application is shown;

[0012] Figure 4 A schematic diagram of a target path according to an embodiment of the present application is shown;

[0013] Figure 5 A flowchart of a software package compiling method according to another embodiment of the present application is shown;

[0014] Figure 6 A schematic diagram of a target radius and a moving path corresponding to a single fish according to an embodiment of the present application is shown;

[0015] Figure 7 A structural block diagram of a software package compiling apparatus according to an embodiment of the present application is shown;

[0016] Figure 8 A block diagram of an electronic device suitable for implementing a software package compiling method according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0017] Hereinafter, embodiments of the present application will be described with reference to the accompanying drawings. It is to be understood, however, that the description is merely exemplary of the present application, and is not intended to limit the scope of the present application. In the following detailed description, numerous specific details are set forth in order to provide a thorough understanding of the present application. However, it will be apparent to one skilled in the art that one or more embodiments of the present application can be practiced without these specific details. In other instances, well-known structures and functions have not been described in detail in order to avoid obscuring aspects of the present application.

[0018] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used herein, the term "includes" and / or "including", as well as

[0019] All terms used herein, including technical and scientific terms, have the meanings as commonly understood by one of ordinary skill in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of the specification, and should not be interpreted in an idealized or overly formal way.

[0020] In the case of using expressions similar to "at least one of A, B, and C, etc.", it should generally be interpreted that the expression includes any of one, two, or all of the items enumerated after the term "at least one of", unless otherwise specifically defined (e.g., "a system having at least one of A, B, and C" should include, but not be limited to, a system having A alone, a system having B alone, a system having C alone, a system having both A and B, a system having both A and C, a system having both B and C, and / or a system having A, B, and C, etc.).

[0021] The related software package compilation method is generally to perform package-by-package serial compilation (e.g., to compile the software packages in a fixed order determined based on artificial experience) or limited parallel compilation (to compile part of the software packages at the same time) on all software packages, resulting in the failure of the compilation of part of the software packages due to the failure to meet the dependency relationship. In the case of the failure of the software package compilation, it is necessary to perform the compilation again on all the software packages that have failed to compile, repeatedly compile multiple times until the dependency relationship of all the software packages is met, and then solve other types of errors one by one. Thus, it will result in the need to compile some software packages multiple times, consume a long time, and have a low compilation efficiency, and the lower software package that should be compiled first can be compiled after the upper software package that is in a later compilation order, resulting in the fact that although the lower software package can be successfully compiled, the dependency problem still occurs when the lower software package is installed. In addition, the dependency relationship between the software packages is generally determined manually based on experience, and it is difficult to accurately determine the dependency relationship, increasing the difficulty of the software package compilation and installation.

[0022] Therefore, embodiments of the present application provide a software package compilation method, including: based on a set of software packages to be compiled, constructing a dependency relationship graph, the dependency relationship graph including nodes and dependency relationships between the nodes, wherein the nodes represent the software packages, and the dependency relationships between the nodes represent whether the compilation or installation of the software package corresponding to one node depends on the compilation or installation of the software package corresponding to another node; selecting multiple nodes from the dependency relationship graph as initial positions of multiple fishes in a fish swarm algorithm respectively, wherein the number of the multiple fishes is a preset value; based on the fish swarm algorithm, causing the multiple fishes to move to the next node in the dependency relationship graph from the initial positions of the multiple fishes respectively, obtaining a moving path of each fish, and the moving path represents a sorting result of the nodes in the dependency relationship graph; selecting a target path from the moving paths of the multiple fishes according to the dependency relationships between the nodes in the moving paths; and compiling the software packages in the set of software packages according to the target path.

[0023] Figure 1An application scenario of the software package compiling method and the electronic device according to the embodiments of the present application is shown.

[0024] As shown in Figure 1 The application scenario 100 according to the embodiments can include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104 and a server 105. The network 104 is a medium for providing communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103 and the server 105. The network 104 can include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0025] A user can use the first terminal device 101, the second terminal device 102, the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0026] The first terminal device 101, the second terminal device 102, the third terminal device 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers and desktop computers, etc.

[0027] The server 105 can be a server providing various services, such as a background management server supporting websites browsed by users using the first terminal device 101, the second terminal device 102, the third terminal device 103 (only as an example). The background management server can analyze and process received user requests and other data, and feed back the processing results (such as web pages, information or data generated according to user requests, etc.) to the terminal device.

[0028] For example, the user can initiate a software package compilation instruction through the first terminal device 101, the second terminal device 102, and the third terminal device 103. In response to the instruction, the server 105 can construct a dependency graph based on a set of software packages to be compiled, the dependency graph including nodes and dependency relationships between the nodes, where a node represents a software package, and a dependency relationship between the nodes represents whether the compilation or installation of a software package corresponding to one node depends on the compilation or installation of a software package corresponding to another node. A plurality of nodes are selected from the dependency graph as initial positions of a plurality of fish in a fish swarm algorithm, where the number of the plurality of fish is a preset value. Based on the fish swarm algorithm, the plurality of fish respectively start moving from the respective initial positions to a next node in the dependency graph according to the dependency relationships between the nodes, and a movement path of each fish is obtained, where the movement path represents a sorting result of the nodes in the dependency graph. A target path is selected from the movement paths of the plurality of fish according to the dependency relationships between the nodes in the movement path. The software packages in the set of software packages are compiled according to the target path.

[0029] It should be noted that the software package compilation method provided in the embodiments of the present application can generally be executed by the server 105. Correspondingly, the software package compilation apparatus provided in the embodiments of the present application can generally be arranged in the server 105. The software package compilation method provided in the embodiments of the present application can also be executed by a server or a server cluster different from the server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105. Correspondingly, the software package compilation apparatus provided in the embodiments of the present application can also be arranged in a server or a server cluster different from the server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105.

[0030] It should be understood that Figure 1 the number of terminal devices, networks, and servers in the above-mentioned scenarios is only illustrative. Any number of terminal devices, networks, and servers can be provided according to implementation needs.

[0031] The software package compilation method provided in the embodiments of the present application will be described in detail below based on the scenarios described above. Figure 1 The software package compilation method provided in the embodiments of the present application will be described in detail below based on the scenarios described above. Figures 2-6 The software package compilation method provided in the embodiments of the present application will be described in detail below based on the scenarios described above.

[0032] Figure 2 A flowchart of a software package compilation method according to an embodiment of the present application is shown.

[0033] As shown in Figure 2 , the software package compilation method of this embodiment includes operations S210-S250.

[0034] At operation S210, a dependency graph is constructed based on the set of software packages to be compiled, the dependency graph including nodes and dependencies between the nodes, where a node represents a software package and a dependency between nodes represents whether the compilation or installation of the software package corresponding to one node depends on the compilation or installation of the software package corresponding to another node.

[0035] Optionally, there can be dependencies between multiple software packages in the set of software packages, and the dependencies between the software packages can include that the compilation or installation of one software package depends on the compilation or installation of another node corresponding software package, for example: software package A needs to be successfully compiled after software package B is compiled, and / or software package A needs to be successfully installed after software package B is installed.

[0036] Optionally, the dependencies between the software packages can be represented by the dependency graph. A node in the dependency graph can represent a software package, and the dependencies between the nodes correspond to the dependencies between the software packages. The dependencies between the nodes can be represented by directed edges between the nodes, for example: there is a dependency between two nodes connected by a directed edge, and the direction of the directed edge represents the direction of the dependency, such as a directed edge from node 1 to node 2, indicating that the compilation or installation of the software package corresponding to node 1 depends on the compilation or installation of the software package corresponding to node 2.

[0037] At operation S220, multiple nodes are selected from the dependency graph as initial positions of multiple fish in the fish swarm algorithm, where the number of the multiple fish is a preset value.

[0038] At operation S230, based on the fish swarm algorithm, the multiple fish start from their respective initial positions and move to the next node in the dependency graph according to the dependencies between the nodes to obtain the movement path of each fish, which represents the sorting result of the nodes in the dependency graph.

[0039] Illustratively, the fish swarm algorithm includes a swarm intelligence optimization algorithm that simulates the collective behavior of fish foraging, gathering, etc. in nature. A fish in the fish swarm algorithm represents a possible solution, and the fish swarm represents a set of multiple possible solutions. The action type of each fish can include foraging behavior, flocking behavior, and tail chasing behavior, and a fish in the relevant fish swarm algorithm usually only performs one of these behaviors at any time.

[0040] For example, foraging behavior can include random movement of fish to explore the surrounding environment; flocking behavior can include each fish exploring the number of partners around it, calculating the center position of these partners, and moving towards the center position; and tail chasing behavior can include when a fish or a small group of fish finds food (food can represent the most suitable next node), its partners around it will quickly follow.

[0041] Optionally, the number of the plurality of fish can be set according to actual needs. Too many fish will increase the calculation cost, and too few fish will result in insufficient global search capability and easily fall into local optimum. For example, in the case where the number of nodes in the dependency graph is 1000, the number of the plurality of fish can be set to 30 to 40. It should be noted that the specific value of the number of the plurality of fish is only an example for illustration, and can be adjusted according to actual needs, and the specific value of the number of the plurality of fish is not limited.

[0042] Figure 3 A schematic diagram of a moving path of a fish swarm according to an embodiment of the application is shown.

[0043] As shown in Figure 3 , the nodes in the dependency graph can include: F1, F2, F3, FN, S1, S2, M1, M2, M3, M4, M5, M6.

[0044] As shown in Figure 3 , F1, F2, F3, and FN can be selected as the initial positions of the four fish in the fish swarm algorithm from the dependency graph. Each fish can move from the initial position, Figure 3 The arrow in the figure indicates the possible moving direction of each fish.

[0045] Optionally, the moving direction of the fish needs to satisfy the dependency relationship between the nodes. For example, for the fish with F1 node as the initial position, the possible moving direction can include moving from F1 node to S1 node or moving from F1 node to S2 node. When it is determined that the dependency relationship between F1 node and S1 node satisfies the preset requirement, S1 node can be taken as the next node and move from F1 node to S1 node. Further, the next node relative to S1 node can be determined and continue to move from S1 node to its next node, and so on, until the moving path of the fish is obtained.

[0046] Optionally, the moving path can represent the arrangement order of all nodes in the dependency graph, and the arrangement order can represent the compilation order of the software packages corresponding to all nodes. For example, the moving path includes: moving from F1 node (corresponding to software package A) to S1 node (corresponding to software package B), moving from S1 node to M2 node (corresponding to software package D)… Correspondingly, the compilation order includes: compiling software package A first, then compiling software package B, then compiling software package D (wherein software package A, software package B, and software package D are not shown in the figure).

[0047] In operation S240, a target path is selected from the moving paths of the plurality of fish according to the dependency relationship between the nodes in the moving path.

[0048] In operation S250, the software packages in the software package set are compiled according to the target path.

[0049] Optionally, the moving path of one fish can correspond to a compiling order of one software package. The moving paths of multiple fishes can have differences in compiling success rate, compiling resource consumption, etc., which are usually related to the dependency relationship. Therefore, according to the dependency relationship between the nodes in the moving path, a target path is selected from the moving paths of the multiple fishes, and the target path can meet the requirements in terms of compiling success rate, compiling resource consumption, etc.

[0050] Figure 4 A schematic diagram of a target path according to an embodiment of the present application is shown.

[0051] As shown in Figure 4 According to the target path, each fish can start from the initial position and move to the next node in the direction indicated by the arrow in sequence.

[0052] Optionally, the software package corresponding to each node in the target path can be determined, and the software package corresponding to the node is sequentially compiled according to the sorting result of the node in the target path.

[0053] According to an embodiment of the present application, when the scale of the software package is large (such as hundreds or even thousands), it is difficult to take into account the failure retry cost of the software package, the difference in compiling time, the instantaneous resource contention, etc. by simply considering the topological order, and the above factors are usually affected by the dependency relationship. By constructing a dependency relationship graph, the dependency relationship between the software packages in terms of compiling or installing, etc. can be intuitively and accurately represented, and the problem of low efficiency and inaccurate results caused by manually determining the dependency relationship can be avoided. By combining the dependency relationship graph with the fish swarm algorithm, the process of determining the compiling order of the software package is abstracted as a dynamic optimization process of fish foraging in the dependency relationship graph. By selecting multiple nodes in the dependency relationship graph as the initial positions of multiple fishes in the fish swarm algorithm, the moving paths of the fishes are obtained based on the fish swarm algorithm, and the sorting result of the nodes in the dependency relationship graph is represented by the moving paths, so that an optimal compiling order can be determined, the success rate of the software package compiling is improved, and the compiling of a large number of software packages with complex dependency relationships is completed at one time, stably and efficiently. Thus, the technical problem of high compiling failure rate and low compiling efficiency of a software package set with a large number of software packages and complex dependency relationships in related methods is solved.

[0054] According to an embodiment of the present application, moving to the next node in the dependency relationship graph according to the dependency relationship between the nodes includes the following operations.

[0055] For each fish in the multiple fishes, a center node can be selected as the node where the fish currently locates, and a first candidate node can be selected from the nodes around the center node according to the dependency relationship between the center node and the nodes around the center node.

[0056] As shown in Figure 3 For example, in the case that the current node of the fish is F1, F1 can be taken as the center node, and S1 and S2 can be taken as the nodes around the center node. The dependency relationship between F1 and S1 and the dependency relationship between F1 and S2 can be determined respectively, and S1 or S2 can be selected as the first candidate node according to the dependency relationship.

[0057] The node in the dependency relationship graph that is selected as the next node by other fish more than a preset standard can be taken as the second candidate node.

[0058] Optionally, the node more than the preset standard can be the node that is selected most frequently. The next node selected by each of the other fish in the school can be obtained, and the node that is selected most frequently can be determined therefrom. As shown in Figure 3 The next node selected by each of the other fish can include M1, M2, M3, …, M6, and so on, in which M2 is selected as the next node by two fish (fish with F2 as the initial position and fish with F3 as the initial position), and M2 is selected most frequently, so M2 can be taken as the second candidate node.

[0059] One of the first candidate node and the second candidate node can be selected as the next node to which the fish is to move according to the association relationship between the center node and the first candidate node and the second candidate node.

[0060] Optionally, the first candidate node can represent the candidate selected by each fish itself as the next node, which represents the local optimum corresponding to each fish, and the second candidate node can represent the next node selected by the other fish in the school collectively, which represents the social optimum corresponding to the school. The first candidate node and the second candidate node can be evaluated to determine the most suitable node as the next node to which the fish is to move. For example, the association relationship between the center node and the first candidate node and the second candidate node can be evaluated to determine the next node.

[0061] The fish can be moved to the next node, and the execution of taking the current node of the fish as the center node and selecting a node as the first candidate node from the nodes around the center node according to the dependency relationship between the center node and the nodes around the center node can be returned.

[0062] As shown in Figure 3 For the fish with F1 as the initial position, after determining that the next node is S1, the fish is moved to S1, and S1 is taken as the center node, the first candidate node and the second candidate node compared with S1 are determined, and the next node compared with S1 is determined therefrom.

[0063] According to the embodiments of the present application, the local optimum is determined by determining the candidate node selected by each fish itself as the next node, the social optimum is determined by determining the next node selected by the fish group collectively, and the next node of each fish is determined by comparing the advantages and disadvantages of the local optimum and the social optimum. Through the above double-path comparison, each fish neither blindly follows the social optimum nor is trapped in the local optimum, so that the overall convergence speed is significantly improved.

[0064] According to the embodiments of the present application, selecting one of the first candidate node and the second candidate node as the next node to which the fish moves according to the association relationship between the center node and the first candidate node and the second candidate node includes the following operations.

[0065] The target path weight from the center node to the first candidate node and the target path weight from the center node to the second candidate node can be calculated according to the dependency relationship between the center node and the first candidate node and the second candidate node and the dependency relationship of the first candidate node and the second candidate node with other nodes in the dependency relationship graph.

[0066] Optionally, for the first candidate node, the target path weight from the center node to the first candidate node can be calculated according to the dependency relationship between the center node and the first candidate node and the dependency relationship of the first candidate node with other nodes in the dependency relationship graph.

[0067] Correspondingly, for the second candidate node, the target path weight from the center node to the second candidate node can be calculated according to the dependency relationship between the center node and the second candidate node and the dependency relationship of the second candidate node with other nodes in the dependency relationship graph.

[0068] One of the first candidate node and the second candidate node can be selected as the next node to which the fish moves according to the target path weight from the center node to the first candidate node and the target path weight from the center node to the second candidate node.

[0069] Optionally, the above two target path weights can be compared, for example, the target path weight with a lower value can be determined, and the candidate node corresponding to the target path weight is taken as the next node.

[0070] According to the embodiments of the present application, if the node selected by other fish is directly taken as the next node, although the node selected by other fish can be more consistent with the dependency relationship, the congestion of the node is too high due to the selection of the node by multiple fish, and the node is easy to become a resource bottleneck. If the node selected by each fish is directly taken as the next node, it can fall into a local optimum, resulting in that only a local optimum value but not a global optimum value can be obtained, and by determining the next node from the first candidate node and the second candidate node, the resource consumption and the search accuracy can be comprehensively considered, so that a more reasonable next node can be determined.

[0071] According to the embodiments of the present application, the calculation of the target path weight from the center node to the first candidate node and the target path weight from the center node to the second candidate node according to the dependency relationship between the center node and the first candidate node and the second candidate node and the dependency relationship of the first candidate node and the second candidate node with other nodes in the dependency relationship graph includes the following operations.

[0072] The initial path weight from the center node to the first candidate node and the initial path weight from the center node to the second candidate node can be determined according to the dependency relationship between the center node and the first candidate node and the second candidate node.

[0073] Optionally, for the first candidate node, the dependency relationship between the center node and the first candidate node can be determined, for example, whether the compilation or installation of the first candidate node depends on the compilation or installation of the center node, so as to determine the initial path weight from the center node to the first candidate node.

[0074] Correspondingly, for the second candidate node, for example, whether the compilation or installation of the second candidate node depends on the compilation or installation of the center node can be determined, so as to determine the initial path weight from the center node to the second candidate node.

[0075] Optionally, the initial path weight can represent the compilation cost when two nodes perform compilation in sequence, if the compilation or installation of the software package B is not dependent on the compilation or installation of the software package A, but is dependent on the compilation or installation of the software package C, and the determined compilation order is to compile the software package A corresponding to the center node first and then to compile the software package B corresponding to the next node, since the compilation order cannot meet the dependency relationship of the software package B, the compilation cost of this compilation order is high, and the corresponding initial path weight is high.

[0076] The node weight of the first candidate node and the second candidate node can be determined according to the dependency relationship of the first candidate node and the second candidate node with other nodes in the dependency relationship graph.

[0077] Optionally, the node weight can represent the importance of the node. For example, when the compilation or installation of a plurality of other nodes all need to rely on the compilation or installation of a first candidate node, it indicates that the first candidate node is more important, and the node weight of the first candidate node is higher.

[0078] The target path weight from the center node to the first candidate node can be calculated according to the initial path weight from the center node to the first candidate node and the node weight of the first candidate node.

[0079] The target path weight from the center node to the second candidate node can be calculated according to the initial path weight from the center node to the second candidate node and the node weight of the second candidate node.

[0080] Optionally, the product of the initial path weight and the node weight can be calculated to obtain the target path weight. The higher the initial path weight, the higher the compilation cost, and the higher the node weight, the more important the node. When the compilation cost of a more important node is higher (i.e., the target path weight is higher), the influence on whether the software package compilation can be successfully performed is greater (e.g., the compilation success rate is significantly reduced), and therefore, the candidate node corresponding to a lower target path weight can be selected as the next node.

[0081] According to the embodiments of the present application, the initial path weight between the center node and the candidate node and the node weight of the candidate node itself are comprehensively considered to determine the target path weight, which can comprehensively evaluate whether the candidate node is suitable as the next node from multiple dimensions such as weight importance and compilation cost, so that a more reasonable node can be screened out.

[0082] Optionally, the historical failure rate when the compilation is performed on the first candidate node and the second candidate node within a predetermined historical period can also be obtained, and one of the first candidate node and the second candidate node with a smaller target path weight and a lower historical failure rate is selected as the next node to which the center node moves.

[0083] For example, the candidate node with a smaller target path weight and a lower historical failure rate is selected as the next node.

[0084] Figure 5 A flowchart of a software package compilation method according to another embodiment of the present application is shown. As shown in FIG. 5, the software package compilation method of this embodiment includes operations S510-S5120. Figure 5

[0085] ​In operation S510, the total number N of fishes, the number M of iterations, and the step length L are set. N, M, and L are all positive integers. For one fish, one iteration corresponds to one process of determining the next node. The step length is used to represent the neighborhood radius that the fish can explore in one movement. For example, when the step length is 1, the fish finds the neighboring node of the current node in each iteration. When the step length is 2, the fish finds the node that is one node away from the current node in each iteration.

[0086] In operation S520, for the i-th fish in the fish group, the i-th fish Xi trails to obtain a first candidate node when i is equal to 1. The first candidate node can be determined in the manner described in the above embodiments. For example, for the i-th fish, the current node of the fish can be taken as the center node, and the first candidate node can be selected from the surrounding nodes according to the dependency relationship between the center node and the surrounding nodes.

[0087] In operation S530, the i-th fish Xi gathers to obtain a second candidate node. The second candidate node can be determined in the manner described in the above embodiments. For example, for the i-th fish, the node in the dependency relationship graph that is selected as the next node by other fishes more than a preset standard can be taken as the second candidate node.

[0088] In operation S540, the target path weight W1 from the center node to the first candidate node can be calculated.

[0089] In operation S550, the target path weight W2 from the center node to the second candidate node can be calculated.

[0090] For example, the target path weight W1 from the center node to the first candidate node can be calculated according to the dependency relationship between the center node and the first candidate node, and the dependency relationship of the first candidate node with other nodes in the dependency relationship graph.

[0091] For example, the target path weight W2 from the center node to the second candidate node can also be calculated according to the dependency relationship between the center node and the second candidate node, and the dependency relationship of the second candidate node with other nodes in the dependency relationship graph.

[0092] In operation S560, it is determined whether the target path weight W1 is less than the target path weight W2.

[0093] In operation S570, if the target path weight W1 is less than the target path weight W2, the first candidate node is taken as the next node of the current node. Assuming that the current node is the initial node, i.e., the first node in the sorting, the operation determines the second node in the sorting.

[0094] If the target path weight W1 is greater than or equal to the target path weight W2, the second candidate node is selected as the next node in operation S580.

[0095] For example, if the target path weight W1 is less than the target path weight W2, it means that the compilation cost from the center node to the first candidate node is smaller, and thus the first candidate node can be selected as the next node.

[0096] Correspondingly, if the target path weight W2 is less than the target path weight W1, it means that the compilation cost from the center node to the second candidate node is smaller, and thus the second candidate node can be selected as the next node.

[0097] For example, in operations S520-S580, the two paths are compared in each determination of the next node by the double path comparison mechanism, and the more suitable candidate node is selected as the next node, so that each fish neither blindly follows the trend nor falls into the local optimum problem, and the convergence speed of the fish swarm algorithm is improved.

[0098] In operation S590, it is determined whether i reaches the total number of fish N, that is, whether all fish have determined the second node of the respective path. In the case where i does not reach N, i = i + 1, that is, operations S520 and S530 are executed for the next fish until i reaches the total number of fish N.

[0099] In operation S5100, in the case where i reaches the total number of fish N, all fish have determined the second node of the respective path, that is, the first iteration is completed, and at this time, gen = gen + 1, that is, the current iteration number gen is incremented by 1. For example, after the first iteration is completed, the current iteration number gen is incremented by 1, and the second iteration is performed.

[0100] In operation S5110, it is determined whether gen is greater than the preset iteration number threshold M, and in the case where gen is less than or equal to M, operations S520 and S530 are executed to perform the next iteration.

[0101] In operation S5120, in the case where gen is greater than M, the iteration is completed.

[0102] For example, the iteration operation can be terminated when the preset iteration number threshold M is reached, and for example, the iteration can be completed when the movement path determined by each of the N fish no longer changes after a number of iterations (the number of iterations is less than M).

[0103] For example, after the iteration is completed, the N fish obtain respective movement paths, and the movement path with the smallest compilation cost of the entire movement path can be selected as the target path from the movement paths of the N fish.

[0104] According to the embodiments of the present application, by applying the fish swarm algorithm to the determination of the software package compilation sequence, the problems of low efficiency, easy to fall into local optimum and resource contention of the related method are solved, and finally a globally optimal compilation sequence can be output, which significantly improves the success rate, throughput and time efficiency of large-scale software package compilation.

[0105] According to the embodiments of the present application, the operation of determining the initial path weight from the center node to the first candidate node and the initial path weight from the center node to the second candidate node according to the dependency relationship between the center node and the first candidate node and the second candidate node includes the following operations.

[0106] For any candidate node of the first candidate node and the second candidate node, if the compilation or installation of the software package corresponding to the candidate node depends on the compilation or installation of the software package corresponding to the center node, the initial path weight from the center node to the candidate node is set to a first value. If the compilation or installation of the software package corresponding to the candidate node does not depend on the compilation or installation of the software package corresponding to the center node, the initial path weight from the center node to the candidate node is set to be higher than the first value.

[0107] Optionally, for any candidate node, if the compilation or installation of the software package corresponding to the candidate node depends on the compilation or installation of the software package corresponding to the center node, it indicates that the center node can meet the dependency relationship required by the candidate node, and therefore a lower initial path weight can be set for the candidate node, such as setting to the first value, for example, 0.

[0108] Optionally, if the compilation or installation of the software package corresponding to the candidate node does not depend on the compilation or installation of the software package corresponding to the center node, it indicates that the center node is difficult to meet the dependency relationship required by the candidate node, and therefore a higher initial path weight can be set for the candidate node.

[0109] According to the embodiments of the present application, if the compilation or installation of the software package corresponding to any candidate node does not depend on the compilation or installation of the software package corresponding to the center node, setting the initial path weight from the center node to the candidate node to be higher than the first value includes: if the installation of the software package corresponding to any candidate node does not depend on the installation of the software package corresponding to the center node, setting the initial path weight from the center node to the candidate node to be a second value, wherein the second value is higher than the first value; if the compilation of the software package corresponding to any candidate node does not depend on the compilation of the software package corresponding to the center node, setting the initial path weight from the center node to the candidate node to be a third value, wherein the third value is higher than the second value.

[0110] Optionally, the importance of different types of dependency relationships can be different, for example, if the dependency relationship of the installation process of a software package is not satisfied, it can only affect the running of the software package; and if the dependency relationship of the compilation process of the software package is not satisfied, it can cause other software packages dependent on the software package to be unable to compile normally, therefore, the importance of the dependency relationship of the compilation process can be set to be higher than that of the installation process, and accordingly, different initial path weights can be set according to the types of the dependency relationships, for example, if the compilation of any candidate node corresponding to a software package does not depend on the compilation of the software package corresponding to the center node, the initial path weight from the center node to any candidate node is set to a third value, and if the installation of any candidate node corresponding to a software package does not depend on the installation of the software package corresponding to the center node, the initial path weight from the center node to any candidate node is set to a second value, and the third value is higher than the second value.

[0111] According to the embodiments of the present application, the initial path weight is determined according to the type of the dependency relationship, which can more accurately reflect the importance of the dependency relationship, and then the next node can be accurately determined.

[0112] According to the embodiments of the present application, the node weight of each of the first candidate node and the second candidate node is determined according to the dependency relationship of each of the first candidate node and the second candidate node with other nodes in the dependency relationship graph, which comprises: for any candidate node in the first candidate node and the second candidate node, determining the number of nodes dependent on the any candidate node in the dependency relationship graph; and calculating the node weight of the any candidate node according to the number of nodes.

[0113] Optionally, for any candidate node, the nodes dependent on the any candidate node can be: the nodes need to be compiled successfully after the candidate node is compiled, and / or the nodes need to be installed successfully after the candidate node is installed.

[0114] Optionally, the node weight of any candidate node can be calculated according to the number of nodes and the ratio of the number of all nodes in the dependency relationship graph, to obtain the node weight.

[0115] According to the embodiments of the present application, by respectively determining the initial path weight and the node weight, and determining the target path weight according to the initial path weight and the node weight, and then screening the next node, the first candidate node and the second candidate node can be comprehensively evaluated from multiple angles such as whether the dependency relationship between the nodes can be satisfied and the importance of the nodes, so that a more reasonable candidate node can be screened as the next node.

[0116] In an embodiment, the corresponding node weight can also be set according to the type of the dependency relationship. The type of the dependency relationship can include a first type, which can be whether the compilation of the software package corresponding to a node depends on the compilation of the software package corresponding to another node, which can be referred to as compilation dependency; and a second type, which can be whether the installation of the software package corresponding to a node depends on the installation of the software package corresponding to another node, which can be referred to as installation dependency.

[0117] For example, for any node, the number of other nodes on which the compilation process depends can be determined in the dependency relationship graph; the first node weight of the node can be calculated according to the number of other nodes, such as for any node, the ratio of the number of other nodes on which the compilation process depends to the total number of nodes can be calculated to obtain the first node weight of the node; the number of other nodes on which the installation process depends can also be determined in the dependency relationship graph; the second node weight of the node can be calculated according to the number of other nodes, such as for any node, the ratio of the number of other nodes on which the installation process depends to the total number of nodes can be calculated to obtain the first node weight of the node.

[0118] Optionally, the value of the first node weight and the second node weight can be determined according to the importance of different types of dependency relationships, such as in the case where the first type of dependency relationship is determined to be more important than the second type of dependency relationship, the first node weight can be set to be greater than the second node weight. The correspondence between the software package, the software package on which it depends during compilation (i.e. compilation dependency), the software package on which it depends during installation (i.e. installation dependency), the first node weight, and the second node weight can be as shown in Table 1.

[0119] Wherein, the first node weight can be a compilation dependency (buildrequire) weight, and the second node weight can be an installation dependency (require) weight. buildrequire1, buildrequire2…buildrequire n respectively represent the software package on which it depends during compilation, require1, require2…require n respectively represent the software package on which it depends during installation. Wherein , … respectively represent the compilation dependency weight of software package a, software package b…software package n, which are collectively referred to as , , … respectively represent the installation dependency weight of software package a, software package b…software package n, which are collectively referred to as .

[0120]

[0121] In the case that the software package set includes n software packages, for the movement path of each fish, it includes the movement path of the fish in n nodes. For a movement path, the sum of the target path weights between each two nodes can be determined to obtain the compilation cost of the whole movement path.

[0122] The compilation cost of the movement path can be shown in the following formula (1).

[0123] (1)

[0124] Wherein, C(S) is the compilation cost of the movement path, is the sum of the compilation costs of the missing software package weight combined with the compilation dependency, and the compilation cost is added by 1 and the performance of the software package weight if the software package is not in the previous compilation sequence.

[0125] is the sum of the installation costs of the missing software package weight combined with the installation dependency, and the cost is added by 0.5 and the performance of the software package weight if the software package is not in the previous compilation sequence.

[0126] {δ1,δn} represents the compilation order of the compilation dependency and the installation dependency, and the compilation cost is generated if the current software package is not in this order.

[0127] In formula (1), it is assumed that if the installation of the software package corresponding to a node does not depend on the installation of the software package corresponding to the previous node, the initial path weight from the previous node to the node is set to 0.5, that is, the second value is 0.5, and it is assumed that if the compilation of the software package corresponding to a node does not depend on the compilation of the software package corresponding to the previous node, the initial path weight from the previous node to the node is set to 1, that is, the third value is 1.

[0128] For example, the compilation order can be initialized, a compilation order can be randomly generated, according to the order, whether the compilation dependency and the installation dependency of the software package exist is traversed from the first software package, the compilation cost is added by 1 for each non-existent compilation dependency, the compilation cost is added by 0.5 for each non-existent installation dependency, the whole compilation cost of the current compilation order is calculated in combination with the weight of each software package, and the optimization target is to optimize the compilation path with the minimum compilation cost according to the following mathematical model.

[0129] According to the embodiments of the present application, the initial path weight and the node weight are set according to the type of the dependency relationship, which can more accurately reflect the importance of the dependency relationship and avoid decision bias.

[0130] According to an embodiment of the present application, selecting a node as the first candidate node from the surrounding nodes according to the dependency relationship between the center node and the surrounding nodes comprises the following operations.

[0131] The nodes within a predetermined target radius from the center node can be determined as the surrounding nodes of the center node in the dependency graph, and the target radius is measured by the hop number between nodes.

[0132] Figure 6 A schematic diagram of a target radius and a moving path corresponding to a single fish is shown according to an embodiment of the present application.

[0133] As shown in Figure 6 , the center node can be the F1 node. The step length can represent the neighborhood radius that the fish can explore in one movement. For example, when the step length is 1, the fish only looks for the next node compared to the F1 node, such as only looking for the Xnext node as the next node, and the compilation order corresponding to the fish is to compile the F1 node first and then compile the Xnext node.

[0134] The target radius can include the hop number between nodes, for example, when the hop number is 1, the nodes with a hop number of 1 from the F1 node can be determined as the surrounding nodes with the F1 node as the origin. The surrounding nodes include, for example, Xn1, Xn2, Xnext, Xv, etc.

[0135] Alternatively, if the dependency relationship between the center node and all other nodes in the dependency graph is directly determined, it will result in too high a calculation amount, and therefore, the nodes within a predetermined target radius from the center node can be determined as the surrounding nodes of the center node, and only the dependency relationship between the center node and the surrounding nodes is determined.

[0136] The initial path weight of the center node to each surrounding node can be calculated according to the dependency relationship between the center node and the surrounding nodes; and a node is selected as the first candidate node from the surrounding nodes according to the initial path weight.

[0137] Alternatively, the node with the lowest initial path weight in the surrounding nodes can be directly selected as the first candidate node.

[0138] As shown in Figure 3 , for the F1 node, the surrounding nodes corresponding thereto include the S1 node and the S2 node, the initial path weight of the F1 node to the S1 node and the initial path weight of the F1 node to the S2 node can be calculated, and the node with the lowest initial path weight is determined as the first candidate node.

[0139] Optionally, the node congestion degree of each surrounding node is determined first, and for each surrounding node, the node congestion degree is used to represent the ratio of the number of times the node is selected as the next node by other fish to the total number of fish. A node set of the surrounding nodes with a node congestion degree lower than a preset congestion degree threshold (which can be set according to actual needs) can be obtained, and a node with the lowest initial path weight in the node set is selected as the first candidate node.

[0140] For example, if a large number of fish all select the same node as the next node, a "rush" problem can occur, causing the node congestion degree to be too high, and the node can become a resource bottleneck.

[0141] For example, for a fish swarm, the resource can include a living space required by the fish swarm. When a large number of fish all point to the same node, the resource around the node can be quickly consumed and occupied, for example, too many fish rush to the same node, causing the space resource to rapidly decrease, which can cause the fish swarm to be unable to move.

[0142] Optionally, a node set with a lower node congestion degree can be filtered out first, and then a node with the lowest initial path weight in the node set is determined as the first candidate node. The first candidate node determined in this way can meet the requirements of the node congestion degree and the initial path weight at the same time.

[0143] According to an embodiment of the present application, the target radius can also be reduced as the number of nodes passed by the fish in the dependency graph increases.

[0144] For example, if the target radius is too large, the global search capability is stronger, but a decision jitter problem can occur, such as unstable and irregular fluctuations in the moving direction and distance of the fish, causing the search process to lack focus. If the target radius is too small, the local fine search is more accurate, but a local minimum problem can occur, such as the fish being trapped in a local area that appears to be optimal but is not globally optimal, and being unable to jump out of the range to explore a better solution. By reducing the target radius as the number of nodes passed by the fish in the dependency graph increases, the search range and search accuracy can be considered.

[0145] According to an embodiment of the present application, reducing the target radius as the number of nodes passed by the fish in the dependency graph increases includes: if the number of nodes passed by the fish in the dependency graph is less than or equal to a preset number threshold, setting the target radius to a base value; and if the number of nodes passed by the fish in the dependency graph is greater than the preset number threshold, setting the target radius to an updated value, wherein the updated value is greater than the base value.

[0146] Optionally, a larger target radius is set in an early stage of movement of each fish (e.g., when the number of nodes passed by the fish in the dependency graph is less than or equal to a preset number threshold), that is, the target radius is set to a base value, so that the search can be performed in a larger range, covering a wider search space as much as possible, and enhancing the global exploration capability. In a later stage of movement of each fish (e.g., when the number of nodes passed by the fish in the dependency graph is greater than the preset number threshold), the target radius is reduced, that is, the target radius is set to an updated value, so that a fine search can be performed in a smaller range, improving the search accuracy.

[0147] By the above method of nonlinearly decreasing the target radius, the search range and the search accuracy can be considered, thereby improving the convergence speed and the search result accuracy of the fish swarm algorithm.

[0148] According to an embodiment of the present application, selecting a plurality of nodes from the dependency graph as initial positions of a plurality of fishes in the fish swarm algorithm includes: selecting a node set satisfying a dependency relationship standard from the dependency graph, wherein the dependency relationship standard includes that the compilation or installation of a software package corresponding to a node does not depend on the compilation or installation of a software package corresponding to any other node; and randomly selecting a plurality of nodes from the node set as initial positions of a plurality of fishes in the fish swarm algorithm.

[0149] Optionally, for a first software package performing compilation, the compilation process and the installation process thereof cannot depend on other software packages, so that the entire compilation process and the installation process can normally start to be performed, and therefore, all nodes satisfying the above dependency relationship standard can be determined from the dependency graph to obtain a node set, and then a plurality of nodes are randomly selected from the node set as initial positions of a plurality of fishes in the fish swarm algorithm.

[0150] For example, the nodes satisfying the dependency relationship standard are determined from the dependency graph to include F1, F2, F3, F4,..., FN. Since the preset number of fishes is 4, 4 nodes are randomly selected from the above nodes, such as F1, F2, F3, and FN. According to an embodiment of the present application, by selecting a node set satisfying the dependency relationship standard from the dependency graph, any fish can be at a position that can normally start to compile at an initial moment of compilation, and thus it is ensured that each compilation sequence can normally start to be performed.

[0151] According to an embodiment of the present application, the software package compilation method further includes obtaining original codes corresponding to each software package in the software package set and configuration files corresponding to the original codes; and parsing first fields and second fields in the configuration files of the software packages to obtain dependency relationships between the software packages, wherein the first field indicates whether the compilation of a software package depends on the compilation of other software packages, and the second field indicates whether the installation of the software package depends on the installation of other software packages.

[0152] Optionally, the original code and the configuration file corresponding to the original code can be obtained from an original code repository maintained by a software developer or a community. The configuration file can be parsed to determine the first field and the second field.

[0153] Based on the above software package compiling method, the application further provides a software package compiling apparatus. The following will be described in combination with Figure 7 The apparatus is described in detail.

[0154] Figure 7 A structure block diagram of the software package compiling apparatus according to an embodiment of the application is shown.

[0155] As Figure 7 shown, the software package compiling apparatus 700 of this embodiment includes a building module 710, a selecting module 720, a moving module 730, a selecting module 740 and a compiling module 750.

[0156] The building module 710 is configured to build a dependency graph based on a software package set to be compiled, the dependency graph including nodes and dependency relationships between the nodes, wherein the nodes represent software packages, and the dependency relationships between the nodes represent whether the compilation or installation of a software package corresponding to one node depends on the compilation or installation of a software package corresponding to another node. In an embodiment, the building module 710 can be configured to perform the operation S210 described above, and details are not repeated here.

[0157] The selecting module 720 is configured to select a plurality of nodes from the dependency graph as initial positions of a plurality of fishes in a fish swarm algorithm respectively, wherein the number of the plurality of fishes is a preset value. In an embodiment, the selecting module 720 can be configured to perform the operation S220 described above, and details are not repeated here.

[0158] The moving module 730 is configured to cause the plurality of fishes to move from the respective initial positions to next nodes in the dependency graph according to the dependency relationships between the nodes based on the fish swarm algorithm, to obtain moving paths of the plurality of fishes, and the moving paths represent sorting results of the nodes in the dependency graph. In an embodiment, the moving module 730 can be configured to perform the operation S230 described above, and details are not repeated here.

[0159] The selecting module 740 is configured to select a target path from the moving paths of the plurality of fishes according to the dependency relationships between the nodes in the moving paths. In an embodiment, the selecting module 740 can be configured to perform the operation S240 described above, and details are not repeated here.

[0160] The compiling module 750 is configured to compile the software packages in the software package set according to the target path. In an embodiment, the compiling module 750 can be configured to perform the operation S250 described above, and details are not repeated here.

[0161] According to an embodiment of the present application, the moving module 730 comprises a first selection sub-module, a selection sub-module, a second selection sub-module and a return sub-module.

[0162] The first selection sub-module is configured to select a node as a first candidate node from the nodes around the center node according to the dependency relationship between the center node and the nodes around the center node; the selection sub-module is configured to select a node as a second candidate node if the number of times the node is selected as the next node in the dependency relationship graph by other fish is higher than a preset standard; the second selection sub-module is configured to select one of the first candidate node and the second candidate node as the next node to which the fish is to move according to the association relationship between the center node and the first candidate node and the second candidate node; and the return sub-module is configured to make the fish move to the next node and return to execute the operation of selecting a node as a first candidate node from the nodes around the center node according to the dependency relationship between the center node and the nodes around the center node.

[0163] According to an embodiment of the present application, the second selection sub-module comprises a first calculation unit and a selection unit.

[0164] The first calculation unit is configured to calculate a target path weight from the center node to the first candidate node and a target path weight from the center node to the second candidate node according to the dependency relationship between the center node and the first candidate node and the second candidate node and the dependency relationship of the first candidate node and the second candidate node with other nodes in the dependency relationship graph; and the selection unit is configured to select one of the first candidate node and the second candidate node as the next node to which the fish is to move according to the target path weight from the center node to the first candidate node and the target path weight from the center node to the second candidate node.

[0165] According to an embodiment of the present application, the first calculation unit comprises a first determination sub-unit, a second determination sub-unit, a first calculation sub-unit and a second calculation sub-unit.

[0166] The first determination sub-unit is configured to determine an initial path weight from the center node to the first candidate node and an initial path weight from the center node to the second candidate node according to the dependency relationship between the center node and the first candidate node and the second candidate node; the second determination sub-unit is configured to determine a node weight of the first candidate node and the second candidate node according to the dependency relationship of the first candidate node and the second candidate node with other nodes in the dependency relationship graph; the first calculation sub-unit is configured to calculate a target path weight from the center node to the first candidate node according to the initial path weight from the center node to the first candidate node and the node weight of the first candidate node; and the second calculation sub-unit is configured to calculate a target path weight from the center node to the second candidate node according to the initial path weight from the center node to the second candidate node and the node weight of the second candidate node.

[0167] According to the embodiment of the present application, for the first determining subunit, the determining of the initial path weight from the center node to the first candidate node and the initial path weight from the center node to the second candidate node according to the dependency relationship between the center node and the first candidate node and the second candidate node comprises: if the compiling or installing of the software package corresponding to the first candidate node or the second candidate node does not depend on the compiling or installing of the software package corresponding to the center node, setting the initial path weight from the center node to the corresponding first candidate node or second candidate node as a first value.

[0168] According to the embodiment of the present application, for the first determining subunit, the determining of the initial path weight from the center node to the first candidate node and the initial path weight from the center node to the second candidate node according to the dependency relationship between the center node and the first candidate node and the second candidate node further comprises: if the compiling or installing of the software package corresponding to the first candidate node or the second candidate node depends on the compiling or installing of the software package corresponding to the center node, setting the initial path weight from the center node to the corresponding first candidate node or second candidate node as a second value, wherein the first value is greater than the second value.

[0169] According to the embodiment of the present application, for the second determining subunit, the determining of the node weight of the first candidate node and the second candidate node according to the dependency relationship between the first candidate node and the second candidate node and other nodes in the dependency relationship graph comprises: for any candidate node in the first candidate node and the second candidate node, determining the number of nodes in the dependency relationship graph that depend on the any candidate node; and calculating the node weight of the any candidate node according to the number of nodes.

[0170] According to the embodiment of the present application, the first selection sub-module comprises a determining unit, a second calculating unit and a first obtaining unit.

[0171] The determining unit is configured to determine, in the dependency relationship graph, nodes with a distance less than a predetermined distance from the center node as surrounding nodes of the center node; the second calculating unit is configured to calculate initial path weights of the center node to each surrounding node according to the dependency relationship between the center node and the surrounding nodes; and the obtaining unit is configured to take the surrounding nodes with the initial path weights satisfying a preset standard as the first candidate nodes.

[0172] According to the embodiment of the present application, the first selection sub-module further comprises a second obtaining unit and a reducing unit.

[0173] The second obtaining unit is configured to take nodes within a target radius with the center node as the origin as the surrounding nodes of the center node; and the reducing unit is configured to reduce the target radius as the number of nodes passed by the fish in the dependency relationship graph increases.

[0174] According to an embodiment of the present application, the second obtaining unit comprises a first obtaining subunit and a second obtaining subunit.

[0175] The first obtaining subunit is configured to set the target radius as a first radius value when it is determined that the execution frequency is less than or equal to a preset frequency threshold; and the second obtaining subunit is configured to set the target radius as a second radius value when it is determined that the execution frequency is greater than the preset frequency threshold, wherein the first radius value is greater than the second radius value.

[0176] According to an embodiment of the present application, the selecting module 720 comprises a first selecting subunit and a random selecting subunit.

[0177] The first selecting subunit is configured to select a node set satisfying a dependency relationship standard from the dependency relationship graph, wherein the dependency relationship standard comprises that the compilation of the software package corresponding to the node does not depend on the compilation of any other software package corresponding to any other node; and the random selecting subunit is configured to

[0178] Randomly select a plurality of nodes from the node set as the initial positions of a plurality of fishes in the fish swarm algorithm.

[0179] According to an embodiment of the present application, the software package compilation apparatus further comprises an obtaining module and an analyzing module.

[0180] The obtaining module is configured to obtain the original code corresponding to each software package in the software package set and the configuration file corresponding to the original code; and the analyzing module is configured to analyze a first field and a second field in the configuration file of each software package to obtain the dependency relationship between the software packages, wherein the first field indicates whether the compilation of the software package depends on the compilation of other software packages, and the second field indicates whether the installation of the software package depends on the installation of other software packages.

[0181] According to an embodiment of the present application, any of the modules of the constructing module 710, the selecting module 720, the moving module 730, the selecting module 740 and the compiling module 750 can be combined in one module, or any of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of the modules can be combined with at least part of the functions of the other modules, and implemented in one module. According to an embodiment of the present application, at least one of the constructing module 710, the selecting module 720, the moving module 730, the selecting module 740 and the compiling module 750 can be implemented at least in part as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on board, a system in package, an application specific integrated circuit (ASIC), or any other reasonable manner of integrating or packaging a circuit, etc. in hardware or firmware, or implemented in any one of the three implementation manners of software, hardware and firmware, or in a proper combination of any of the implementation manners. Alternatively, at least one of the constructing module 710, the selecting module 720, the moving module 730, the selecting module 740 and the compiling module 750 can be implemented at least in part as a computer program module which, when executed, can perform the corresponding functions.

[0182] Figure 8 A block diagram of an electronic device suitable for implementing the software package compiling method according to an embodiment of the present application is shown.

[0183] As shown in Figure 8 The electronic device 800 according to an embodiment of the present application includes a processor 801 which can perform various appropriate actions and processes according to a program stored in a read only memory (ROM) 802 or a program loaded from a storage portion 808 into a random access memory (RAM) 803. The processor 801 can include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special purpose microprocessor (e.g., an application specific integrated circuit (ASIC)), etc. The processor 801 can also include an on-board memory for cache use. The processor 801 can include a single processing unit or multiple processing units for performing different actions of the method processes according to embodiments of the present application.

[0184] In the RAM 803, various programs and data required for the operation of the electronic device 800 are stored. The processor 801, the ROM 802, and the RAM 803 are connected to each other via the bus 804. The processor 801 performs various operations of the method flow according to the embodiments of the present application by executing the programs in the ROM 802 and / or the RAM 803. It should be noted that the programs can also be stored in one or more memories other than the ROM 802 and the RAM 803. The processor 801 can also perform various operations of the method flow according to the embodiments of the present application by executing the programs stored in the one or more memories.

[0185] According to the embodiments of the present application, the electronic device 800 can further include an input / output (I / O) interface 805, which is also connected to the bus 804. The electronic device 800 can further include one or more of the following components connected to the input / output (I / O) interface 805: an input part 806 including a keyboard, a mouse, and the like; an output part 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), and the like, and a speaker, and the like; a storage part 808 including a hard disk, and the like; and a communication part 809 including a network interface card such as a LAN card, a modem, and the like. The communication part 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output (I / O) interface 805 as necessary. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, and the like is mounted on the drive 810 as necessary, so that a computer program read therefrom is installed in the storage part 808 as necessary.

[0186] The present application also provides a computer readable storage medium, which can be included in the device / apparatus / system described in the above embodiments; or can exist separately without being assembled into the device / apparatus / system. The above computer readable storage medium carries one or more programs, when the one or more programs are executed, the method according to the embodiments of the present application is implemented.

[0187] According to an embodiment of the present application, the computer readable storage medium can be a non-transitory computer readable storage medium, for example, can include but not limited to: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this application, a computer readable storage medium can be any tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present application, the computer readable storage medium can include the ROM 802 and / or the RAM 803 described above, and / or one or more memory devices other than the ROM 802 and the RAM 803.

[0188] Embodiments of the present application also include a computer program product, which includes a computer program containing program codes for executing the methods shown in the flowcharts. When the computer program product is run in a computer system, the program codes are used to make the computer system implement the methods provided by the embodiments of the present application.

[0189] The above functions defined in the system / device / apparatus of the embodiments of the present application are performed when the computer program is executed by the processor 801. According to an embodiment of the present application, the system, device, module, unit, etc. described above can be implemented by computer program modules.

[0190] In one embodiment, the computer program can rely on tangible storage media such as optical storage media, magnetic storage media, etc. In another embodiment, the computer program can also be transmitted, distributed, and downloaded in the form of signals on network media. The computer program containing program codes can be transmitted by any appropriate network media, including but not limited to wireless, wired, etc., or any suitable combination of the foregoing.

[0191] In such an embodiment, the computer program can be downloaded and installed from the network by the communication part 809, and / or installed from the detachable medium 811. When the computer program is executed by the processor 801, the above functions defined in the system of the embodiments of the present application are performed. According to an embodiment of the present application, the system, device, apparatus, module, unit, etc. described above can be implemented by computer program modules.

[0192] According to embodiments of the present application, program code for implementing the computer programs provided by embodiments of the present application can be written in any combination of one or more programming languages, and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. The programming language includes, but is not limited to, such languages as Java, C++, python, "C" language, or the like. The program code can execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the remote computing device, or entirely on the remote computing device or server. In the latter scenario, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computing device, such as through the Internet using an Internet Service Provider.

[0193] The computer program instructions can also be loaded onto a computer or other programmable information processing apparatus to cause a series of operations to be performed on the computer or other programmable information processing apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable information processing apparatus implement the functions / acts specified in the flowchart and / or block diagram block or blocks.

[0194] Those skilled in the art will understand that features recited in the various embodiments of the present application can be combined and / or integrated in a variety of ways, even if such combinations or integrations are not expressly noted in the present application. In particular, features recited in the various embodiments of the present application can be combined and / or integrated in ways that do not depart from the spirit and scope of the present application. All such combinations and / or integrations are within the scope of the present application.

[0195] The embodiments of the present application are described above. However, these embodiments are merely for illustration purposes, and are not intended to limit the scope of the present application. Although the embodiments are described separately above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. Those skilled in the art can make various substitutions and modifications without departing from the scope of the present application, and these substitutions and modifications shall fall within the scope of the present application.

Claims

1. A software package compiling method, characterized by, The method comprises: constructing a dependency graph based on a software package set to be compiled, the dependency graph comprising nodes and dependency relationships between the nodes, wherein the nodes represent software packages, and the dependency relationships between the nodes represent whether the compilation or installation of a software package corresponding to one node depends on the compilation or installation of a software package corresponding to another node; selecting multiple nodes from the dependency graph as initial positions of multiple fish in a fish swarm algorithm, wherein the number of the multiple fish is a preset value; based on the fish swarm algorithm, causing the multiple fish to move to a next node in the dependency graph according to the dependency relationships between the nodes from respective initial positions, to obtain a moving path of each fish, the moving path representing a sorting result of the nodes in the dependency graph; selecting a target path from the moving paths of the multiple fish according to the dependency relationships between the nodes in the moving path; compiling software packages in the software package set according to the target path; wherein the moving to the next node in the dependency graph according to the dependency relationships between the nodes comprises, for each fish in the multiple fish, selecting a node as a first candidate node from nodes around the center node according to the dependency relationships between the center node and the nodes around the center node; selecting a node in the dependency graph as a second candidate node, which is selected as the next node by other fish more than a preset standard; selecting one of the first candidate node and the second candidate node as the next node to which the fish moves according to an association relationship between the center node and the first candidate node and the second candidate node; causing the fish to move to the next node, and returning to the selecting the node as the first candidate node from the nodes around the center node according to the dependency relationships between the center node and the nodes around the center node; wherein the selecting one of the first candidate node and the second candidate node as the next node to which the fish moves according to the association relationship between the center node and the first candidate node and the second candidate node comprises: calculating a target path weight from the center node to the first candidate node and a target path weight from the center node to the second candidate node according to the dependency relationships between the center node and the first candidate node and the second candidate node and the dependency relationships between the first candidate node and the second candidate node and other nodes in the dependency graph; selecting one of the first candidate node and the second candidate node as the next node to which the fish moves according to the target path weight from the center node to the first candidate node and the target path weight from the center node to the second candidate node.

2. The method of claim 1, wherein, The calculating the target path weight from the center node to the first candidate node and the target path weight from the center node to the second candidate node according to the dependency relationship between the center node and the first candidate node and the second candidate node and the dependency relationship of the first candidate node and the second candidate node with other nodes in the dependency graph comprises: determining an initial path weight from the center node to the first candidate node and an initial path weight from the center node to the second candidate node according to the dependency relationship between the center node and the first candidate node and the second candidate node; determining node weights of the first candidate node and the second candidate node according to the dependency relationship of the first candidate node and the second candidate node with other nodes in the dependency graph; calculating the target path weight from the center node to the first candidate node according to the initial path weight from the center node to the first candidate node and the node weight of the first candidate node; calculating the target path weight from the center node to the second candidate node according to the initial path weight from the center node to the second candidate node and the node weight of the second candidate node.

3. The method of claim 2, wherein, The determining an initial path weight from the center node to the first candidate node and an initial path weight from the center node to the second candidate node according to the dependency relationship between the center node and the first candidate node and the second candidate node comprises: if the compilation or installation of the software package corresponding to the any candidate node depends on the compilation or installation of the software package corresponding to the center node, setting the initial path weight from the center node to the any candidate node as a first value; if the compilation or installation of the software package corresponding to the any candidate node does not depend on the compilation or installation of the software package corresponding to the center node, setting the initial path weight from the center node to the any candidate node as higher than the first value.

4. The method of claim 3, wherein, The setting the initial path weight from the center node to the any candidate node as higher than the first value if the compilation or installation of the software package corresponding to the any candidate node does not depend on the compilation or installation of the software package corresponding to the center node comprises: if the installation of the software package corresponding to the any candidate node does not depend on the installation of the software package corresponding to the center node, setting the initial path weight from the center node to the any candidate node as a second value, wherein the second value is higher than the first value; if the compilation of the software package corresponding to the any candidate node does not depend on the compilation of the software package corresponding to the center node, setting the initial path weight from the center node to the any candidate node as a third value, wherein the third value is higher than the second value.

5. The method of claim 2, wherein, The determining node weights of the first candidate node and the second candidate node according to the dependency relationship of the first candidate node and the second candidate node with other nodes in the dependency graph comprises: determining the number of nodes in the dependency graph that depend on the any candidate node for the any candidate node of the first candidate node and the second candidate node; and determining the node weight of the any candidate node according to the number of nodes in the dependency graph that depend on the any candidate node. calculating a node weight of any candidate node according to the number of nodes.

6. The method of claim 1, wherein, The selecting a node as a first candidate node from the surrounding nodes according to the dependency relationship between the center node and the surrounding nodes includes: determining, in the dependency graph, nodes having a distance from the center node within a predetermined target radius as surrounding nodes of the center node, the target radius being measured by a number of hops between nodes; calculating an initial path weight of the center node to each surrounding node according to the dependency relationship between the center node and the surrounding nodes; selecting a node as the first candidate node from the surrounding nodes according to the initial path weight.

7. The method of claim 6, wherein, The method further includes: decreasing the target radius as the number of nodes passed by the fish in the dependency graph increases.

8. The method of claim 7, wherein, The decreasing the target radius as the number of nodes passed by the fish in the dependency graph increases includes: setting the target radius to a base value if the number of nodes passed by the fish in the dependency graph is less than or equal to a preset number threshold; setting the target radius to an updated value if the number of nodes passed by the fish in the dependency graph is greater than the preset number threshold, wherein the updated value is greater than the base value.

9. The method of claim 1, wherein, The selecting multiple nodes as initial positions of multiple fish in the fish swarm algorithm from the dependency graph includes: selecting a node set satisfying a dependency relationship criterion from the dependency graph, wherein the dependency relationship criterion includes that compilation or installation of a software package corresponding to a node does not depend on compilation or installation of a software package corresponding to any other node; randomly selecting multiple nodes from the node set as initial positions of multiple fish in the fish swarm algorithm.

10. The method of claim 1, wherein, The method further includes: obtaining original codes corresponding to each software package in the software package set and configuration files corresponding to the original codes; parsing a first field and a second field in the configuration file of each software package to obtain a dependency relationship between the software packages, wherein the first field indicates whether compilation of a software package depends on compilation of other software packages, and the second field indicates whether installation of a software package depends on installation of other software packages. 11.An electronic device, comprising: one or more processors; a memory for storing one or more computer programs, characterized in that the one or more processors execute the one or more computer programs to implement steps of the software package compilation method according to any one of claims 1-10.

Citation Information

Patent Citations

  • Method and devicefor constructing Linux system

    CN112214221A

  • Path planning method and system based on water tiger fish algorithm

    CN117094456A