A balanced partitioning method based on network flow
By selecting virtual source points and sink points in the network flow diagram and iteratively updating the maximum flow and edge weights to achieve balanced segmentation, the problems of circuit edge processing difficulties, high segmentation cost, and inability to support directed signal segmentation and slow segmentation speed in the prior art are solved, and a smaller cutting cost and faster segmentation speed are achieved.
Patent Information
- Application Number
- CN202411496433.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-10-25
AI Technical Summary
The existing network flow-based segmentation method cannot directly process the connected edges in the circuit. The segmentation is expensive and cannot support directed signal segmentation, and the segmentation speed is slow.
A balanced segmentation method based on network flow is proposed. By selecting virtual source points and sink points, a network flow graph is established, and the maximum flow and edge weights are iteratively updated, the network flow graph is segmented to achieve balanced segmentation.
This method can effectively process directional signals, adapt to segmentation scenarios where physical channels have directional limitations, reduce cutting costs, and increase segmentation speed.
Smart Images

Figure CN119005110B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of electronic design automation (EDA), and in particular relates to a balanced segmentation method based on network flow. Background Art
[0002] In the field of EDA, many links involve algorithms related to segmentation. For example, in order to achieve parallel synthesis during logic synthesis, the circuit design needs to be divided into different sub-parts, and each sub-part needs to be logically synthesized or optimized at the same time; in the layout process, the circuit design must not only be divided into different sub-parts, but also the communication cost of the physical channel of each sub-part on the chip must be taken into consideration.
[0003] Circuit design is different from general graph structures. It has its own structural characteristics. Its operation mode is mostly based on the pipeline processing mode. At the same time, its internal connections can connect multiple circuit modules at the same time. It has certain particularities, so it requires a segmentation method for circuit design. Network flow is a classic graph problem. Using network flow for segmentation is a relatively advanced algorithm application. The process of solving network flow can also be regarded as the solution process of segmentation.
[0004] The existing segmentation methods based on network flow have the following problems: 1. The existing segmentation methods based on network flow cannot directly process the edges (net) in the circuit, which can connect multiple circuit modules at the same time. 2. The existing segmentation methods based on network flow randomly select source points S and sink points T in the network flow graph. The source point is the starting node of the flow, and the sink point is the arrival node of the flow. If the nodes of the source point S and the sink point T are improperly selected, such as selecting two nodes with particularly large maximum flow values, then the segmentation cost will increase. The segmentation cost refers to the sum of the weights of the edges on the segmentation boundary. 3. The existing segmentation methods based on network flow are mostly applicable to undirected graphs, while the signals in circuit design are directional. At the same time, in the later wiring stage, the physical channels that can carry signals sometimes limit the direction of the signals. Therefore, the segmentation methods based on network flow urgently need a segmentation method that can support directed signals. 4. The existing segmentation methods based on flow are slow because the segmentation process involves multiple maximum flow recalculations, which consumes a lot of time. Summary of the invention
[0005] The present invention provides a balanced segmentation method based on network flow to solve the problems that the existing segmentation method based on network flow cannot directly process the edges in the circuit, has a high segmentation cost, cannot support directed signal segmentation, and has a slow segmentation method.
[0006] In order to solve the above technical problems, the technical solution provided by the present invention is:
[0007] The present invention relates to a balanced segmentation method based on network flow, which comprises the following steps:
[0008] S1. The circuit modules in the circuit are taken as nodes, and the edges between the circuit modules are taken as edges to establish a network flow graph;
[0009] S2. Select one of the nodes in the network flow graph as the source and another node as the sink;
[0010] S3. Set the initial maximum flow of the network flow graph to 0;
[0011] S4. Search for a path from the source point to the sink point that has not been searched before. If the path can be found, go to S5; if the path cannot be found, skip S5 and go to S6;
[0012] S5. Take the weight of the edge with the minimum edge weight on the path as the minimum flow of the path, update the maximum flow of the network flow graph and the weight of each edge passed by the path, and return to S4;
[0013] S6. Input the signal flow to the source point of the updated network flow graph, take the nodes that the signal flow can reach as group X, take the nodes that the signal flow cannot reach as group Y, split the edges of the network flow graph whose starting point is in the node of group X and whose end point is in the node of group Y, and form a cutting boundary. The updated maximum flow is the minimum cutting cost.
[0014] S7. Determine whether the sum of the weights of the nodes in the X group nodes and the Y group nodes is balanced. If balanced, output the segmentation result. If unbalanced, enter S8;
[0015] S8. When the sum of the weights of the nodes in group X is too large, traverse the nodes in group X and form a new sink with the original sink. When the sum of the weights of the nodes in group Y is too large, traverse the nodes in group Y and form a new source with the original source. Analyze the updated maximum flow in each case in the manner of S4-S6, select the cutting scheme with the smallest maximum flow and return to S7.
[0016] Preferably, in S1, the logic size of the circuit module is used as the weight of the corresponding node; and the capacity of the edge is used as the weight of the corresponding edge.
[0017] Preferably, when establishing a network flow graph in S1, when there is an edge connecting multiple circuit modules or there is an edge connecting a source point and multiple circuit modules or there is an edge connecting a circuit module and multiple sinks, the weight of the edge is recorded as w, the node at the input end of the edge is defined as a driving node, and the nodes at the multiple output ends are defined as load nodes, a virtual node is established between the driving node and the load node, the weight of the virtual node is 0, an edge with a weight of w is established between the driving node and the virtual node, and an edge with a weight of positive infinity is established between the virtual node and each load node.
[0018] Preferably, the update formula of the maximum flow of the network flow graph in S5 is:
[0019] max-flow(t)=max-flow(t-1)+min-flow,
[0020] In the formula, t represents the number of updates of the maximum flow, max-flow(t) and max-flow(t-1) represent the maximum flow of the network flow graph at the t-th update and the t-1-th update respectively, and min-flow represents the minimum flow of the path.
[0021] Preferably, the specific manner of S5 updating the weight of each edge that the path passes through is: the weight of each edge on the path is reduced to reduce the minimum flow of the path.
[0022] Preferably, the balance formula for determining whether the weights of the nodes in the X group nodes and the Y group nodes are balanced in S7 is:
[0023] |Wx - Wy| / |Wx + Wy| > α ,
[0024] Where Wx is the sum of the weights of all nodes in the X group of nodes, and Wy is the sum of the weights of all nodes in the Y group of nodes. α is the threshold value;
[0025] When the above balance formula is satisfied, it is judged as the weight and balance of the nodes in the X group nodes and the Y group nodes. When the above balance formula is not satisfied, it is judged as the weight and imbalance of the nodes in the X group nodes and the Y group nodes.
[0026] Preferably, each time S8 traverses the nodes in group X or group Y, after adding a new node to the source or sink, the nodes and edges in group X are deleted and restored after calculating the maximum flow.
[0027] Preferably, S4 uses a breadth-first search method or a depth-first search algorithm to search for an unsearched path from the source point to the sink point.
[0028] Compared with the prior art, the technical solution provided by the present invention has the following beneficial effects:
[0029] 1. The balanced segmentation method based on network flow involved in the present invention selects one of the nodes in the network flow graph as the source point and the other node as the sink point, sets the initial maximum flow to 0, searches for the path from the source point to the sink point in turn and takes the weight of the edge with the minimum weight on the path as the minimum flow, iteratively updates the maximum flow of the network flow graph and the weight of the edge passing through the path, inputs the signal flow to the source point of the updated network flow graph, takes the nodes that the signal flow can reach as the X group and the nodes that the signal flow cannot reach as the Y group, and segments the edges of the nodes in the network flow graph whose starting point is located in the X group and whose end point is located in the Y group, and completes a segmentation. By selecting virtual source points and sink points, the method makes the network flow algorithm more suitable for the circuit structure characterized by flow processing, can coordinate and integrate the different positions of the circuit input and output ports, so that the value of the maximum flow finally obtained is smaller, that is, the cutting cost is smaller, can process directional signals, and adapt to the segmentation scenario where the channel has directional restrictions on the physical channel.
[0030] 2. The balanced segmentation method based on network flow involved in the present invention determines whether the sum of the weights of the two groups of nodes after segmentation is balanced after each segmentation. If the weights of the two groups of nodes after segmentation are unbalanced, traverse the nodes of the group with larger weight and add the traversed nodes to the source point or the sink point, repeat the path search from the source point to the sink point, find the minimum flow on the path, update the weight of each edge on the maximum flow machine path of the network flow graph, cut the network flow graph and other steps, find the situation with the minimum cutting cost as the new cutting plan, until the weights of the two groups of nodes after segmentation are balanced. This method uses balanced segmentation as a constraint condition while maintaining the network flow as a real flow. Through each iterative adjustment, new segmentation boundaries and cutting costs are incrementally obtained, the size of the cutting cost is controlled, a balanced segmentation result is obtained, and the segmentation speed based on network flow is improved.
[0031] 3. The balanced partitioning method based on network flow involved in the present invention, when establishing a network flow graph, when there is an edge connecting multiple circuit modules or an edge connecting a source point and multiple circuit modules or an edge connecting a circuit module and multiple sinks, the edge is defined as a hyperedge, the weight of the edge is recorded as w, the node at the input end of the edge is defined as a driving node, and the nodes at the multiple output ends are defined as load nodes, a virtual node is established between the driving node and the load node, the weight of the virtual node is 0, an edge with a weight of w is established between the driving node and the virtual node, and an edge with a positive infinite weight is established between the virtual node and each load node, thereby solving the problem of edge modeling in network flow and making the cutting of the edges in the circuit more reasonable, that is, either not cutting the edge or cutting it at the output port of the driving node, thereby reducing the cutting cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a flow chart of a balanced segmentation method based on network flow involved in the present invention;
[0033] Figure 2 is a circuit diagram in an embodiment;
[0034] Figure 3 It is a schematic diagram of the structure of a hyperedge;
[0035] Figure 4 This is a schematic diagram after the hyperedge processing;
[0036] Figure 5 It is the network flow graph established;
[0037] Figure 6 It is the network flow graph after the first segmentation;
[0038] Figure 7 is the network flow graph of the second segmentation after adding node d to the source point in the embodiment;
[0039] Figure 8 is the network flow graph of the second segmentation after adding node f to the source point in the embodiment;
[0040] Fig. 9 It is the network flow graph of the second segmentation after adding node e to the source point in the embodiment. DETAILED DESCRIPTION
[0041] In order to further understand the content of the present invention, the present invention is described in detail in conjunction with examples. The following examples are used to illustrate the present invention but are not used to limit the scope of the present invention.
[0042] See attached Figure 1 As shown, the balanced segmentation method based on network flow involved in the present invention comprises the following steps:
[0043] S1. The circuit modules in the circuit are regarded as nodes, the edges between the circuit modules are regarded as edges, and the logical size of the circuit modules is regarded as the weight of the corresponding node, and the capacity of the edge is regarded as the weight of the corresponding edge, to establish a network flow graph. Since the network flow requires that there cannot be edges connecting multiple nodes at the same time, there are edges connecting multiple nodes in the actual circuit. Such edges are called hyperedges. Figure 2 Take the circuit shown as an example, net 1 That is, a hyperedge. At this time, the edge needs to be further processed. Specifically, when there is an edge connecting multiple circuit modules, or an edge connecting a source point and multiple circuit modules, or an edge connecting a circuit module and multiple sinks, that is, when a hyperedge exists, such as Figure 3 is a schematic diagram of a hyperedge with a driver node d (the input end of the network flow) and a load node d greater than or equal to d 1 -d i(output end of the network flow), record the weight of the edge as w, define the node at the input end of the edge as the driver node, and the nodes at multiple output ends as load nodes, establish a virtual node d' between the driver node and the load node, the weight of the virtual node is 0, establish an edge with a weight of w between the driver node and the virtual node, and establish an edge with a weight of positive infinity between the virtual node and each load node. The advantage of this treatment is that when performing a segmentation operation, for the segmentation method that aims to minimize the cutting cost, the guiding method either does not cut the edge, or cuts on the edge between the driver node and the virtual node, increasing the cutting cost of w, and does not cut between the virtual node and the load node; if the cut is between the virtual node and the load node, the load nodes will be separated from each other, and the cutting cost will be repeatedly superimposed, causing the cutting cost to be overestimated, making the segmentation objective function inaccurate and obtaining a bad segmentation result.
[0044] It should be noted that for edges with only two endpoints, there is no need to create a virtual node. This solves the problem of modeling edges in network flows.
[0045] Follow the steps in S1 to finally obtain Figure 4 The network flow diagram is not related to Figure 2 It corresponds to the circuit diagram in the figure and is only used to illustrate how to segment the network flow graph later. The network flow graph contains 7 nodes numbered ag. The arrow-shaped lines between the nodes are edges, and the numbers on the edges represent the weights of the edges.
[0046] S2. Select one of the nodes in the network flow graph as the source and another node as the sink; Figure 5 As shown, this embodiment selects node a as the source point and node e as the sink point.
[0047] S3. Set the initial maximum flow of the network flow graph to 0.
[0048] S4. Use a breadth-first search method or a depth-first search algorithm to search for a path from the source point to the sink point that has not been searched. If the path can be found, go to S5; if the path cannot be found, skip S5 and go to S6.
[0049] S5. Figure 5 The paths of the network flow graph shown are path a→d→e and path a→d→c→e. Taking the first searched path a→d→e as an example, the weight of the edge with the minimum edge weight on the path is used as the minimum flow of the path, and the maximum flow of the network flow graph and the weight of each edge passed by the path are updated;
[0050] The update formula for updating the maximum flow of the network flow graph is:
[0051] max-flow(t)=max-flow(t-1)+min-flow,
[0052] In the formula, t represents the number of updates of the maximum flow, max-flow (t) and max-flow (t-1) represent the maximum flow of the network flow graph at the t-th update and the t-1-th update, respectively, and min-flow represents the minimum flow of the path;
[0053] The specific method of updating the weight of each edge that the path passes through is: the weight of each edge on the path reduces the minimum flow of the path.
[0054] After updating the maximum flow of the network flow graph and the weight of each edge on the path a→d→e, return to S4, search for another path a→d→c→e from the source to the sink, and iterate the maximum flow of the network flow graph and the network flow graph again according to S5, and finally get the following Figure 6 The network flow diagram shown.
[0055] from Figure 6 It can be seen from the network flow diagram shown that the weights of the edges between nodes a and d, the edges between nodes d and e, the edges between nodes d and c, and the edges between nodes c and e are all updated. The denominator in the number on the edge represents the initial weight of the corresponding edge, and the numerator represents the traffic that has been occupied. The difference between the denominator and the numerator is the remaining capacity of the corresponding edge.
[0056] S6. Input the signal flow to the source point of the updated network flow graph, take the nodes that the signal flow can reach as group X, take the nodes that the signal flow cannot reach as group Y, split the edges of the network flow graph whose starting point is in the node of group X and whose end point is in the node of group Y, and form a cutting boundary. The updated maximum flow is the minimum cutting cost. Figure 6 As shown in the figure, the directions from node a to node f and from node a to node b are opposite. The signal flow of node a cannot reach node f and node b. The remaining capacity between node a and node d is 0. Therefore, no signal flow will reach d. Therefore, node a falls into group X and the remaining nodes fall into group Y. The edges from node a to node f, node a to node b, and node a to node d are cut. Since the updated maximum flow is the minimum cutting cost, the cutting cost of this cutting is 2.
[0057] S7. Determine whether the sum of the weights of the nodes in the X group nodes and the Y group nodes is balanced. If balanced, output the segmentation result. If not balanced, enter S8. Determine whether it is balanced according to the following balance formula:
[0058] |Wx - Wy| / |Wx + Wy| > α ,
[0059] Where Wx is the sum of the weights of all nodes in the X group of nodes, and Wy is the sum of the weights of all nodes in the Y group of nodes. α is the threshold value;
[0060] When the above balance formula is satisfied, it is judged as the weight and balance of the nodes in the X group nodes and the Y group nodes. When the above balance formula is not satisfied, it is judged as the weight and imbalance of the nodes in the X group nodes and the Y group nodes.
[0061] S8. When the sum of the weights of the nodes in group X is too large, traverse the nodes in group X and form a new sink with the original sink. When the sum of the weights of the nodes in group Y is too large, traverse the nodes in group Y and form a new source with the original source. Each time the nodes in group X or group Y are traversed, a new node is added to the source or sink, and the nodes and edges in group X are deleted. The updated maximum flow in each case is analyzed in the manner of S4-S6, and the deleted nodes and edges in group X are restored after calculating the maximum flow. The cutting scheme with the smallest maximum flow is selected and the return is made to S7.
[0062] To explain this step in more detail, this embodiment assumes that the sum of the weights of all nodes in the Y group of nodes is greater, that is, Wy>Wx. Assuming that node d in the Y group of nodes is added to the source point, a new segmentation boundary and maximum flow will be obtained, as shown in FIG. Figure 7 As shown, it is not difficult to find that the addition of node d does not increase the size of the cutting cost, but the weight of the node in group X and the value of Wx change from 1 to 2. Node d is a good choice because it increases the cutting cost very little and makes the segmentation more balanced.
[0063] Suppose that node f in group Y is added to the source node, such as Figure 8As shown in Figure 1, because node f can add more network flows to the sink e, as mentioned in step 7, the X group and the dividing line are temporarily deleted from the network flow graph, that is, the flow from node f will not be allowed to be transmitted to the nodes in group X. The reason is that the cutting boundary between group X and group Y is already the bottleneck of the network flow. The capacity of each edge in the cutting boundary is completely equal to the actual flow, that is, it is impossible to transmit any flow to the direction of group Y nodes. Temporarily deleting the X group and the dividing line from the network flow graph is actually the algorithm to avoid exploring unnecessary solution space and save processing time. The maximum flow from node f to sink e is X(f) = {f,b,d,g}, the original X(a) = {a}, then the new X = X(f)UX(a) = {a,b,d,f,g}, the maximum flow from node f to node e is max-flow(f) = 4, the original max-flow(a) = 2, then the new maximum flow is equal to the sum of the two 6. It is not difficult to see that Wx = 5, Wy=2, which is not a balanced segmentation result. At the same time, the new min-cut increases by 4, which makes the cutting cost larger. It can be seen that adding node f to the source point is not a good choice.
[0064] Select new nodes to add to the source nodes, including any nodes in group Y, and of course also including nodes that have no edges with any nodes in group X, such as node c; refer to the attached Fig. 9 As shown, then as in the above method, the maximum flow of node c max-flow(c) = 4, X(c) = {c, d, e}, and the union of the original X(a) = {a} is the new X = {a, c, d, g}, and the new max-flow = 4+2=6. It can be seen that the segmentation result is more balanced, but the cutting cost is increased a lot. Selecting node c to join the source point is a more compromised choice. However, the present invention needs to be continuously optimized and adjusted through iterative steps, so it is a better choice to add the node with the least maximum flow to the source point in each iteration, such as node d.
[0065] The present invention is described in detail above in conjunction with the embodiments, but the contents described are only preferred embodiments of the present invention and cannot be considered to limit the scope of implementation of the present invention. All equivalent changes and improvements made according to the scope of application of the present invention should still fall within the scope of the patent coverage of the present invention.
Claims
1. A balanced segmentation method based on network flow, characterized in that: It includes the following steps: S1. Take the circuit modules in the circuit as nodes, the edges between the circuit modules as edges, the logical size of the circuit modules as the weight of the corresponding nodes, and the capacity of the edges as the weight of the corresponding edges to establish a network flow graph; when establishing the network flow graph, when there is an edge connecting multiple circuit modules or there is an edge connecting a source point and multiple circuit modules or there is an edge connecting a circuit module and multiple sinks, record the weight of the edge as w, define the node at the input end of the edge as a driving node, and the nodes at the multiple output ends as load nodes, establish a virtual node between the driving node and the load node, the weight of the virtual node is 0, establish an edge with a weight of w between the driving node and the virtual node, and establish an edge with a weight of positive infinity between the virtual node and each load node; S2. Select one of the nodes in the network flow graph as the source and another node as the sink; S3. Set the initial maximum flow of the network flow graph to 0; S4. Search for a path from the source point to the sink point that has not been searched before. If the path can be found, go to S5; if the path cannot be found, skip S5 and go to S6; S5. Take the weight of the edge with the minimum edge weight on the path as the minimum flow of the path, update the maximum flow of the network flow graph and the weight of each edge passed by the path, and return to S4; S6. Input the signal flow to the source point of the updated network flow graph, take the nodes that the signal flow can reach as group X, take the nodes that the signal flow cannot reach as group Y, split the edges of the network flow graph whose starting point is in the node of group X and whose end point is in the node of group Y, and form a cutting boundary. The updated maximum flow is the minimum cutting cost. S7. Determine whether the sum of the weights of the nodes in the X group nodes and the Y group nodes is balanced. If balanced, output the segmentation result. If unbalanced, enter S8; The balance formula for judging whether the weights of nodes in group X and group Y are balanced is: |Wx - Wy| / |Wx + Wy| > α , Where Wx is the sum of the weights of all nodes in the X group of nodes, and Wy is the sum of the weights of all nodes in the Y group of nodes. α is the threshold value; When the above balance formula is satisfied, the weights of the nodes in group X and group Y are judged to be balanced. When the above balance formula is not satisfied, the weights of the nodes in group X and group Y are judged to be unbalanced. S8. When the sum of the weights of the nodes in group X is too large, traverse the nodes in group X and form a new sink with the original sink. When the sum of the weights of the nodes in group Y is too large, traverse the nodes in group Y and form a new source with the original source. Analyze the updated maximum flow in each case in the manner of S4-S6, select the cutting scheme with the smallest maximum flow and return to S7.
2. The balanced segmentation method based on network flow according to claim 1, characterized in that: The update formula of the maximum flow of the S5 network flow graph is: max-flow(t)=max-flow(t-1)+min-flow, In the formula, t represents the number of updates of the maximum flow, max-flow(t) and max-flow(t-1) represent the maximum flow of the network flow graph at the t-th update and the t-1-th update respectively, and min-flow represents the minimum flow of the path.
3. The balanced segmentation method based on network flow according to claim 1, characterized in that: The specific manner in which S5 updates the weight of each edge that the path passes through is that the weight of each edge on the path is reduced by the minimum flow of the path.
4. The balanced segmentation method based on network flow according to claim 1, characterized in that: Each time, S8 traverses the nodes in the X group or the Y group, adds a new node to the source node or the sink node, deletes the nodes and edges in the X group, and restores them after calculating the maximum flow.
5. The balanced segmentation method based on network flow according to claim 1, characterized in that: The S4 uses a breadth-first search method or a depth-first search algorithm to search for an unsearched path from the source point to the sink point.
Citation Information
Patent Citations
Wireless sensor network node dynamic deployment method based on network flow
CN103297983A
Optimal under-chain channel network routing method based on minimum cost flow
CN114938379A