WO2015021869A1 - Method and device for selecting optimal network maximum flow algorithm - Google Patents

Method and device for selecting optimal network maximum flow algorithm Download PDF

Info

Publication number
WO2015021869A1
WO2015021869A1 PCT/CN2014/083511 CN2014083511W WO2015021869A1 WO 2015021869 A1 WO2015021869 A1 WO 2015021869A1 CN 2014083511 W CN2014083511 W CN 2014083511W WO 2015021869 A1 WO2015021869 A1 WO 2015021869A1
Authority
WO
WIPO (PCT)
Prior art keywords
algorithm
network
algorithms
flow
active node
Prior art date
Application number
PCT/CN2014/083511
Other languages
French (fr)
Chinese (zh)
Inventor
王蕾
崔慧敏
吕方
冯晓兵
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2015021869A1 publication Critical patent/WO2015021869A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/04Forecasting or optimisation specially adapted for administrative or management purposes, e.g. linear programming or "cutting stock problem"
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks

Definitions

  • the present invention relates to the field of network maximum flow, and in particular, to a method and device for selecting an optimal network maximum stream algorithm.
  • BACKGROUND OF THE INVENTION Acquiring the maximum flow problem of a network is a classic problem in graph theory and combinatorial optimization, and it has a wide application background.
  • the pre-flow propulsion method is a commonly used method for obtaining a maximum flow of a network
  • the method includes multiple algorithms, which can be summarized as: obtaining a residual network according to the acquired network flow graph, from the residual network Obtaining an active node, and in the residual network, the surplus stream corresponding to the active node is advanced to the sink point through the adjacent node, and after determining that the adjacent node is a new active node, continuing in the The residual network pushes the new active node to the sink point through the adjacent node until the active node does not exist in the residual network, and then determines that the traffic of the sink point is the maximum flow of the network.
  • Embodiments of the present invention provide a method and a device for selecting an optimal network maximum flow algorithm, which are capable of determining an optimal network maximum flow algorithm according to different network flow graphs.
  • a method for selecting an optimal network maximum flow algorithm including: Obtaining a network flow graph, and obtaining a first residual network according to the network flow graph;
  • Obtaining a set of operation algorithms where the set of operation algorithms includes at least two algorithms; performing pre-flow advancement in parallel by the at least two algorithms in the first residual network to obtain a second residual network, and Determining, in the second residual network, the number of key edges corresponding to the at least two algorithms;
  • the algorithm corresponding to determining the maximum value of the number of key edges is an optimal network maximum flow algorithm of the network flow graph.
  • the method further includes:
  • the acquisition operation algorithm set includes:
  • the algorithm template includes a data structure configured by the user to manage the active node, and an algorithm configured by the user corresponding to the active node, and the algorithm
  • the set of operational algorithms is obtained in accordance with the algorithm and data structure.
  • the method further includes:
  • Fine-grained locking of the data structure of the network flow graph is Fine-grained.
  • the pre-flow advancement is performed in parallel by the at least two algorithms in the first residual network.
  • the method further includes:
  • the method further includes:
  • the obtaining the second residual network includes:
  • the second residual network is obtained according to the new distance identifier of all the nodes to the sink.
  • determining the sink point when determining that the data structure of the management active node does not have an active node, determining the sink point
  • the traffic is the maximum flow of the network.
  • the method further includes:
  • the pre-flow advancement in parallel in the residual network by the at least two algorithms includes:
  • Pre-flow advancement is performed in parallel by the at least two algorithms according to the corresponding number of threads in the first residual network.
  • the method further includes:
  • the number of threads is reconfigured for the at least two algorithms based on the number of key edges.
  • an algorithm selection device including:
  • An obtaining unit configured to acquire a network flow graph, and obtain a first residual amount according to the network flow graph Networking, and acquiring a set of operational algorithms, where the set of operational algorithms includes at least two algorithms;
  • a processing unit configured to perform pre-flow advancement in parallel by the at least two algorithms in the first residual network, to obtain a second residual network, and determine a key corresponding to the at least two algorithms after pre-flow advancement
  • An algorithm corresponding to the number of edges and determining a maximum value of the number of key edges in the second residual network is an optimal network maximum flow algorithm of the network flow graph.
  • the acquiring unit is further configured to: after obtaining the first residual network according to the network flow graph, acquiring an active node according to the first residual network;
  • the acquiring unit is specifically configured to: acquire an algorithm and a data structure corresponding to the active node according to an algorithm template, and obtain the operation algorithm set according to the algorithm and the data structure, where the algorithm template includes user configured management The data structure of the active node and the user-configured algorithm corresponding to the active node and the data structure of the network flow graph.
  • the processing unit is further configured to add a fine-grained lock to the data structure of the network flow graph.
  • the processing unit is specifically configured to perform an active active node according to the at least two algorithms, Acquiring a corresponding active node in the data structure, and advancing the surplus stream of the corresponding active node in parallel with the neighboring node whose distance identifier is lower than itself according to the at least two algorithms, wherein The surplus stream includes a positive difference between the inflow and the outflow of the active node.
  • the processing unit is further configured to: perform a surplus flow of the corresponding active node to the sink point by using the neighboring node After advancing, if the neighboring node has the surplus stream, determining that the adjacent node is a new active node, and placing the new active node into the data of the management active node In the structure.
  • the processing unit is further configured to: when the pre-flow advancement is performed in parallel by the at least two algorithms, obtain the number of edges that are re-identified, Obtaining an update parameter according to the algorithm template, and when determining that the update parameter and the number of re-identified edges satisfy a preset condition, updating a distance identifier of all nodes to the sink point to obtain all the nodes to The new distance identifier of the meeting point, and according to all the knots mentioned The new distance identification point to the sink point gets the second residual network.
  • the processing unit is further configured to: when determining that the data structure of the management active node does not have an active node When the point is reached, it is determined that the traffic of the sink is the maximum flow of the network.
  • the acquiring unit is further configured to: pass in the first residual network Obtaining a total number of threads before the at least two algorithms perform the pre-flow advancement in parallel; the processing unit is further configured to: configure a number of threads corresponding to the at least two algorithms, and pass the network in the first residual network
  • the at least two algorithms perform pre-flow advancement according to the corresponding number of threads, wherein the number of threads includes a ratio of the total number of threads to the number of algorithms of the at least two algorithms.
  • the processing unit is further configured to: after determining that the algorithm corresponding to the maximum value of the number of the critical edges is the optimal network maximum flow algorithm, The number of threads is reconfigured for the at least two algorithms based on the number of key edges.
  • the network flow graph is pre-flowed by operating a plurality of algorithms in the algorithm set, and after the pre-flow advancement, the algorithm with the largest number of key edges corresponding to each algorithm is determined as the optimal network maximum flow algorithm.
  • the adaptive network flow graph can be dynamically adjusted to obtain an optimal performance algorithm, thereby improving the efficiency of the network maximum flow calculation.
  • FIG. 1 is a schematic flowchart of a method for selecting an optimal network maximum flow algorithm according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart diagram of another method for selecting an optimal network maximum flow algorithm according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of an algorithm selection device according to an embodiment of the present invention
  • FIG. 4 is a schematic structural diagram of another algorithm selection device according to an embodiment of the present invention.
  • the embodiment of the invention provides a method for selecting an optimal network maximum flow algorithm.
  • the execution subject of the method is an algorithm selection device, including:
  • the algorithm selection device acquires a network flow graph, and obtains a first residual network according to the network flow graph.
  • the residual network is obtained by transforming the network flow graph.
  • the algorithm selection device acquires a set of operation algorithms.
  • the set of operational algorithms includes at least two algorithms.
  • the algorithm selecting device acquires an active node according to the first residual network, where the active node is a node whose inbound traffic is greater than the outgoing traffic, and the algorithm selecting device acquires an algorithm and data corresponding to the active node according to the algorithm template. Structure, and the set of operational algorithms is obtained according to the algorithm and data structure.
  • the algorithm template includes a data structure configured by the user to manage the active node, an algorithm configured by the user corresponding to the active node, and a data structure of the network flow graph.
  • the algorithm template includes a main control part, providing a framework of the algorithm; the algorithm part, the user may configure at least two algorithms; the node management part, including the acquired active node and the user-configured corresponding management active node data Structure (such as bucke t, F IFO-queue and s tack); update event, used to update the distance identifier of each node in the first residual network to the sink; update parameters, configured by the user; Network flow graph data structure for storing residual networks.
  • the node management part including the acquired active node and the user-configured corresponding management active node data Structure (such as bucke t, F IFO-queue and s tack)
  • update event used to update the distance identifier of each node in the first residual network to the sink
  • update parameters configured by the user
  • Network flow graph data structure for storing residual networks.
  • the algorithm part, the node management part and the update parameter can be configured by the user.
  • the above algorithm framework can be: Whi le (act i veV) ⁇
  • activeV indicates the number of active nodes in the residual network
  • activeV indicates that the number of active nodes in the residual network is not zero
  • the algorithm selection device may obtain an algorithm and a data structure configured by the user according to the foregoing algorithm template, and obtain the operation algorithm set according to the algorithm and the data structure, where the operation algorithm set may be:
  • bucket (i->d) represents the data structure of the user-managed active node; vertex, computel (node* i) ⁇ ... workset.
  • Parallel operations of multiple algorithms can be implemented by the above set of operational algorithms.
  • the algorithm selection device may fine-grain the data structure of the network flow graph to prevent data competition, for example, preventing other algorithms other than the active node corresponding algorithm from reading and writing the active node.
  • the algorithm selection device performs pre-flow advancement in parallel in the first residual network by using the at least two algorithms to obtain a second residual network, and determines, in the second residual network, the at least two algorithms. The number of key edges.
  • the parallelism refers to that another algorithm can be executed at the same time in the process of executing one of the algorithms, and is not limited to starting at the same time.
  • the algorithm selects the number of active nodes from the management according to the at least two algorithms According to the structure, the corresponding active node is obtained, and the surplus stream of the corresponding active node is pushed in parallel to the sink point by the adjacent node whose distance identifier is lower than the self according to the at least two algorithms.
  • the surplus flow includes a positive difference between the inflow and the outflow of the active node.
  • the algorithm selecting device determines that the neighboring node is a new active node, and places the new active node into the data structure of the managing active node. in.
  • the algorithm selecting device acquires the number of re-identified edges, and obtains an update parameter according to the algorithm template, and determines the update parameter and the number of the re-identified edges.
  • the distance identifiers of all nodes to the sink point are updated to obtain a new distance identifier of all the nodes to the sink point, and the second residue is obtained according to the new distance identifier of all the nodes to the sink point.
  • the algorithm selecting device determines to update the flow of the new active node, * when determining that the product of the number of re-identified edges and the update parameter is greater than the number of sides of the network flow graph and the product of the number, *, and number.
  • the algorithm selection device may perform reverse width-first search by the sink point to update all the nodes to the sink point identifier, and after the distance identifier is updated, obtain the second residual network according to the updated distance identifier, and The number of key edges corresponding to the at least two algorithms is counted in the second residual network.
  • the algorithm selecting device determines, when the data structure of the management active node does not have an active node, determining that the traffic of the sink is the maximum flow of the network, such that the at least two algorithms are calculated by executing the parallel algorithm in parallel.
  • the network flow graph speeds up the acquisition of the maximum flow of the network, thereby improving the calculation efficiency.
  • the algorithm selecting device acquires the total number of threads and performs the number of threads corresponding to at least two algorithms before the pre-streaming advancement by the at least two algorithms in the first residual network, and the algorithm selecting device is in the The pre-streaming advancement is performed in parallel by the at least two algorithms according to the corresponding number of threads in the first residual network.
  • the number of threads includes a ratio of the total number of threads to the number of algorithms of the at least two algorithms, that is, the number of threads configured by the algorithm selection device for each algorithm is the same.
  • code that the algorithm executes in parallel can be:
  • the algorithm that determines, by the algorithm selection device, the maximum value of the number of the critical edges is an optimal network maximum flow algorithm of the network flow graph.
  • the algorithm is determined to be the optimal network maximum flow algorithm corresponding to the network flow graph.
  • the algorithm selects the number of threads for the at least two algorithms according to the number of the key edges.
  • the algorithm selection device pre-flows the network flow graph by operating multiple algorithms in the algorithm set, and after the pre-flow advancement, the number of key edges corresponding to each algorithm is the largest.
  • the algorithm is determined as the optimal network maximum flow algorithm, so that in the process of obtaining the maximum flow of the network, the adaptive different network flow graphs can be dynamically adjusted to obtain an optimal performance algorithm, thereby improving the efficiency of the network maximum flow calculation.
  • An embodiment of the present invention provides a method for selecting an optimal network maximum flow algorithm, as shown in FIG. 2, including:
  • the S20 algorithm selects a device to obtain a network flow graph, and obtains a first residual network according to the network flow graph.
  • the residual network is obtained by transforming the network flow graph.
  • the algorithm selection device acquires an active node according to the first residual network.
  • the algorithm selection device acquires an algorithm and a data structure corresponding to the active node according to the algorithm template, and adds a fine-grained lock to the data structure of the network flow graph.
  • the active node is a node whose inbound traffic is greater than the outgoing traffic.
  • the algorithm template includes a data structure of the user-configured active active node and an algorithm configured by the user corresponding to the active node and a data structure of the network flow graph.
  • the algorithm selection device puts the acquired active node into the data structure of the management active node.
  • the algorithm template includes a main control part, providing a framework of the algorithm; the algorithm part, the user may configure at least two algorithms; the node management part, including the acquired active node and the user-configured corresponding management active node data Structure (such as bucket, FIFO-queue, and stack); update event, used to update the distance identifier of each node in the first residual network to the sink; update parameters, configured by the user; network flow graph Data structure for storing residual networks.
  • the node management part including the acquired active node and the user-configured corresponding management active node data Structure (such as bucket, FIFO-queue, and stack); update event, used to update the distance identifier of each node in the first residual network to the sink; update parameters, configured by the user; network flow graph Data structure for storing residual networks.
  • the algorithm part, the node management part and the update parameter can be configured by the user.
  • the above algorithm framework can be:
  • activeV indicates the number of active nodes in the residual network
  • activeV indicates that the number of active nodes in the residual network is not zero
  • the algorithm selection device may obtain an algorithm and a data structure configured by the user according to the foregoing algorithm template, and obtain the operation algorithm set according to the algorithm and the data structure, where the operation algorithm set may be:
  • GLOB_UPDT-FREQ 0.5;
  • bucket (i->d) represents the data structure of the user-managed active node; vertex, computel (node* i) ⁇ ... workset.
  • push ( j); ⁇ indicates the active node and the corresponding algorithm
  • GLOB_UPDT_FREQ 0.5 indicates the user-configured update parameters.
  • Parallel operations of multiple algorithms can be implemented by the above set of operational algorithms.
  • the algorithm selection device obtains the operation algorithm set according to the algorithm and the data structure.
  • the set of operational algorithms includes at least two algorithms.
  • the algorithm selection device acquires a corresponding active node from the data structure of the management active node according to the at least two algorithms.
  • the algorithm selects a device to obtain a total number of threads, and configures a number of threads corresponding to at least two algorithms according to the total number of threads.
  • the number of threads includes a ratio of the total number of threads to the number of algorithms of the at least two algorithms.
  • the algorithm selection device performs pre-flow advancement in parallel according to the corresponding number of threads in the first residual network by using the at least two algorithms.
  • the surplus flow includes a positive difference between the inflow and the outflow of the active node.
  • code that the algorithm executes in parallel can be:
  • Paral lel-f or (the number of a 1 gor i thms) executes all algorithms in parallel, where the number of algorithms represents the number of algorithms, paral lel_f or (thread_group [i] ) executes algorithm i, where thread- Group [i] represents the thread group corresponding to algorithm i; algorithm_i () represents algorithm i.
  • the algorithm selecting device determines that the adjacent node is a new active node, and puts the new active node into the Manage active nodes, in the data structure.
  • the algorithm selection device acquires the number of edges that are re-identified when the pre-flow advancement is performed in parallel by the at least two algorithms, and acquires the update parameter according to the algorithm template. It should be noted that, if the algorithm selection device determines that there is no active node in the data structure of the active node after performing the pre-flow advancement, it determines that the traffic of the sink point is the maximum flow of the network, so that the at least The two algorithms calculate the network flow graph, which speeds up the acquisition of the maximum flow of the network, thereby improving the calculation efficiency.
  • the algorithm selecting device updates the distance identifiers of all the nodes to the sink point when determining that the update parameter and the number of the re-identified edges meet the preset condition, to obtain a new giant of all the nodes to the sink point. Off the logo.
  • the algorithm selecting device determines to update the distance identifier of all the nodes to the sink point, and the algorithm selecting device Specifically, the sinker performs reverse width priority search to update the distance identifier of all nodes to the sink point, and after the distance identifier is updated, obtains the second residual network according to the updated distance identifier, and in the second residual The number of key edges corresponding to the at least two algorithms is counted in the quantity network.
  • the algorithm selection device obtains the second residual network according to the new distance identifier.
  • the algorithm selection device determines the number of key edges corresponding to the at least two algorithms in the second residual network.
  • the algorithm that determines the maximum value of the number of key edges by the algorithm selection device is an optimal network maximum flow algorithm of the network flow graph.
  • the algorithm selection device reconfigures the number of threads for the optimal network maximum flow algorithm. Specifically, after determining the optimal network maximum flow algorithm, more threads are allocated for the optimal network maximum flow, so that the algorithm reduces computation time and improves computation efficiency in the operation process, thereby improving the algorithm. Algorithm performance.
  • the adaptive network flow graph can be dynamically adjusted to obtain an optimal performance algorithm, thereby improving the efficiency of the network maximum stream calculation.
  • An embodiment of the present invention provides an algorithm selection device 30, as shown in FIG. 3, including: The obtaining unit 31 is configured to obtain a network flow graph, obtain a first residual network according to the network flow graph, and obtain a set of operation algorithms.
  • the residual network is obtained by transforming a network flow graph, and the operational algorithm set includes at least two algorithms.
  • the processing unit 32 is configured to perform pre-flow advancement in parallel by the at least two algorithms in the first residual network to obtain a second residual network, and determine a key edge corresponding to the at least two algorithms after the pre-flow advancement
  • the algorithm corresponding to the quantity, and determining the maximum value of the number of key edges in the second residual network is the optimal network maximum flow algorithm of the network flow graph.
  • the acquiring unit 31 is further configured to obtain an active node according to the first residual network after obtaining the first residual network according to the network flow graph.
  • the obtaining unit 31 puts the acquired active node into the data structure of the management active node.
  • the acquiring unit 31 is configured to obtain an algorithm and a data structure corresponding to the active node according to the algorithm template, and obtain the operation algorithm set according to the algorithm and the data structure, where the algorithm template includes a user-configured active node.
  • the data structure and the user-configured algorithm corresponding to the active node and the data structure of the network flow graph are configured to obtain an algorithm and a data structure corresponding to the active node according to the algorithm template, and obtain the operation algorithm set according to the algorithm and the data structure, where the algorithm template includes a user-configured active node.
  • the algorithm template includes a main control part, providing a framework of the algorithm; the algorithm part, the user may configure at least two algorithms; the node management part, including the acquired active node and the user-configured corresponding management active node data Structure (such as bucket, FIFO-queue, and stack); update event, used to update the distance identifier of each node in the first residual network; update parameters, configured by the user, network flow graph data structure, Used to store residual networks.
  • the node management part including the acquired active node and the user-configured corresponding management active node data Structure (such as bucket, FIFO-queue, and stack); update event, used to update the distance identifier of each node in the first residual network; update parameters, configured by the user, network flow graph data structure, Used to store residual networks.
  • the algorithm part, the node management part and the update parameter can be configured by the user.
  • the above algorithm framework can be:
  • Ver tex. compute (i); where act iveV indicates the number of active nodes in the residual network, while (activeV) indicates that the number of active nodes in the residual network is not zero, the algorithm is executed, i workset. Remove 0 means that the active node is taken out from the node management part, and the workset represents the data structure of the corresponding management active node configured by the user; vertex, compute (i) The surplus stream of the active node is operated by an algorithm corresponding to the active node.
  • the algorithm selection device may obtain an algorithm and a data structure configured by the user according to the foregoing algorithm template, and obtain the operation algorithm set according to the algorithm and the data structure, where the operation algorithm set may be:
  • bucket (i->d) represents the data structure of the user-managed active node; vertex, computel (node* i) ⁇ ... workset.
  • Parallel operations of multiple algorithms can be implemented by the above set of operational algorithms.
  • processing unit 32 is further configured to: fine-grain the data structure of the network flow graph to prevent data competition, for example, prevent other algorithms other than the active node corresponding algorithm from reading and writing the active node. operating.
  • the processing unit 32 is configured to: obtain, according to the at least two algorithms, a corresponding active node from the data structure of the active node, and perform the corresponding active node in parallel according to the at least two algorithms.
  • the surplus flow advances to the meeting point through adjacent nodes.
  • the surplus flow includes a positive difference between the inflow and the outflow of the active node.
  • processing unit is further configured to: after the surplus stream of the corresponding active node is advanced to the sink point by using an adjacent node whose distance identifier is lower than itself, if the neighboring node has the surplus flow, Then, the adjacent node is determined to be a new active node, and the new active node is placed in the data structure of the management active node.
  • the obtaining unit 31 is further configured to: before the pre-streaming advancement by the at least two algorithms in the first residual network, obtain a total number of threads, and the processing unit configures at least two algorithms according to the total number of threads. The number of threads, and pre-flow advancement in parallel by the at least two algorithms according to the corresponding number of threads in the first residual network.
  • the number of threads includes a ratio of the total number of threads to the number of algorithms of the at least two algorithms, that is, the number of threads configured by the algorithm selection device for each algorithm is the same.
  • the code that the algorithm executes in parallel can be:
  • Paral lel-f or (the number of a 1 gor i thms) executes all algorithms in parallel, where the number of algorithms represents the number of algorithms, paral lel_f or (thread_group [i] ) executes algorithm i, where thread- Group [i] represents the thread group corresponding to algorithm i; algorithm_i () represents algorithm i.
  • the processing unit 32 is further configured to: when the pre-stream advancement is performed in parallel by the at least two algorithms, obtain the number of re-identified edges, obtain an update parameter according to the algorithm template, and determine the update parameter and When the number of the re-identified edges meets the preset condition, the distance identifiers of all the nodes to the sink point are updated to obtain a new distance identifier of all the nodes to the sink point, and the second distance identifier is obtained according to the new distance identifier. Residual network.
  • the algorithm selecting device determines to update the distance identifier of all the nodes to the sink point, and the algorithm selecting device Specifically, the sinking point performs reverse width first search to update the distance identifiers of all the nodes to the sink point, and after the distance is updated, obtains the second residual network according to the updated distance identifier, and in the second residual The number of key edges corresponding to the at least two algorithms is counted in the quantity network.
  • processing unit 32 is further configured to: after determining that the algorithm corresponding to the maximum value of the number of the critical edges is the optimal network maximum flow algorithm, reconfiguring the number of threads for the at least two algorithms according to the number of the critical edges.
  • the algorithm is determined to be the optimal network maximum flow algorithm corresponding to the network flow graph.
  • the obtaining unit 31 is further configured to: determine a data structure of the active node in the management When there is no active node, the flow of the sink is determined to be the maximum flow of the network.
  • the network flow graph is calculated by executing the at least two algorithms in parallel, the speed of acquiring the maximum flow of the network is accelerated, thereby improving the speed. Computational efficiency.
  • the algorithm selecting device performs pre-flow advancement of the network flow graph by using multiple algorithms in the algorithm set, and after the pre-flow advancement, determining the algorithm with the largest number of key edges corresponding to each algorithm as
  • the optimal network maximum flow algorithm enables dynamic adaptation of different network flow graphs to obtain optimal performance algorithms in the process of obtaining the maximum flow of the network, thereby improving the efficiency of the network maximum flow calculation.
  • the present invention provides an algorithm selection device 40. As shown in FIG. 4, the algorithm selection device 40 includes:
  • processor 41 a processor (Rocessor) 41, a communication interface (42), a memory 43 and a communication bus 44; wherein the processor 41, the communication interface 42, and the memory 43 are completed by the communication bus 44 Communication with each other.
  • processor 41 the communication interface 42, and the memory 43 are completed by the communication bus 44 Communication with each other.
  • the processor 41 may be a multi-core CPU or a specific integrated circuit.
  • An ASIC Application Specific Integrated Circuit
  • one or more integrated circuits configured to implement embodiments of the present invention.
  • the memory 43 is for storing program code, and the program code includes computer operation instructions and a network flow diagram.
  • Memory 43 may contain high speed RAM memory and may also include non-volatile memory, such as at least "disk storage.”
  • the communication interface 42 is configured to implement connection communication between the devices.
  • the processor 41 executes program code for acquiring a network flow graph, and obtains a first residual network according to the network flow graph, and acquires an operation algorithm set, where the at least two algorithms are performed in parallel in the first residual network. Pre-flow advancement, obtaining a second residual network, and determining the number of key edges corresponding to the at least two algorithms in the second residual network, and determining that the maximum value of the number of key edges corresponds to the network flow.
  • the optimal network maximum flow algorithm for the graph is
  • the set of operational algorithms includes at least two algorithms.
  • the processor 41 is further configured to: acquire an active node according to the first residual network, acquire an algorithm and a data structure corresponding to the active node according to the algorithm template, and obtain the operation according to the algorithm and the data structure. Algorithm set.
  • the algorithm template includes a data structure configured by the user to manage the active node, an algorithm configured by the user corresponding to the active node, and a data structure of the network flow graph.
  • the processor 41 is further configured to add a fine-grained lock to the data structure of the network flow graph.
  • the processor 41 is configured to: obtain, according to the at least two algorithms, a corresponding active node from a data structure of the active node, and perform the corresponding active node in parallel according to the at least two algorithms. The surplus flow advances to the meeting point through adjacent nodes.
  • the surplus flow includes a positive difference between the inflow and the outflow of the active node.
  • the processor 41 is specifically configured to: if the neighboring node has the surplus flow, determine that the adjacent node is a new active node, and put the new active node into a management active In the data structure of the node.
  • the processor 41 is further configured to: when the pre-streaming is performed in parallel by the at least two algorithms, obtain the number of edges that are re-identified, and obtain an update parameter according to the algorithm template, where the update parameter is determined and When the number of the re-identified edges meets the preset condition, the distance identifiers of all the nodes to the sink point are updated to obtain a new distance identifier of all the nodes to the sink point, and the second distance identifier is obtained according to the new distance identifier. Residual network.
  • the processor 41 is further configured to: when there is no active node in the data structure of the management active node, determine that the traffic of the sink is the maximum flow of the network.
  • the processor 41 is further configured to: obtain a total number of threads, and configure, according to the total number of threads, a number of threads corresponding to at least two algorithms, where the at least two algorithms are used according to the first residual network The corresponding number of threads is pre-flowed in parallel.
  • the number of threads includes a ratio of the total number of threads to the number of algorithms of the at least two algorithms
  • the processor 41 is further configured to reconfigure the number of threads for the at least two algorithms according to the number of the critical edges.

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Signal Processing (AREA)
  • Economics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Human Resources & Organizations (AREA)
  • Strategic Management (AREA)
  • Marketing (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Game Theory and Decision Science (AREA)
  • Development Economics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

Embodiments of the present invention provide a method and a device for selecting optimal network maximum flow algorithm, and relates to the field of network maximum flows, which can determine an optimal network maximum flow algorithm according to different network flow graphs. The method comprises: an algorithm selecting device acquiring a network flow graph, and obtaining a first residual network according to the network flow graph; acquiring an operation algorithm set, the operation algorithm set comprising at least two algorithms; performing preflow push concurrently in the first residual network by using at least two algorithms, to obtain a second residual network, determining, in the second residual network, a quantity of pivotal edges corresponding to the at least two algorithms, and determining that an algorithm corresponding to the maximum value of the quantity of pivotal edges, as an optimal network maximum flow algorithm of the network flow graph. The embodiments of the present invention are used for selecting a network maximum flow algorithm.

Description

一种最优网络最大流算法的选择方法和设备  Method and device for selecting optimal network maximum flow algorithm
技术领域 本发明涉及网络最大流领域, 尤其涉及一种最优网络最大流算法的选 择方法和设备。 背景技术 获取网络最大流问题是图论和组合优化中的经典问题, 它具有广泛 的应用背景。 TECHNICAL FIELD The present invention relates to the field of network maximum flow, and in particular, to a method and device for selecting an optimal network maximum stream algorithm. BACKGROUND OF THE INVENTION Acquiring the maximum flow problem of a network is a classic problem in graph theory and combinatorial optimization, and it has a wide application background.
现有技术中, 预流推进方法是一种常用的获取网络最大流的方法, 该方法包括多种算法, 这些算法可以归纳为:根据获取的网络流图得到残 量网络, 从残量网络中获取活跃结点, 并在该残量网络中将活跃结点对 应的盈余流通过相邻结点向汇点进行推进, 并在确定该相邻结点为新的 活跃结点后, 继续在该残量网络将该新的活跃结点通过相邻结点向汇点 进行推进, 直至该残量网络中不存在活跃结点, 则确定此时汇点的流量 为网络最大流。  In the prior art, the pre-flow propulsion method is a commonly used method for obtaining a maximum flow of a network, and the method includes multiple algorithms, which can be summarized as: obtaining a residual network according to the acquired network flow graph, from the residual network Obtaining an active node, and in the residual network, the surplus stream corresponding to the active node is advanced to the sink point through the adjacent node, and after determining that the adjacent node is a new active node, continuing in the The residual network pushes the new active node to the sink point through the adjacent node until the active node does not exist in the residual network, and then determines that the traffic of the sink point is the maximum flow of the network.
由上可知, 在现有的通过预流推进方法获取网络最大流的过程中, 只是通过一种算法对网络流图进行预流推进, 也就是说, 无论获取的网 络流图是哪种类型 (例如可以是非平衡的二分图) , 都通过一种算法进 行计算, 但是, 对于不同类型的网络流图, 该算法对网络最大流的计算 并不一定是最优的, 由于不适应这个网络流图的算法冗余操作多, 因此 无法保证该算法对网络流图的算法性能 (如运算时间和运算效率等) , 从而降低了网络最大流计算的效率。 发明内容 本发明的实施例提供一种最优网络最大流算法的选择方法和设备, 能够根据不同的网络流图确定最优的网络最大流算法。  It can be seen from the above that in the process of obtaining the maximum flow of the network by the pre-flow advancement method, only the network flow graph is pre-flowed by an algorithm, that is, regardless of the type of the network flow graph acquired ( For example, it can be an unbalanced bipartite graph), which is calculated by an algorithm. However, for different types of network flow graphs, the calculation of the maximum flow of the algorithm is not necessarily optimal, because the network flow graph is not adapted. The algorithm has many redundant operations, so the algorithm performance of the algorithm on the network flow graph (such as operation time and computational efficiency) cannot be guaranteed, thereby reducing the efficiency of the network maximum stream calculation. SUMMARY OF THE INVENTION Embodiments of the present invention provide a method and a device for selecting an optimal network maximum flow algorithm, which are capable of determining an optimal network maximum flow algorithm according to different network flow graphs.
为达到上述目的, 本发明的实施例釆用如下技术方案:  In order to achieve the above object, embodiments of the present invention use the following technical solutions:
第一方面, 提供一种最优网络最大流算法的选择方法, 包括: 获取网络流图, 并根据所述网络流图得到第一残量网络; In a first aspect, a method for selecting an optimal network maximum flow algorithm is provided, including: Obtaining a network flow graph, and obtaining a first residual network according to the network flow graph;
获取操作算法集合, 其中, 所述操作算法集合包括至少两个算法; 在所述第一残量网络中通过所述至少两个算法并行进行预流推进, 得到第二残量网络, 并在所述第二残量网络中确定所述至少两个算法对 应的关键边的数量;  Obtaining a set of operation algorithms, where the set of operation algorithms includes at least two algorithms; performing pre-flow advancement in parallel by the at least two algorithms in the first residual network to obtain a second residual network, and Determining, in the second residual network, the number of key edges corresponding to the at least two algorithms;
确定所述关键边的数量的最大值对应的算法为所述网络流图的最优 网络最大流算法。  The algorithm corresponding to determining the maximum value of the number of key edges is an optimal network maximum flow algorithm of the network flow graph.
在第一方面第一种可能的实现方式中, 所述根据所述网络流图得到 第一残量网络后, 还包括:  In a first possible implementation manner of the first aspect, after the obtaining the first residual network according to the network flow graph, the method further includes:
根据所述第一残量网络获取活跃结点;  Obtaining an active node according to the first residual network;
所述获取操作算法集合包括:  The acquisition operation algorithm set includes:
根据算法模板获取所述活跃结点对应的算法和数据结构; 其中, 所 述算法模板包括用户配置的管理所述活跃结点的数据结构和用户配置的 对应所述活跃结点的算法以及所述网络流图的数据结构;  Acquiring an algorithm and a data structure corresponding to the active node according to the algorithm template, where the algorithm template includes a data structure configured by the user to manage the active node, and an algorithm configured by the user corresponding to the active node, and the algorithm The data structure of the network flow graph;
根据所述算法和数据结构获得所述操作算法集合。  The set of operational algorithms is obtained in accordance with the algorithm and data structure.
结合第一种可能的实现方式, 在第二种可能的实现方式中, 所述方 法还包括:  In conjunction with the first possible implementation, in a second possible implementation, the method further includes:
对所述网络流图的数据结构加细粒度锁。  Fine-grained locking of the data structure of the network flow graph.
结合第一种可能的实现方式或第二种可能的实现方式, 在第三种可 能的实现方式中, 所述在所述第一残量网络中通过所述至少两个算法并 行进行预流推进包括:  In combination with the first possible implementation manner or the second possible implementation manner, in a third possible implementation manner, the pre-flow advancement is performed in parallel by the at least two algorithms in the first residual network. Includes:
根据所述至少两个算法从所述管理活跃结点的数据结构中获取对应 的活跃结点;  Obtaining a corresponding active node from the data structure of the management active node according to the at least two algorithms;
根据所述至少两个算法并行将所述对应的活跃结点的盈余流通过距 离标识比自己低的相邻结点向汇点进行推进, 其中, 所述盈余流包括所 述活跃结点的入流量与出流量的正差值。  Performing, according to the at least two algorithms, the surplus stream of the corresponding active node in parallel to the sink point by using an adjacent node whose distance identifier is lower than itself, wherein the surplus stream includes the input of the active node The positive difference between the flow and the outgoing flow.
结合第三种可能的实现方式, 在第四种可能的实现方式中, 所述在 将所述对应的活跃结点的盈余流通过所述相邻结点向汇点进行推进后, 还包括:  With reference to the third possible implementation, in a fourth possible implementation, after the surplus flow of the corresponding active node is advanced to the sink point by using the adjacent node, the method further includes:
若所述相邻结点存在所述盈余流, 则确定所述相邻结点为新的活跃 结点, 并将所述新的活跃结点放入所述管理活跃结 , 的数据结构中。 结合第四种可能的实现方式, 在第五种可能的实现方式中, 在所述 得到第二残量网络前, 还包括: If the neighboring node has the surplus flow, determining that the adjacent node is new active a node, and placing the new active node in the data structure of the management active node. In combination with the fourth possible implementation manner, in the fifth possible implementation manner, before the obtaining the second residual network, the method further includes:
在通过所述至少两个算法并行进行预流推进时, 获取被重标识的边 数;  Obtaining the number of edges that are re-identified when the pre-flow advancement is performed in parallel by the at least two algorithms;
根据所述算法模板获取更新参数;  Obtaining an update parameter according to the algorithm template;
在确定所述更新参数和所述被重标识的边数满足预设条件时, 更新 所有结点到汇点的距离标识, 以得到所述所有结点到汇点的新的距离标 识;  And after determining that the update parameter and the number of re-identified edges satisfy a preset condition, updating a distance identifier of all nodes to the sink point to obtain a new distance identifier of all the nodes to the sink point;
所述得到第二残量网络包括:  The obtaining the second residual network includes:
根据所述所有结点到汇点的新的距离标识得到所述第二残量网络。 结合第四种可能的实现方式或第五种可能的实现方式, 在第六种可 能的实现方式中, 在确定所述管理活跃结点的数据结构不存在活跃结点 时, 则确定汇点的流量为所述网络最大流。  The second residual network is obtained according to the new distance identifier of all the nodes to the sink. In combination with the fourth possible implementation manner or the fifth possible implementation manner, in a sixth possible implementation manner, when determining that the data structure of the management active node does not have an active node, determining the sink point The traffic is the maximum flow of the network.
结合第一方面至第六种可能的实现方式中的任意一种可能的实现方 式, 在第七种可能的实现方式中, 所述在所述第一残量网络中通过所述 至少两个算法并行进行预流推进前, 所述方法还包括:  With reference to any one of the possible implementations of the first aspect to the sixth possible implementation, in a seventh possible implementation, the at least two algorithms are used in the first residual network Before the pre-flow advancement is performed in parallel, the method further includes:
获取总线程数;  Get the total number of threads;
根据所述总线程数配置对应所述至少两个算法的线程数, 其中, 所 述线程数包括所述总线程数与所述至少两个算法的算法数量的比值; 所述在所述第一残量网络中通过所述至少两个算法并行进行预流推 进包括:  Configuring a number of threads corresponding to the at least two algorithms according to the total number of threads, where the number of threads includes a ratio of the total number of threads to an algorithm number of the at least two algorithms; The pre-flow advancement in parallel in the residual network by the at least two algorithms includes:
在所述第一残量网络中通过所述至少两个算法根据所述对应的线程 数并行进行预流推进。  Pre-flow advancement is performed in parallel by the at least two algorithms according to the corresponding number of threads in the first residual network.
结合第七种可能的实现方式, 在第八种可能的实现方式中, 在确定 所述关键边的数量的最大值对应的算法为最优网络最大流算法后, 还包 括:  With reference to the seventh possible implementation manner, in the eighth possible implementation manner, after determining that the algorithm corresponding to the maximum value of the number of the critical edges is the optimal network maximum flow algorithm, the method further includes:
根据所述关键边的数量为所述至少两个算法重新配置线程数。  The number of threads is reconfigured for the at least two algorithms based on the number of key edges.
第二方面, 提供一种算法选择设备, 包括:  In a second aspect, an algorithm selection device is provided, including:
获取单元, 用于获取网络流图, 并根据所述网络流图得到第一残量 网络, 并获取操作算法集合, 其中, 所述操作算法集合包括至少两个算 法; An obtaining unit, configured to acquire a network flow graph, and obtain a first residual amount according to the network flow graph Networking, and acquiring a set of operational algorithms, where the set of operational algorithms includes at least two algorithms;
处理单元, 用于在所述第一残量网络中通过所述至少两个算法并行 进行预流推进, 得到第二残量网络, 并在预流推进后确定所述至少两个 算法对应的关键边的数量, 并在所述第二残量网络中确定所述关键边的 数量的最大值对应的算法为所述网络流图的最优网络最大流算法。  a processing unit, configured to perform pre-flow advancement in parallel by the at least two algorithms in the first residual network, to obtain a second residual network, and determine a key corresponding to the at least two algorithms after pre-flow advancement An algorithm corresponding to the number of edges and determining a maximum value of the number of key edges in the second residual network is an optimal network maximum flow algorithm of the network flow graph.
在第二方面第一种可能的实现方式中, 所述获取单元还用于, 根据 所述网络流图得到第一残量网络后, 根据所述第一残量网络获取活跃结 点;  In a first possible implementation manner of the second aspect, the acquiring unit is further configured to: after obtaining the first residual network according to the network flow graph, acquiring an active node according to the first residual network;
所述获取单元具体用于, 根据算法模板获取所述活跃结点对应的算 法和数据结构, 并根据所述算法和数据结构获得所述操作算法集合, 其 中, 所述算法模板包括用户配置的管理所述活跃结点的数据结构和用户 配置的对应所述活跃结点的算法以及所述网络流图的数据结构。  The acquiring unit is specifically configured to: acquire an algorithm and a data structure corresponding to the active node according to an algorithm template, and obtain the operation algorithm set according to the algorithm and the data structure, where the algorithm template includes user configured management The data structure of the active node and the user-configured algorithm corresponding to the active node and the data structure of the network flow graph.
结合第一种可能的实现方式, 在第二种可能的实现方式中, 所述处 理单元还用于, 对所述网络流图的数据结构加细粒度锁。  In conjunction with the first possible implementation, in a second possible implementation, the processing unit is further configured to add a fine-grained lock to the data structure of the network flow graph.
结合第一种可能的实现方式或第二种可能的实现方式, 在第三种可 能的实现方式中, 所述处理单元具体用于, 根据所述至少两个算法从所 述管理活跃结 ,、的数据结构中获取对应的活跃结点, 并根据所述至少两 个算法并行将所述对应的活跃结点的盈余流通过距离标识比自己低的相 邻结点向汇点进行推进, 其中, 所述盈余流包括所述活跃结点的入流量 与出流量的正差值。  In combination with the first possible implementation manner or the second possible implementation manner, in a third possible implementation manner, the processing unit is specifically configured to perform an active active node according to the at least two algorithms, Acquiring a corresponding active node in the data structure, and advancing the surplus stream of the corresponding active node in parallel with the neighboring node whose distance identifier is lower than itself according to the at least two algorithms, wherein The surplus stream includes a positive difference between the inflow and the outflow of the active node.
结合第三种可能的实现方式, 在第四种可能的实现方式中, 所述处 理单元还用于, 在将所述对应的活跃结点的盈余流通过所述相邻结点向 汇点进行推进后, 若所述相邻结点存在所述盈余流, 则确定所述相邻结 点为新的活跃结点, 并将所述新的活跃结点放入所述管理活跃结点的数 据结构中。  In conjunction with the third possible implementation, in a fourth possible implementation, the processing unit is further configured to: perform a surplus flow of the corresponding active node to the sink point by using the neighboring node After advancing, if the neighboring node has the surplus stream, determining that the adjacent node is a new active node, and placing the new active node into the data of the management active node In the structure.
结合第四种可能的实现方式, 在第五种可能的实现方式中, 所述处 理单元还用于, 在通过所述至少两个算法并行进行预流推进时, 获取被 重标识的边数, 根据所述算法模板获取更新参数, 并在确定所述更新参 数和所述被重标识的边数满足预设条件时, 更新所有结点到汇点的距离 标识, 以得到所述所有结点到汇点的新的距离标识, 并根据所述所有结 点到汇点的新的距离标识得到所述第二残量网络。 With reference to the fourth possible implementation, in a fifth possible implementation, the processing unit is further configured to: when the pre-flow advancement is performed in parallel by the at least two algorithms, obtain the number of edges that are re-identified, Obtaining an update parameter according to the algorithm template, and when determining that the update parameter and the number of re-identified edges satisfy a preset condition, updating a distance identifier of all nodes to the sink point to obtain all the nodes to The new distance identifier of the meeting point, and according to all the knots mentioned The new distance identification point to the sink point gets the second residual network.
结合第四种可能的实现方式或第五种可能的实现方式, 在第六种可 能的实现方式中, 所述处理单元还用于, 在确定所述管理活跃结点的数 据结构不存在活跃结点时, 则确定汇,、的流量为所述网络最大流。  In combination with the fourth possible implementation manner or the fifth possible implementation manner, in a sixth possible implementation manner, the processing unit is further configured to: when determining that the data structure of the management active node does not have an active node When the point is reached, it is determined that the traffic of the sink is the maximum flow of the network.
结合第二方面至第六种可能的实现方式中的任意一种可能的实现方 式, 在第七种可能的实现方式中, 所述获取单元还用于, 在所述第一残 量网络中通过所述至少两个算法并行进行预流推进前, 获取总线程数; 所述处理单元还用于, 配置对应所述至少两个算法的线程数, 并在 所述第一残量网络中通过所述至少两个算法根据所述对应的线程数并行 进行预流推进, 其中, 所述线程数包括所述总线程数与所述至少两个算 法的算法数量的比值。  With reference to any one of the possible implementations of the second aspect to the sixth possible implementation, in a seventh possible implementation, the acquiring unit is further configured to: pass in the first residual network Obtaining a total number of threads before the at least two algorithms perform the pre-flow advancement in parallel; the processing unit is further configured to: configure a number of threads corresponding to the at least two algorithms, and pass the network in the first residual network The at least two algorithms perform pre-flow advancement according to the corresponding number of threads, wherein the number of threads includes a ratio of the total number of threads to the number of algorithms of the at least two algorithms.
结合第七种可能的实现方式, 在第八种可能的实现方式中, 所述处 理单元还用于, 在确定所述关键边的数量的最大值对应的算法为最优网 络最大流算法后, 根据所述关键边的数量为所述至少两个算法重新配置 线程数。  With reference to the seventh possible implementation manner, in an eighth possible implementation, the processing unit is further configured to: after determining that the algorithm corresponding to the maximum value of the number of the critical edges is the optimal network maximum flow algorithm, The number of threads is reconfigured for the at least two algorithms based on the number of key edges.
釆用上述方案, 通过操作算法集合中的多种算法对网络流图进行预 流推进, 并在预流推进后, 将各算法对应的关键边的数量最多的算法确 定为最优网络最大流算法, 使得在获取网络最大流的计算过程中, 能够 动态调整自适应不同的网络流图, 得到最优性能的算法, 从而提高网络 最大流计算的效率。 附图说明 为了更清楚地说明本发明实施例的技术方案, 下面将对实施例描述 中所需要使用的附图作简单地介绍, 显而易见地, 下面描述中的附图仅 仅是本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创 造性劳动的前提下, 还可以根据这些附图获得其他的附图。  Using the above scheme, the network flow graph is pre-flowed by operating a plurality of algorithms in the algorithm set, and after the pre-flow advancement, the algorithm with the largest number of key edges corresponding to each algorithm is determined as the optimal network maximum flow algorithm. In the process of obtaining the maximum flow of the network, the adaptive network flow graph can be dynamically adjusted to obtain an optimal performance algorithm, thereby improving the efficiency of the network maximum flow calculation. BRIEF DESCRIPTION OF THE DRAWINGS In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some implementations of the present invention. For example, other drawings may be obtained from those of ordinary skill in the art in light of the inventive work.
图 1 为本发明实施例提供的一种最优网络最大流算法的选择方法的 流程示意图;  FIG. 1 is a schematic flowchart of a method for selecting an optimal network maximum flow algorithm according to an embodiment of the present invention;
图 2 为本发明实施例提供的另一种最优网络最大流算法的选择方法 的流程示意图; 图 3为本发明实施例提供的一种算法选择设备的结构示意图; 图 4为本发明实施例提供的另一种算法选择设备的结构示意图。 具体实施方式 下面将结合本发明实施例中的附图, 对本发明实施例中的技术方案 进行清楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明一部分实 施例, 而不是全部的实施例。 基于本发明中的实施例, 本领域普通技术 人员在没有作出创造性劳动前提下所获得的所有其他实施例, 都属于本 发明保护的范围。 FIG. 2 is a schematic flowchart diagram of another method for selecting an optimal network maximum flow algorithm according to an embodiment of the present invention; FIG. 3 is a schematic structural diagram of an algorithm selection device according to an embodiment of the present invention; FIG. 4 is a schematic structural diagram of another algorithm selection device according to an embodiment of the present invention. The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. example. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
发明实施例提供一种最优网络最大流算法的选择方法,如图 1所示, 该方法的执行主体为算法选择设备, 包括:  The embodiment of the invention provides a method for selecting an optimal network maximum flow algorithm. As shown in FIG. 1 , the execution subject of the method is an algorithm selection device, including:
S 101、 算法选择设备获取网络流图, 并根据该网络流图得到第一残 量网络。  S101. The algorithm selection device acquires a network flow graph, and obtains a first residual network according to the network flow graph.
其中, 该残量网络是通过对网络流图的变换得到的。  The residual network is obtained by transforming the network flow graph.
S 102 , 算法选择设备获取操作算法集合。  S102: The algorithm selection device acquires a set of operation algorithms.
其中, 该操作算法集合包括至少两个算法。  The set of operational algorithms includes at least two algorithms.
具体地, 该算法选择设备根据第一残量网络获取活跃结点, 其中, 活跃结点为入流量大于出流量的结点, 该算法选择设备根据算法模板获 取该活跃结点对应的算法和数据结构, 并根据该算法和数据结构获得该 操作算法集合。  Specifically, the algorithm selecting device acquires an active node according to the first residual network, where the active node is a node whose inbound traffic is greater than the outgoing traffic, and the algorithm selecting device acquires an algorithm and data corresponding to the active node according to the algorithm template. Structure, and the set of operational algorithms is obtained according to the algorithm and data structure.
其中, 该算法模板包括用户配置的管理活跃结点的数据结构和用户 配置的对应该活跃结点的算法以及该网络流图的数据结构。  The algorithm template includes a data structure configured by the user to manage the active node, an algorithm configured by the user corresponding to the active node, and a data structure of the network flow graph.
示例地, 该算法模板包括主控部分, 提供算法的框架; 算法部分, 可以由用户配置至少两个算法; 结点管理部分, 包括获取的活跃结点以 及用户配置的对应管理活跃结点的数据结构 (如 bucke t , F IFO- queue和 s tack中的任一种); 更新事件, 用于更新第一残量网络中各结点到汇点 的距离标识; 更新参数, 由用户进行配置; 网络流图数据结构, 用于存 放残量网络。  For example, the algorithm template includes a main control part, providing a framework of the algorithm; the algorithm part, the user may configure at least two algorithms; the node management part, including the acquired active node and the user-configured corresponding management active node data Structure (such as bucke t, F IFO-queue and s tack); update event, used to update the distance identifier of each node in the first residual network to the sink; update parameters, configured by the user; Network flow graph data structure for storing residual networks.
其中, 算法部分、 结点管理部分和更新参数可以由用户进行配置。 例如, 上述算法框架可以为: whi le (act i veV) { The algorithm part, the node management part and the update parameter can be configured by the user. For example, the above algorithm framework can be: Whi le (act i veV) {
i = workse t. remove ();  i = workse t. remove ();
ver tex. compute (i);  Ver tex. compute (i);
其中, activeV表示残量网络存在活跃结点的个数, while (activeV) 表示残量网络存在活跃结点的个数不为零时执行算法, i = workset. remove 0表示将该活跃结点从结点管理部分中取出, workset即 表示用户配置的对应管理活跃结点的数据结构; vertex, compute (i)表示 通过该活跃结点对应的算法对该活跃结点的盈余流进行运算。 Where activeV indicates the number of active nodes in the residual network, while (activeV) indicates that the number of active nodes in the residual network is not zero, the algorithm is executed, i = workset. remove 0 indicates that the active node is In the node management part, the workset represents the data structure of the corresponding active management node configured by the user; vertex, compute (i) indicates that the surplus stream of the active node is operated by the algorithm corresponding to the active node.
需要说明的是, 算法选择设备可以根据上述算法模板获取到由用户 配置的算法和数据结构, 并根据该算法和数据结构得到该操作算法集合, 该操作算法集合可以为:  It should be noted that the algorithm selection device may obtain an algorithm and a data structure configured by the user according to the foregoing algorithm template, and obtain the operation algorithm set according to the algorithm and the data structure, where the operation algorithm set may be:
workse t:: bucket (i->d);  Workse t:: bucket (i->d);
vertex, computel (node* i) { … workset. push ( j); } vertex. compute2 (node* i) { … }  Vertex, computel (node* i) { ... workset. push ( j); } vertex. compute2 (node* i) { ... }
GLOB_UPDT-FREQ = 0.5; GLOB_UPDT-FREQ = 0.5;
其中, workset:: bucket (i->d)表示用户配置的管理活跃结点的数据 结构; vertex, computel (node* i) { … workset. push ( j); }表示活跃 结点及对应的算法, GL0B_UPDT_FREQ = 0.5表示用户配置的更新参数。 通过上述操作算法集合可以实现多个算法并行运算。  Where workset:: bucket (i->d) represents the data structure of the user-managed active node; vertex, computel (node* i) { ... workset. push ( j); } indicates the active node and the corresponding algorithm , GL0B_UPDT_FREQ = 0.5 indicates the user-configured update parameters. Parallel operations of multiple algorithms can be implemented by the above set of operational algorithms.
进一步地, 算法选择设备可以对该网络流图的数据结构加细粒度锁, 从而防止数据竟争, 例如, 防止活跃结点对应算法之外的其它算法对该 活跃结点的读写操作。  Further, the algorithm selection device may fine-grain the data structure of the network flow graph to prevent data competition, for example, preventing other algorithms other than the active node corresponding algorithm from reading and writing the active node.
S103、 算法选择设备在该第一残量网络中通过该至少两个算法并行 进行预流推进, 得到第二残量网络, 并在所述第二残量网络中确定该至 少两个算法对应的关键边的数量。  S103. The algorithm selection device performs pre-flow advancement in parallel in the first residual network by using the at least two algorithms to obtain a second residual network, and determines, in the second residual network, the at least two algorithms. The number of key edges.
其中, 这里所说的并行是指在其中一个算法执行的过程中, 可以同 时执行另一个算法, 并不限定是在同一时刻开始执行。  Here, the parallelism refers to that another algorithm can be executed at the same time in the process of executing one of the algorithms, and is not limited to starting at the same time.
具体地, 算法选择设备根据该至少两个算法从该管理活跃结点的数 据结构中获取对应的活跃结点, 并根据该至少两个算法并行将该对应的 活跃结点的盈余流通过距离标识比自己低的相邻结点向汇点进行推进。 Specifically, the algorithm selects the number of active nodes from the management according to the at least two algorithms According to the structure, the corresponding active node is obtained, and the surplus stream of the corresponding active node is pushed in parallel to the sink point by the adjacent node whose distance identifier is lower than the self according to the at least two algorithms.
其中, 该盈余流包括该活跃结点的入流量与出流量的正差值。  The surplus flow includes a positive difference between the inflow and the outflow of the active node.
可选地, 若该相邻结点存在该盈余流, 则算法选择设备确定该相邻 结点为新的活跃结点, 并将该新的活跃结点放入该管理活跃结点的数据 结构中。  Optionally, if the neighboring node has the surplus stream, the algorithm selecting device determines that the neighboring node is a new active node, and places the new active node into the data structure of the managing active node. in.
进一步地, 算法选择设备在通过该至少两个算法并行进行预流推进 时, 获取被重标识的边数, 并根据该算法模板获取更新参数, 在确定该 更新参数和该被重标识的边数满足预设条件时, 更新所有结点到汇点的 距离标识, 以得到该所有结点到汇点的新的距离标识, 并根据该所有结 点到汇点的新的距离标识得到第二残量网络。  Further, when the pre-streaming advancement is performed in parallel by the at least two algorithms, the algorithm selecting device acquires the number of re-identified edges, and obtains an update parameter according to the algorithm template, and determines the update parameter and the number of the re-identified edges. When the preset condition is met, the distance identifiers of all nodes to the sink point are updated to obtain a new distance identifier of all the nodes to the sink point, and the second residue is obtained according to the new distance identifier of all the nodes to the sink point. Quantity network.
示例地, 算法选择设备在确定该被重标识的边数与该更新参数的乘 积大于网络流图的边数和结 , *、数的乘积时, 确定更新该新的活跃结 , *、的 流量, 算法选择设备具体可以由汇点进行反向宽度优先搜索实现对所有 结点到汇点距离标识的更新, 并在距离标识更新后, 根据更新后的距离 标识得到第二残量网络, 并在该第二残量网络中统计该至少两个算法对 应的关键边的数量。  For example, the algorithm selecting device determines to update the flow of the new active node, * when determining that the product of the number of re-identified edges and the update parameter is greater than the number of sides of the network flow graph and the product of the number, *, and number. The algorithm selection device may perform reverse width-first search by the sink point to update all the nodes to the sink point identifier, and after the distance identifier is updated, obtain the second residual network according to the updated distance identifier, and The number of key edges corresponding to the at least two algorithms is counted in the second residual network.
可选地, 算法选择设备在确定该管理活跃结,、的数据结构不存在活 跃结点时, 则确定汇点的流量为该网络最大流, 这样, 由于通过并行执 行该至少两个算法计算该网络流图, 加快了获取该网络最大流的速度, 从而提高了计算效率。  Optionally, the algorithm selecting device determines, when the data structure of the management active node does not have an active node, determining that the traffic of the sink is the maximum flow of the network, such that the at least two algorithms are calculated by executing the parallel algorithm in parallel. The network flow graph speeds up the acquisition of the maximum flow of the network, thereby improving the calculation efficiency.
进一步地, 算法选择设备在该第一残量网络中通过该至少两个算法 并行进行预流推进前, 获取总线程数, 并配置对应该至少两个算法的线 程数, 则算法选择设备在该第一残量网络中通过该至少两个算法根据该 对应的线程数并行进行预流推进。  Further, the algorithm selecting device acquires the total number of threads and performs the number of threads corresponding to at least two algorithms before the pre-streaming advancement by the at least two algorithms in the first residual network, and the algorithm selecting device is in the The pre-streaming advancement is performed in parallel by the at least two algorithms according to the corresponding number of threads in the first residual network.
其中, 该线程数包括该总线程数与该至少两个算法的算法数量的比 值, 也就是说, 算法选择设备为每个算法配置的线程数是相同的。  The number of threads includes a ratio of the total number of threads to the number of algorithms of the at least two algorithms, that is, the number of threads configured by the algorithm selection device for each algorithm is the same.
例如, 算法并行执行的代码可以是:  For example, the code that the algorithm executes in parallel can be:
pa ra l l e l - f or (the numbe r of a l gor i thms) {  Pa ra l l e l - f or (the numbe r of a l gor i thms) {
pa ra l l e l - f or (thread- grou [ i ] ) {  Pa ra l l e l - f or (thread- grou [ i ] ) {
a 1 gor i thm_ i (); paral lel-f or (the number of a 1 gor i thms)并行执行所有算法, 其 中 , the number of algorithms 表 示 算 法 的 数 量 , paral lel_f or (thread— group [i] )执行算法 i, 其中, thread-group [i] 表示算法 i对应的线程组; algorithm_i ()表示算法 i。 a 1 gor i thm_ i (); Paral lel-f or (the number of a 1 gor i thms) executes all algorithms in parallel, where the number of algorithms represents the number of algorithms, paral lel_f or (thread_group [i] ) executes algorithm i, where thread- Group [i] represents the thread group corresponding to algorithm i; algorithm_i () represents algorithm i.
需要说明的是, 线程数越多, 则对应算法的运算时间越快, 运算效 率越高。  It should be noted that the more the number of threads, the faster the calculation time of the corresponding algorithm and the higher the computational efficiency.
S 104、 算法选择设备确定该关键边的数量的最大值对应的算法为该 网络流图的最优网络最大流算法。  S104. The algorithm that determines, by the algorithm selection device, the maximum value of the number of the critical edges is an optimal network maximum flow algorithm of the network flow graph.
具体地, 算法对应的关键边的数量越多, 则表明该算法的冗余操作 越少, 因此, 确定该算法为对应该网络流图的最优网络最大流算法。  Specifically, the more the number of key edges corresponding to the algorithm, the less redundant operation of the algorithm. Therefore, the algorithm is determined to be the optimal network maximum flow algorithm corresponding to the network flow graph.
进一步地, 算法选择设备在确定该关键边的数量的最大值对应的算 法为最优网络最大流算法后, 根据该关键边的数量为该至少两个算法重 新配置线程数。  Further, after the algorithm corresponding to determining the maximum value of the number of key edges is the optimal network maximum flow algorithm, the algorithm selects the number of threads for the at least two algorithms according to the number of the key edges.
具体地, 在确定最优网络最大流算法后, 则为该最优网络最大流分 配更多的线程, 从而使得该算法在运算的过程中, 减少运算时间, 提高 运算效率, 从而提高该算法的算法性能。  Specifically, after determining the optimal network maximum flow algorithm, more threads are allocated for the optimal network maximum flow, so that the algorithm reduces computation time and improves computation efficiency in the operation process, thereby improving the algorithm. Algorithm performance.
釆用上述执行主体为算法选择设备的方案, 算法选择设备通过操作 算法集合中的多种算法对网络流图进行预流推进, 并在预流推进后, 将 各算法对应的关键边的数量最多的算法确定为最优网络最大流算法, 使 得在获取网络最大流的计算过程中, 能够动态调整自适应不同的网络流 图, 得到最优性能的算法, 从而提高网络最大流计算的效率。  上述 Using the above-mentioned execution subject as an algorithm to select a device, the algorithm selection device pre-flows the network flow graph by operating multiple algorithms in the algorithm set, and after the pre-flow advancement, the number of key edges corresponding to each algorithm is the largest. The algorithm is determined as the optimal network maximum flow algorithm, so that in the process of obtaining the maximum flow of the network, the adaptive different network flow graphs can be dynamically adjusted to obtain an optimal performance algorithm, thereby improving the efficiency of the network maximum flow calculation.
本发明实施例提供一种最优网络最大流算法的选择方法, 如图 2 所 示, 包括: An embodiment of the present invention provides a method for selecting an optimal network maximum flow algorithm, as shown in FIG. 2, including:
S20 算法选择设备获取网络流图, 并根据该网络流图得到第一残 量网络。  The S20 algorithm selects a device to obtain a network flow graph, and obtains a first residual network according to the network flow graph.
其中, 该残量网络是通过对网络流图的变换得到的。  The residual network is obtained by transforming the network flow graph.
S 202、 算法选择设备根据该第一残量网络获取活跃结点。  S202. The algorithm selection device acquires an active node according to the first residual network.
S203、 算法选择设备根据算法模板获取该活跃结点对应的算法和数 据结构, 并对该网络流图的数据结构加细粒度锁。 其中, 活跃结点为入流量大于出流量的结点, 该算法模板包括该用 户配置的管理活跃结点的数据结构和用户配置的对应该活跃结点的算法 以及该网络流图的数据结构。 S203. The algorithm selection device acquires an algorithm and a data structure corresponding to the active node according to the algorithm template, and adds a fine-grained lock to the data structure of the network flow graph. The active node is a node whose inbound traffic is greater than the outgoing traffic. The algorithm template includes a data structure of the user-configured active active node and an algorithm configured by the user corresponding to the active node and a data structure of the network flow graph.
具体地, 该算法选择设备将获取到的活跃结点放入该管理活跃结点 的数据结构中。  Specifically, the algorithm selection device puts the acquired active node into the data structure of the management active node.
示例地, 该算法模板包括主控部分, 提供算法的框架; 算法部分, 可以由用户配置至少两个算法; 结点管理部分, 包括获取的活跃结点以 及用户配置的对应管理活跃结点的数据结构 (如 bucket, FIFO-queue和 stack中的任一种); 更新事件, 用于更新第一残量网络中各结点到汇点 的距离标识; 更新参数, 由用户进行配置; 网络流图数据结构, 用于存 放残量网络。  For example, the algorithm template includes a main control part, providing a framework of the algorithm; the algorithm part, the user may configure at least two algorithms; the node management part, including the acquired active node and the user-configured corresponding management active node data Structure (such as bucket, FIFO-queue, and stack); update event, used to update the distance identifier of each node in the first residual network to the sink; update parameters, configured by the user; network flow graph Data structure for storing residual networks.
其中, 算法部分、 结点管理部分和更新参数可以由用户进行配置。 例如, 上述算法框架可以为:  The algorithm part, the node management part and the update parameter can be configured by the user. For example, the above algorithm framework can be:
whi le (act i veV) {  Whi le (act i veV) {
i = workse t. remove ();  i = workse t. remove ();
ver tex. compute (i);  Ver tex. compute (i);
其中, activeV表示残量网络存在活跃结点的个数, while (activeV) 表示残量网络存在活跃结点的个数不为零时执行算法, i = workset. remove ()表示将该活跃结点从结点管理部分中取出, workset即 表示用户配置的对应管理活跃结点的数据结构; vertex, compute (i)表示 通过该活跃结点对应的算法对该活跃结点的盈余流进行运算。 Where activeV indicates the number of active nodes in the residual network, while (activeV) indicates that the number of active nodes in the residual network is not zero, the algorithm is executed, i = workset. remove () indicates that the active node Extracted from the node management part, the workset represents the data structure corresponding to the management active node configured by the user; vertex, compute (i) indicates that the surplus stream of the active node is operated by the algorithm corresponding to the active node.
需要说明的是, 算法选择设备可以根据上述算法模板获取到由用户 配置的算法和数据结构, 并根据该算法和数据结构得到该操作算法集合, 该操作算法集合可以为:  It should be noted that the algorithm selection device may obtain an algorithm and a data structure configured by the user according to the foregoing algorithm template, and obtain the operation algorithm set according to the algorithm and the data structure, where the operation algorithm set may be:
workse t:: bucket (i->d);  Workse t:: bucket (i->d);
vertex, computel (node* i) { … workset. push ( j); } vertex. compute2 (node* i) { … }  Vertex, computel (node* i) { ... workset. push ( j); } vertex. compute2 (node* i) { ... }
GLOB_UPDT-FREQ = 0.5; 其中, workset:: bucket (i->d)表示用户配置的管理活跃结点的数据 结构; vertex, computel (node* i) { … workset. push ( j); }表示活跃 结点及对应的算法, GLOB_UPDT_FREQ = 0.5表示用户配置的更新参数。 通过上述操作算法集合可以实现多个算法并行运算。 GLOB_UPDT-FREQ = 0.5; Where workset:: bucket (i->d) represents the data structure of the user-managed active node; vertex, computel (node* i) { ... workset. push ( j); } indicates the active node and the corresponding algorithm , GLOB_UPDT_FREQ = 0.5 indicates the user-configured update parameters. Parallel operations of multiple algorithms can be implemented by the above set of operational algorithms.
S 204、 算法选择设备根据该算法和数据结构获得该操作算法集合。 其中, 该操作算法集合包括至少两个算法。  S204. The algorithm selection device obtains the operation algorithm set according to the algorithm and the data structure. The set of operational algorithms includes at least two algorithms.
S 205、 算法选择设备根据该至少两个算法从该管理活跃结,、的数据 结构中获取对应的活跃结点。  S 205. The algorithm selection device acquires a corresponding active node from the data structure of the management active node according to the at least two algorithms.
5206、 算法选择设备获取总线程数, 并根据该总线程数配置对应该 至少两个算法的线程数。  5206. The algorithm selects a device to obtain a total number of threads, and configures a number of threads corresponding to at least two algorithms according to the total number of threads.
其中, 该线程数包括该总线程数与该至少两个算法的算法数量的比 值。  The number of threads includes a ratio of the total number of threads to the number of algorithms of the at least two algorithms.
需要说明的是, 线程数越多, 则对应算法的运算时间越快, 运算效 率越高。  It should be noted that the more the number of threads, the faster the calculation time of the corresponding algorithm and the higher the computational efficiency.
5207、 算法选择设备在该第一残量网络中通过该至少两个算法根据 该对应的线程数并行进行预流推进。  S207. The algorithm selection device performs pre-flow advancement in parallel according to the corresponding number of threads in the first residual network by using the at least two algorithms.
其中, 该盈余流包括该活跃结点的入流量与出流量的正差值。  The surplus flow includes a positive difference between the inflow and the outflow of the active node.
例如, 算法并行执行的代码可以是:  For example, the code that the algorithm executes in parallel can be:
paral lel-f or (the number of algorithms) {  Paral lel-f or (the number of algorithms) {
parallel-for (thread- grou [i] ) {  Parallel-for (thread- grou [i] ) {
a 1 gor i thm_ i ();  a 1 gor i thm_ i ();
paral lel-f or (the number of a 1 gor i thms)并行执行所有算法, 其 中 , the number of algorithms 表 示 算 法 的 数 量 , paral lel_f or (thread— group [i] )执行算法 i, 其中, thread-group [i] 表示算法 i对应的线程组; algorithm_i ()表示算法 i。 Paral lel-f or (the number of a 1 gor i thms) executes all algorithms in parallel, where the number of algorithms represents the number of algorithms, paral lel_f or (thread_group [i] ) executes algorithm i, where thread- Group [i] represents the thread group corresponding to algorithm i; algorithm_i () represents algorithm i.
S208、 在预流推进后, 若该活跃结点的相邻结点存在盈余流, 则算 法选择设备确定该相邻结点为新的活跃结点, 并将该新的活跃结点放入 该管理活跃结 ,、的数据结构中。  S208. After the pre-flow advancement, if there is a surplus flow in the adjacent node of the active node, the algorithm selecting device determines that the adjacent node is a new active node, and puts the new active node into the Manage active nodes, in the data structure.
S 209、 算法选择设备在通过该至少两个算法并行进行预流推进时, 获取被重标识的边数, 并根据该算法模板获取更新参数。 需要说明的是, 若算法选择设备在进行预流推进后, 确定管理活跃 结点的数据结构中不存在活跃结点, 则确定汇点的流量为网络最大流, 这样, 由于通过并行执行该至少两个算法计算该网络流图, 加快了获取 该网络最大流的速度, 从而提高了计算效率。 S 209. The algorithm selection device acquires the number of edges that are re-identified when the pre-flow advancement is performed in parallel by the at least two algorithms, and acquires the update parameter according to the algorithm template. It should be noted that, if the algorithm selection device determines that there is no active node in the data structure of the active node after performing the pre-flow advancement, it determines that the traffic of the sink point is the maximum flow of the network, so that the at least The two algorithms calculate the network flow graph, which speeds up the acquisition of the maximum flow of the network, thereby improving the calculation efficiency.
S 21 0、 算法选择设备在确定该更新参数和该被重标识的边数满足预 设条件时, 更新所有结点到汇点的距离标识, 以得到该所有结点到汇点 的新的 巨离标识。  S 21 0. The algorithm selecting device updates the distance identifiers of all the nodes to the sink point when determining that the update parameter and the number of the re-identified edges meet the preset condition, to obtain a new giant of all the nodes to the sink point. Off the logo.
示例地, 算法选择设备在确定该被重标识的边数与该更新参数的乘 积大于网络流图的边数和结点数的乘积时, 确定更新所有结点到汇点的 距离标识, 算法选择设备具体可以由汇点进行反向宽度优先搜索实现对 所有结点到汇点的距离标识更新, 并在距离标识更新后, 根据更新后的 距离标识得到第二残量网络, 并在该第二残量网络中统计该至少两个算 法对应的关键边的数量。  For example, when determining that the product of the number of re-identified edges and the update parameter is greater than the product of the number of edges and the number of nodes of the network flow graph, the algorithm selecting device determines to update the distance identifier of all the nodes to the sink point, and the algorithm selecting device Specifically, the sinker performs reverse width priority search to update the distance identifier of all nodes to the sink point, and after the distance identifier is updated, obtains the second residual network according to the updated distance identifier, and in the second residual The number of key edges corresponding to the at least two algorithms is counted in the quantity network.
S 21 1、 算法选择设备根据该新的距离标识得到该第二残量网络。 S 21 2、 算法选择设备在该第二残量网络中确定该至少两个算法对应 的关键边的数量。  S 21 1. The algorithm selection device obtains the second residual network according to the new distance identifier. S 21 2. The algorithm selection device determines the number of key edges corresponding to the at least two algorithms in the second residual network.
S 21 3、 算法选择设备确定该关键边的数量的最大值对应的算法为该 网络流图的最优网络最大流算法。  S 21 3. The algorithm that determines the maximum value of the number of key edges by the algorithm selection device is an optimal network maximum flow algorithm of the network flow graph.
S 214、 算法选择设备为该最优网络最大流算法重新配置线程数。 具体地, 在确定最优网络最大流算法后, 则为该最优网络最大流分 配更多的线程, 从而使得该算法在运算的过程中, 减少运算时间, 提高 运算效率, 从而提高该算法的算法性能。  S214. The algorithm selection device reconfigures the number of threads for the optimal network maximum flow algorithm. Specifically, after determining the optimal network maximum flow algorithm, more threads are allocated for the optimal network maximum flow, so that the algorithm reduces computation time and improves computation efficiency in the operation process, thereby improving the algorithm. Algorithm performance.
釆用上述方案, 使得在获取网络最大流的计算过程中, 能够动态调 整自适应不同的网络流图, 得到最优性能的算法, 从而提高网络最大流 计算的效率。  The above scheme is adopted, so that in the process of obtaining the maximum flow of the network, the adaptive network flow graph can be dynamically adjusted to obtain an optimal performance algorithm, thereby improving the efficiency of the network maximum stream calculation.
需要说明的是, 对于上述方法实施例, 为了简单描述, 故将其都表 述为一系列的动作组合, 但是本领域技术人员应该知悉, 本发明并不受 所描述的动作顺序的限制, 其次, 本领域技术人员也应该知悉, 说明书 中所描述的实施例均属于优选实施例, 所涉及的动作和模块并不一定是 本发明所必须的。 本发明实施例提供一种算法选择设备 30 , 如图 3所示, 包括: 获取单元 31, 用于获取网络流图, 并根据该网络流图得到第一残量 网络, 并获取操作算法集合。 It should be noted that, for the above method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should understand that the present invention is not limited by the described action sequence. Those skilled in the art should also appreciate that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention. An embodiment of the present invention provides an algorithm selection device 30, as shown in FIG. 3, including: The obtaining unit 31 is configured to obtain a network flow graph, obtain a first residual network according to the network flow graph, and obtain a set of operation algorithms.
其中, 该残量网络是通过对网络流图的变换得到的, 该操作算法集 合包括至少两个算法。  The residual network is obtained by transforming a network flow graph, and the operational algorithm set includes at least two algorithms.
处理单元 32, 用于在该第一残量网络中通过该至少两个算法并行进 行预流推进, 得到第二残量网络, 并在预流推进后确定该至少两个算法 对应的关键边的数量, 并在所述第二残量网络中确定该关键边的数量的 最大值对应的算法为该网络流图的最优网络最大流算法。  The processing unit 32 is configured to perform pre-flow advancement in parallel by the at least two algorithms in the first residual network to obtain a second residual network, and determine a key edge corresponding to the at least two algorithms after the pre-flow advancement The algorithm corresponding to the quantity, and determining the maximum value of the number of key edges in the second residual network is the optimal network maximum flow algorithm of the network flow graph.
进一步地, 该获取单元 31还用于, 根据该网络流图得到第一残量网 络后, 根据该第一残量网络获取活跃结点。  Further, the acquiring unit 31 is further configured to obtain an active node according to the first residual network after obtaining the first residual network according to the network flow graph.
具体地, 该获取单元 31将获取到的活跃结点放入该管理活跃结点的 数据结构中。  Specifically, the obtaining unit 31 puts the acquired active node into the data structure of the management active node.
该获取单元 31具体用于, 根据算法模板获取该活跃结点对应的算法 和数据结构, 并根据该算法和数据结构获得该操作算法集合, 其中, 该 算法模板包括用户配置的管理活跃结点的数据结构和用户配置的对应该 活跃结点的算法以及该网络流图的数据结构。  The acquiring unit 31 is configured to obtain an algorithm and a data structure corresponding to the active node according to the algorithm template, and obtain the operation algorithm set according to the algorithm and the data structure, where the algorithm template includes a user-configured active node. The data structure and the user-configured algorithm corresponding to the active node and the data structure of the network flow graph.
示例地, 该算法模板包括主控部分, 提供算法的框架; 算法部分, 可以由用户配置至少两个算法; 结点管理部分, 包括获取的活跃结点以 及用户配置的对应管理活跃结点的数据结构 (如 bucket, FIFO-queue和 stack中的任一种); 更新事件, 用于更新第一残量网络中各结点的距离 标识; 更新参数, 由用户进行配置, 网络流图数据结构, 用于存放残量 网络。  For example, the algorithm template includes a main control part, providing a framework of the algorithm; the algorithm part, the user may configure at least two algorithms; the node management part, including the acquired active node and the user-configured corresponding management active node data Structure (such as bucket, FIFO-queue, and stack); update event, used to update the distance identifier of each node in the first residual network; update parameters, configured by the user, network flow graph data structure, Used to store residual networks.
其中, 算法部分、 结点管理部分和更新参数可以由用户进行配置。 例如, 上述算法框架可以为:  The algorithm part, the node management part and the update parameter can be configured by the user. For example, the above algorithm framework can be:
whi le (act iveV) {  Whi le (act iveV) {
i = workse t. remove ();  i = workse t. remove ();
ver tex. compute (i); 其中, act iveV表示残量网络存在活跃结点的个数, while (activeV) 表示残量网络存在活跃结点的个数不为零时执行算法, i = workset. remove 0表示将该活跃结点从结点管理部分中取出, workset即 表示用户配置的对应管理活跃结点的数据结构; vertex, compute (i)表示 通过该活跃结点对应的算法对该活跃结点的盈余流进行运算。 Ver tex. compute (i); where act iveV indicates the number of active nodes in the residual network, while (activeV) indicates that the number of active nodes in the residual network is not zero, the algorithm is executed, i = workset. Remove 0 means that the active node is taken out from the node management part, and the workset represents the data structure of the corresponding management active node configured by the user; vertex, compute (i) The surplus stream of the active node is operated by an algorithm corresponding to the active node.
需要说明的是, 该算法选择设备可以根据上述算法模板获取到由用 户配置的算法和数据结构, 并根据该算法和数据结构得到该操作算法集 合, 该操作算法集合可以为:  It should be noted that the algorithm selection device may obtain an algorithm and a data structure configured by the user according to the foregoing algorithm template, and obtain the operation algorithm set according to the algorithm and the data structure, where the operation algorithm set may be:
workse t:: bucket (i->d);  Workse t:: bucket (i->d);
vertex, computel (node* i) { … workset. push ( j); } vertex. compute2 (node* i) { … }  Vertex, computel (node* i) { ... workset. push ( j); } vertex. compute2 (node* i) { ... }
GLOB_UPDT-FREQ = 0.5; GLOB_UPDT-FREQ = 0.5;
其中, workset: : bucket (i->d)表示用户配置的管理活跃结点的数据 结构; vertex, computel (node* i) { … workset. push ( j); }表示活跃 结点及对应的算法, GL0B_UPDT_FREQ = 0.5表示用户配置的更新参数。 通过上述操作算法集合可以实现多个算法并行运算。  Where workset: : bucket (i->d) represents the data structure of the user-managed active node; vertex, computel (node* i) { ... workset. push ( j); } indicates the active node and the corresponding algorithm , GL0B_UPDT_FREQ = 0.5 indicates the user-configured update parameters. Parallel operations of multiple algorithms can be implemented by the above set of operational algorithms.
进一步地, 该处理单元 32还用于, 对网络流图的数据结构加细粒度 锁, 从而防止数据竟争, 例如, 防止活跃结点对应算法之外的其它算法 对该活跃结点的读写操作。  Further, the processing unit 32 is further configured to: fine-grain the data structure of the network flow graph to prevent data competition, for example, prevent other algorithms other than the active node corresponding algorithm from reading and writing the active node. operating.
可选的, 处理单元 32具体用于, 根据该至少两个算法从该管理活跃 结点的数据结构中获取对应的活跃结点, 并根据该至少两个算法并行将 该对应的活跃结点的盈余流通过相邻结点向汇点进行推进。  Optionally, the processing unit 32 is configured to: obtain, according to the at least two algorithms, a corresponding active node from the data structure of the active node, and perform the corresponding active node in parallel according to the at least two algorithms. The surplus flow advances to the meeting point through adjacent nodes.
其中, 该盈余流包括该活跃结点的入流量与出流量的正差值。  The surplus flow includes a positive difference between the inflow and the outflow of the active node.
需要说明的是, 这里所说的并行是指在其中一个算法执行的过程中, 可以同时执行另一个算法, 并不限定是在同一时刻开始执行。  It should be noted that the parallelism mentioned here means that in the process of executing one of the algorithms, another algorithm can be executed at the same time, and it is not limited to start execution at the same time.
进一步的, 该处理单元还用于, 在将该对应的活跃结点的盈余流通 过距离标识比自己低的相邻结点向汇点进行推进后, 若该相邻结点存在 该盈余流, 则确定该相邻结点为新的活跃结点, 并将该新的活跃结点放 入该管理活跃结点的数据结构中。  Further, the processing unit is further configured to: after the surplus stream of the corresponding active node is advanced to the sink point by using an adjacent node whose distance identifier is lower than itself, if the neighboring node has the surplus flow, Then, the adjacent node is determined to be a new active node, and the new active node is placed in the data structure of the management active node.
该获取单元 31还用于, 在该第一残量网络中通过该至少两个算法并 行进行预流推进前, 获取总线程数, 并且该处理单元根据该总线程数配 置对应该至少两个算法的线程数, 并在该第一残量网络中通过该至少两 个算法根据该对应的线程数并行进行预流推进。  The obtaining unit 31 is further configured to: before the pre-streaming advancement by the at least two algorithms in the first residual network, obtain a total number of threads, and the processing unit configures at least two algorithms according to the total number of threads. The number of threads, and pre-flow advancement in parallel by the at least two algorithms according to the corresponding number of threads in the first residual network.
其中, 该线程数包括该总线程数与该至少两个算法的算法数量的比 值, 也就是说, 该算法选择设备为每个算法配置的线程数是相同的。 例如, 算法并行执行的代码可以是: The number of threads includes a ratio of the total number of threads to the number of algorithms of the at least two algorithms, that is, the number of threads configured by the algorithm selection device for each algorithm is the same. For example, the code that the algorithm executes in parallel can be:
paral lel-f or (the number of algorithms) {  Paral lel-f or (the number of algorithms) {
parallel-for (thread- grou [i] ) {  Parallel-for (thread- grou [i] ) {
a 1 gor i thm_ i ();  a 1 gor i thm_ i ();
paral lel-f or (the number of a 1 gor i thms)并行执行所有算法, 其 中 , the number of algorithms 表 示 算 法 的 数 量 , paral lel_f or (thread— group [i] )执行算法 i, 其中, thread-group [i] 表示算法 i对应的线程组; algorithm_i ()表示算法 i。 Paral lel-f or (the number of a 1 gor i thms) executes all algorithms in parallel, where the number of algorithms represents the number of algorithms, paral lel_f or (thread_group [i] ) executes algorithm i, where thread- Group [i] represents the thread group corresponding to algorithm i; algorithm_i () represents algorithm i.
需要说明的是, 线程数越多, 则对应算法的运算时间越快, 运算效 率越高。  It should be noted that the more the number of threads, the faster the calculation time of the corresponding algorithm and the higher the computational efficiency.
可选地, 该处理单元 32还用于, 在通过所述至少两个算法并行进行 预流推进时, 获取被重标识的边数, 根据该算法模板获取更新参数, 并 在确定该更新参数和该被重标识的边数满足预设条件时, 更新所有结点 到汇点的距离标识, 以得到该所有结点到汇点的新的距离标识, 并根据 该新的距离标识得到该第二残量网络。  Optionally, the processing unit 32 is further configured to: when the pre-stream advancement is performed in parallel by the at least two algorithms, obtain the number of re-identified edges, obtain an update parameter according to the algorithm template, and determine the update parameter and When the number of the re-identified edges meets the preset condition, the distance identifiers of all the nodes to the sink point are updated to obtain a new distance identifier of all the nodes to the sink point, and the second distance identifier is obtained according to the new distance identifier. Residual network.
示例地, 算法选择设备在确定该被重标识的边数与该更新参数的乘 积大于网络流图的边数和结点数的乘积时, 确定更新所有结点到汇点的 距离标识, 算法选择设备具体可以由汇点进行反向宽度优先搜索实现对 所有结点到汇点的距离标识的更新, 并在距离更新后, 根据更新后的距 离标识得到第二残量网络, 并在该第二残量网络中统计该至少两个算法 对应的关键边的数量。  For example, when determining that the product of the number of re-identified edges and the update parameter is greater than the product of the number of edges and the number of nodes of the network flow graph, the algorithm selecting device determines to update the distance identifier of all the nodes to the sink point, and the algorithm selecting device Specifically, the sinking point performs reverse width first search to update the distance identifiers of all the nodes to the sink point, and after the distance is updated, obtains the second residual network according to the updated distance identifier, and in the second residual The number of key edges corresponding to the at least two algorithms is counted in the quantity network.
进一步地, 该处理单元 32还用于, 在确定该关键边的数量的最大值 对应的算法为最优网络最大流算法后, 根据该关键边的数量为该至少两 个算法重新配置线程数。  Further, the processing unit 32 is further configured to: after determining that the algorithm corresponding to the maximum value of the number of the critical edges is the optimal network maximum flow algorithm, reconfiguring the number of threads for the at least two algorithms according to the number of the critical edges.
具体地, 算法对应的关键边的数量越多, 则表明该算法的冗余操作 越少, 因此, 则确定该算法为对应该网络流图的最优网络最大流算法。  Specifically, the more the number of key edges corresponding to the algorithm, the less redundant operation of the algorithm. Therefore, the algorithm is determined to be the optimal network maximum flow algorithm corresponding to the network flow graph.
在确定最优网络最大流算法后, 则为该最优网络最大流分配更多的 线程, 从而使得该算法在运算的过程中, 减少运算时间, 提高运算效率, 从而提高该算法的算法性能。  After determining the optimal network maximum flow algorithm, more threads are allocated for the optimal network maximum flow, so that the algorithm reduces the operation time and improves the operation efficiency in the process of operation, thereby improving the algorithm performance of the algorithm.
可选地, 该获取单元 31还用于, 在确定该管理活跃结点的数据结构 中不存在活跃结点时, 则确定汇点的流量为该网络最大流, 这样, 由于 通过并行执行该至少两个算法计算该网络流图, 加快了获取该网络最大 流的速度, 从而提高了计算效率。 Optionally, the obtaining unit 31 is further configured to: determine a data structure of the active node in the management When there is no active node, the flow of the sink is determined to be the maximum flow of the network. Thus, since the network flow graph is calculated by executing the at least two algorithms in parallel, the speed of acquiring the maximum flow of the network is accelerated, thereby improving the speed. Computational efficiency.
釆用上述算法选择设备, 该算法选择设备通过操作算法集合中的多 种算法对网络流图进行预流推进, 并在预流推进后, 将各算法对应的关 键边的数量最多的算法确定为最优网络最大流算法, 使得在获取网络最 大流的计算过程中, 能够动态调整自适应不同的网络流图, 得到最优性 能的算法, 从而提高网络最大流计算的效率。 本发明提供一种算法选择设备 40 , 如图 4所示, 该算法选择设备 40 包括:  选择 Selecting the device by using the above algorithm, the algorithm selecting device performs pre-flow advancement of the network flow graph by using multiple algorithms in the algorithm set, and after the pre-flow advancement, determining the algorithm with the largest number of key edges corresponding to each algorithm as The optimal network maximum flow algorithm enables dynamic adaptation of different network flow graphs to obtain optimal performance algorithms in the process of obtaining the maximum flow of the network, thereby improving the efficiency of the network maximum flow calculation. The present invention provides an algorithm selection device 40. As shown in FIG. 4, the algorithm selection device 40 includes:
处理器 ( rocessor ) 41、 通信接口 ( Communications Interface ) 42、 存储器 (memory ) 43和通信总线 44 ; 其中, 所述处理器 41、 所述通信 接口 42和所述存储器 43通过所述通信总线 44完成相互间的通信。  a processor (Rocessor) 41, a communication interface (42), a memory 43 and a communication bus 44; wherein the processor 41, the communication interface 42, and the memory 43 are completed by the communication bus 44 Communication with each other.
处理器 41可能是一个多核中央处理器 CPU, 或者是特定集成电路 The processor 41 may be a multi-core CPU or a specific integrated circuit.
ASIC ( Application Specific Integrated Circuit ) , 或者是被配置成实施本 发明实施例的一个或多个集成电路。 An ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement embodiments of the present invention.
存储器 43用于存放程序代码, 所述程序代码包括计算机操作指令和 网络流图。 存储器 43可能包含高速 RAM存储器, 也可能还包括非易失 性存储器 ( non-volatile memory ) , 例如至少 "个磁盘存储 。  The memory 43 is for storing program code, and the program code includes computer operation instructions and a network flow diagram. Memory 43 may contain high speed RAM memory and may also include non-volatile memory, such as at least "disk storage."
所述通信接口 42 , 用于实现这些装置之间的连接通信。  The communication interface 42 is configured to implement connection communication between the devices.
所述处理器 41执行程序代码, 用于获取网络流图, 并根据该网络流 图得到第一残量网络, 获取操作算法集合, 在该第一残量网络中通过该 至少两个算法并行进行预流推进, 得到第二残量网络, 并在该第二残量 网络中确定该至少两个算法对应的关键边的数量, 并确定该关键边的数 量的最大值对应的算法为该网络流图的最优网络最大流算法。  The processor 41 executes program code for acquiring a network flow graph, and obtains a first residual network according to the network flow graph, and acquires an operation algorithm set, where the at least two algorithms are performed in parallel in the first residual network. Pre-flow advancement, obtaining a second residual network, and determining the number of key edges corresponding to the at least two algorithms in the second residual network, and determining that the maximum value of the number of key edges corresponds to the network flow The optimal network maximum flow algorithm for the graph.
其中, 该操作算法集合包括至少两个算法。  The set of operational algorithms includes at least two algorithms.
可选地, 该处理器 41还用于, 根据该第一残量网络获取活跃结点, 并根据算法模板获取该活跃结点对应的算法和数据结构, 并根据该算法 和数据结构获得该操作算法集合。  Optionally, the processor 41 is further configured to: acquire an active node according to the first residual network, acquire an algorithm and a data structure corresponding to the active node according to the algorithm template, and obtain the operation according to the algorithm and the data structure. Algorithm set.
其中, 该算法模板包括用户配置的管理活跃结点的数据结构和用户 配置的对应该活跃结点的算法以及该网络流图的数据结构。 可选地,该处理器 41还用于,对该网络流图的数据结构加细粒度锁。 可选地, 该处理器 41具体用于, 根据该至少两个算法从该管理活跃 结点的数据结构中获取对应的活跃结点, 并根据该至少两个算法并行将 该对应的活跃结点的盈余流通过相邻结点向汇点进行推进。 The algorithm template includes a data structure configured by the user to manage the active node, an algorithm configured by the user corresponding to the active node, and a data structure of the network flow graph. Optionally, the processor 41 is further configured to add a fine-grained lock to the data structure of the network flow graph. Optionally, the processor 41 is configured to: obtain, according to the at least two algorithms, a corresponding active node from a data structure of the active node, and perform the corresponding active node in parallel according to the at least two algorithms. The surplus flow advances to the meeting point through adjacent nodes.
其中, 该盈余流包括该活跃结点的入流量与出流量的正差值。  The surplus flow includes a positive difference between the inflow and the outflow of the active node.
可选地, 该处理器 41具体用于, 若该相邻结点存在该盈余流, 则确 定该相邻结点为新的活跃结点, 并将该新的活跃结点该放入管理活跃结 点的数据结构中。  Optionally, the processor 41 is specifically configured to: if the neighboring node has the surplus flow, determine that the adjacent node is a new active node, and put the new active node into a management active In the data structure of the node.
可选地, 该处理器 41还用于, 在通过所述至少两个算法并行进行预 流推进时, 获取被重标识的边数, 并根据该算法模板获取更新参数, 在 确定该更新参数和该被重标识的边数满足预设条件时, 更新所有结点到 汇点的距离标识, 以得到该所有结点到汇点的新的距离标识, 并根据该 新的距离标识得到该第二残量网络。  Optionally, the processor 41 is further configured to: when the pre-streaming is performed in parallel by the at least two algorithms, obtain the number of edges that are re-identified, and obtain an update parameter according to the algorithm template, where the update parameter is determined and When the number of the re-identified edges meets the preset condition, the distance identifiers of all the nodes to the sink point are updated to obtain a new distance identifier of all the nodes to the sink point, and the second distance identifier is obtained according to the new distance identifier. Residual network.
可选地, 该处理器 41还用于, 在确定该管理活跃结点的数据结构中 不存在活跃结点时, 则确定汇点的流量为该网络最大流。  Optionally, the processor 41 is further configured to: when there is no active node in the data structure of the management active node, determine that the traffic of the sink is the maximum flow of the network.
可选地, 该处理器 41还用于, 获取总线程数, 并根据该总线程数配 置对应该至少两个算法的线程数, 在该第一残量网络中通过该至少两个 算法根据该对应的线程数并行进行预流推进。  Optionally, the processor 41 is further configured to: obtain a total number of threads, and configure, according to the total number of threads, a number of threads corresponding to at least two algorithms, where the at least two algorithms are used according to the first residual network The corresponding number of threads is pre-flowed in parallel.
其中, 该线程数包括该总线程数与该至少两个算法的算法数量的比 值;  The number of threads includes a ratio of the total number of threads to the number of algorithms of the at least two algorithms;
可选地, 该处理器 41还用于, 根据该关键边的数量为该至少两个算 法重新配置线程数。  Optionally, the processor 41 is further configured to reconfigure the number of threads for the at least two algorithms according to the number of the critical edges.
以上所述, 仅为本发明的具体实施方式, 但本发明的保护范围并不 局限于此, 任何熟悉本技术领域的技术人员在本发明揭露的技术范围内, 可轻易想到变化或替换, 都应涵盖在本发明的保护范围之内。 因此, 本 发明的保护范围应所述以权利要求的保护范围为准。  The above is only the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily think of changes or substitutions within the technical scope of the present invention. It should be covered by the scope of the present invention. Therefore, the scope of the invention should be determined by the scope of the claims.

Claims

权 利 要 求 Rights request
1、 一种最优网络最大流算法的选择方法, 其特征在于, 包括: 获取网络流图, 并根据所述网络流图得到第一残量网络; 1. A method for selecting the optimal network maximum flow algorithm, which is characterized by: obtaining a network flow graph, and obtaining the first residual network according to the network flow graph;
获取操作算法集合, 其中, 所述操作算法集合包括至少两个算法; 在所述第一残量网络中通过所述至少两个算法并行进行预流推进, 得到第二残量网络, 并在所述第二残量网络中确定所述至少两个算法对 应的关键边的数量; Obtain a set of operating algorithms, wherein the set of operating algorithms includes at least two algorithms; perform pre-flow advancement in parallel through the at least two algorithms in the first residual network to obtain a second residual network, and Determine the number of key edges corresponding to the at least two algorithms in the second residual network;
确定所述关键边的数量的最大值对应的算法为所述网络流图的最 优网络最大流算法。 The algorithm corresponding to the maximum value of the number of critical edges is determined as the optimal network maximum flow algorithm of the network flow graph.
2、 根据权利要求 1 所述的方法, 其特征在于, 所述根据所述网络 流图得到第一残量网络后, 还包括: 2. The method according to claim 1, characterized in that, after obtaining the first residual network according to the network flow graph, it further includes:
根据所述第一残量网络获取活跃结点; Obtain active nodes according to the first residual network;
所述获取操作算法集合包括: The acquisition operation algorithm set includes:
根据算法模板获取所述活跃结点对应的算法和数据结构; 其中, 所 述算法模板包括用户配置的管理所述活跃结点的数据结构和用户配置 的对应所述活跃结点的算法以及所述网络流图的数据结构; Obtain the algorithm and data structure corresponding to the active node according to the algorithm template; wherein, the algorithm template includes a user-configured data structure for managing the active node and a user-configured algorithm corresponding to the active node and the Data structure of network flow graph;
根据所述算法和数据结构获得所述操作算法集合。 The set of operating algorithms is obtained based on the algorithms and data structures.
3、 根据权利要求 2所述的方法, 其特征在于, 所述方法还包括: 对所述网络流图的数据结构加细粒度锁。 3. The method according to claim 2, characterized in that the method further includes: adding fine-grained locks to the data structure of the network flow graph.
4、 根据权利要求 1或 3所述的方法, 其特征在于, 所述在所述第 一残量网络中通过所述至少两个算法并行进行预流推进包括: 4. The method according to claim 1 or 3, wherein the parallel pre-flow advancement through the at least two algorithms in the first residual network includes:
根据所述至少两个算法从所述管理活跃结点的数据结构中获取对 应的活跃结点; Obtain the corresponding active node from the data structure that manages active nodes according to the at least two algorithms;
根据所述至少两个算法并行将所述对应的活跃结点的盈余流通过 距离标识比自己低的相邻结点向汇点进行推进, 其中, 所述盈余流包括 所述活跃结点的入流量与出流量的正差值。 According to the at least two algorithms, the surplus flow of the corresponding active node is advanced to the sink through the adjacent node with a lower distance identifier than itself, wherein the surplus flow includes the input of the active node. The positive difference between flow rate and outflow rate.
5、 根据权利要求 4 所述的方法, 其特征在于, 所述在将所述对应 的活跃结点的盈余流通过所述相邻结点向汇点进行推进后, 还包括: 若所述相邻结点存在所述盈余流, 则确定所述相邻结点为新的活跃 结点, 并将所述新的活跃结点放入所述管理活跃结点的数据结构中。 5. The method according to claim 4, characterized in that, after advancing the surplus flow of the corresponding active node to the sink through the adjacent node, further comprising: if the corresponding If the surplus flow exists in a neighboring node, the neighboring node is determined to be a new active node, and the new active node is put into the data structure for managing active nodes.
6、 根据权利要求 5 所述的方法, 其特征在于, 在所述得到第二残 量网络前, 还包括: 在通过所述至少两个算法并行进行预流推进时, 获取被重标识的边 数; 6. The method according to claim 5, characterized in that, before obtaining the second residual network, it further includes: When pre-flow advancement is performed in parallel through the at least two algorithms, the number of re-identified edges is obtained;
根据所述算法模板获取更新参数; Obtain update parameters according to the algorithm template;
在确定所述更新参数和所述被重标识的边数满足预设条件时, 更新 所有结点到汇点的距离标识, 以得到所述所有结点到汇点的新的距离标 识; When it is determined that the update parameters and the number of re-identified edges meet the preset conditions, update the distance identifiers from all nodes to the sink point to obtain new distance identifiers from all nodes to the sink point;
所述得到第二残量网络包括: Obtaining the second residual network includes:
根据所述所有结点到汇点的新的距离标识得到所述第二残量网络。 The second residual network is obtained according to the new distance identifiers from all nodes to the sink.
7、 根据权利要求 5或 6 所述的方法, 其特征在于, 在确定所述管 理活跃结点的数据结构不存在活跃结点时, 则确定汇点的流量为所述网 络最大流。 7. The method according to claim 5 or 6, characterized in that, when it is determined that there is no active node in the data structure for managing active nodes, it is determined that the flow of the sink point is the maximum flow of the network.
8、 根据权利要求 1 至 7任一项所述的方法, 其特征在于, 所述在 所述第一残量网络中通过所述至少两个算法并行进行预流推进前, 所述 方法还包括: 8. The method according to any one of claims 1 to 7, characterized in that, before performing pre-flow advancement in parallel through the at least two algorithms in the first residual network, the method further includes: :
获取总线程数; Get the total number of threads;
根据所述总线程数配置对应所述至少两个算法的线程数, 其中, 所 述线程数包括所述总线程数与所述至少两个算法的算法数量的比值; 所述在所述第一残量网络中通过所述至少两个算法并行进行预流 推进包括: The number of threads corresponding to the at least two algorithms is configured according to the total number of threads, wherein the number of threads includes the ratio of the total number of threads to the number of algorithms of the at least two algorithms; The parallel pre-flow advancement through at least two algorithms in the residual network includes:
在所述第一残量网络中通过所述至少两个算法根据所述对应的线 程数并行进行预流推进。 In the first residual network, the at least two algorithms are used to perform pre-stream advancement in parallel according to the corresponding number of threads.
9、 根据权利要求 8 所述的方法, 其特征在于, 在确定所述关键边 的数量的最大值对应的算法为最优网络最大流算法后, 还包括: 9. The method according to claim 8, characterized in that, after determining that the algorithm corresponding to the maximum value of the number of key edges is the optimal network maximum flow algorithm, it further includes:
根据所述关键边的数量为所述至少两个算法重新配置线程数。 Reconfiguring the number of threads for the at least two algorithms based on the number of critical edges.
1 0、 一种算法选择设备, 其特征在于, 包括: 10. An algorithm selection device, characterized by including:
获取单元, 用于获取网络流图, 并根据所述网络流图得到第一残量 网络, 并获取操作算法集合, 其中, 所述操作算法集合包括至少两个算 法; The acquisition unit is used to obtain the network flow graph, obtain the first residual network according to the network flow graph, and obtain the operation algorithm set, wherein the operation algorithm set includes at least two algorithms;
处理单元, 用于在所述第一残量网络中通过所述至少两个算法并行 进行预流推进, 得到第二残量网络, 并在预流推进后确定所述至少两个 算法对应的关键边的数量, 并在所述第二残量网络中确定所述关键边的 数量的最大值对应的算法为所述网络流图的最优网络最大流算法。 A processing unit configured to perform pre-flow advancement through the at least two algorithms in parallel in the first residual network to obtain a second residual network, and determine the key corresponding to the at least two algorithms after the pre-flow advancement. The number of edges, and the algorithm corresponding to the maximum value of the number of key edges in the second residual network is determined to be the optimal network maximum flow algorithm of the network flow graph.
1 1、 根据权利要求 1 0 所述的设备, 其特征在于, 所述获取单元还 用于, 根据所述网络流图得到第一残量网络后, 根据所述第一残量网络 获取活跃结点; 1 1. The device according to claim 1 0, characterized in that the acquisition unit is further configured to: after obtaining the first residual network according to the network flow graph, obtain the active node according to the first residual network point;
所述获取单元具体用于, 根据算法模板获取所述活跃结点对应的算 法和数据结构, 并根据所述算法和数据结构获得所述操作算法集合, 其 中, 所述算法模板包括用户配置的管理所述活跃结点的数据结构和用户 配置的对应所述活跃结点的算法以及所述网络流图的数据结构。 The acquisition unit is specifically configured to obtain the algorithm and data structure corresponding to the active node according to the algorithm template, and obtain the operation algorithm set according to the algorithm and data structure, wherein the algorithm template includes user configuration management The data structure of the active node, the algorithm configured by the user corresponding to the active node, and the data structure of the network flow graph.
1 2、 根据权利要求 1 1 所述的设备, 其特征在于, 所述处理单元还 用于, 对所述网络流图的数据结构加细粒度锁。 12. The device according to claim 11, characterized in that the processing unit is further configured to add fine-grained locks to the data structure of the network flow graph.
1 3、 根据权利要求 1 1或 1 2所述的设备, 其特征在于, 所述处理单 元具体用于, 根据所述至少两个算法从所述管理活跃结点的数据结构中 获取对应的活跃结点, 并根据所述至少两个算法并行将所述对应的活跃 结点的盈余流通过距离标识比自己低的相邻结点向汇点进行推进, 其 中, 所述盈余流包括所述活跃结点的入流量与出流量的正差值。 13. The device according to claim 11 or 12, characterized in that the processing unit is specifically configured to obtain the corresponding active node from the data structure of the managed active node according to the at least two algorithms. node, and advance the surplus flow of the corresponding active node to the sink through the adjacent node with a lower distance identifier than itself according to the at least two algorithms in parallel, wherein the surplus flow includes the active node The positive difference between the inflow and outflow of a node.
14、 根据权利要求 1 3 所述的设备, 其特征在于, 所述处理单元还 用于, 在将所述对应的活跃结点的盈余流通过所述相邻结点向汇点进行 推进后, 若所述相邻结点存在所述盈余流, 则确定所述相邻结点为新的 活跃结点, 并将所述新的活跃结点放入所述管理活跃结 ,、的数据结构 中。 14. The device according to claim 13, wherein the processing unit is further configured to: after advancing the surplus flow of the corresponding active node to the sink through the adjacent node, If the surplus flow exists in the adjacent node, determine the adjacent node as a new active node, and put the new active node into the data structure that manages active nodes. .
1 5、 根据权利要求 14 所述的设备, 其特征在于, 所述处理单元还 用于, 在通过所述至少两个算法并行进行预流推进时, 获取被重标识的 边数, 根据所述算法模板获取更新参数, 并在确定所述更新参数和所述 被重标识的边数满足预设条件时, 更新所有结点到汇点的距离标识, 以 得到所述所有结点到汇点的新的距离标识, 并根据所述所有结点到汇点 的新的距离标识得到所述第二残量网络。 15. The device according to claim 14, wherein the processing unit is further configured to obtain the number of re-identified edges when pre-flow advancement is performed in parallel through the at least two algorithms, according to the The algorithm template obtains the update parameters, and when it is determined that the update parameters and the number of re-identified edges meet the preset conditions, it updates the distance identifiers from all nodes to the sink point to obtain the distance identifiers from all nodes to the sink point. A new distance identifier is obtained, and the second residual network is obtained based on the new distance identifier from all nodes to the sink point.
1 6、 根据权利要求 14或 1 5所述的设备, 其特征在于, 所述处理单 元还用于, 在确定所述管理活跃结点的数据结构不存在活跃结点时, 则 确定汇点的流量为所述网络最大流。 16. The device according to claim 14 or 15, wherein the processing unit is further configured to determine the sink point when it is determined that there is no active node in the data structure for managing active nodes. The traffic is the maximum flow of the network.
1 7、 根据权利要求 1 0至 1 6任一项所述的设备, 其特征在于, 所述 获取单元还用于, 在所述第一残量网络中通过所述至少两个算法并行进 行预流推进前, 获取总线程数; 17. The device according to any one of claims 10 to 16, characterized in that the acquisition unit is further configured to perform prediction in parallel through the at least two algorithms in the first residual network. Before the stream is pushed, get the total number of threads;
所述处理单元还用于, 配置对应所述至少两个算法的线程数, 并在 所述第一残量网络中通过所述至少两个算法根据所述对应的线程数并 行进行预流推进, 其中, 所述线程数包括所述总线程数与所述至少两个 算法的算法数量的比值。 The processing unit is also configured to configure the number of threads corresponding to the at least two algorithms, and In the first residual network, the at least two algorithms are used to perform pre-stream advancement in parallel according to the corresponding number of threads, where the number of threads includes the total number of threads and the number of algorithms of the at least two algorithms. ratio.
1 8、 根据权利要求 1 7 所述的设备, 其特征在于, 所述处理单元还 用于, 在确定所述关键边的数量的最大值对应的算法为最优网络最大流 算法后, 根据所述关键边的数量为所述至少两个算法重新配置线程数。 18. The device according to claim 17, wherein the processing unit is further configured to, after determining that the algorithm corresponding to the maximum number of key edges is the optimal network maximum flow algorithm, based on the The number of critical edges is the number of reconfiguration threads of the at least two algorithms.
PCT/CN2014/083511 2013-08-14 2014-08-01 Method and device for selecting optimal network maximum flow algorithm WO2015021869A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310354026.1 2013-08-14
CN201310354026.1A CN104376366B (en) 2013-08-14 2013-08-14 A kind of system of selection of optimal network maximum-flow algorithm and equipment

Publications (1)

Publication Number Publication Date
WO2015021869A1 true WO2015021869A1 (en) 2015-02-19

Family

ID=52468030

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/083511 WO2015021869A1 (en) 2013-08-14 2014-08-01 Method and device for selecting optimal network maximum flow algorithm

Country Status (2)

Country Link
CN (1) CN104376366B (en)
WO (1) WO2015021869A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111158903A (en) * 2019-12-12 2020-05-15 中国科学院深圳先进技术研究院 Dynamic data planning method

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106503095B (en) * 2016-10-13 2019-06-04 南京航空航天大学 A kind of data fusion method based on ballot mode
CN108009643B (en) * 2017-12-15 2018-10-30 清华大学 A kind of machine learning algorithm automatic selecting method and system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101783028A (en) * 2010-02-26 2010-07-21 清华大学 Quick partition method of three-dimensional medical image on basis of video card parallel computing
CN103093281A (en) * 2012-12-27 2013-05-08 吴立新 Network maximum flow parallel solving method
WO2013113364A1 (en) * 2012-01-30 2013-08-08 Nokia Siemens Networks Oy Usage of multiflow and multiple input multiple output in cellular communication systems

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102117485B (en) * 2009-12-30 2012-12-12 中国科学院沈阳自动化研究所 Method for automatically segmenting images based on target shape
CN102116839B (en) * 2009-12-30 2013-02-27 中国科学院沈阳自动化研究所 Method for testing field programmable gate array (FPGA) based on maximum flow method
US8751638B2 (en) * 2010-07-02 2014-06-10 Futurewei Technologies, Inc. System and method to implement joint server selection and path selection

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101783028A (en) * 2010-02-26 2010-07-21 清华大学 Quick partition method of three-dimensional medical image on basis of video card parallel computing
WO2013113364A1 (en) * 2012-01-30 2013-08-08 Nokia Siemens Networks Oy Usage of multiflow and multiple input multiple output in cellular communication systems
CN103093281A (en) * 2012-12-27 2013-05-08 吴立新 Network maximum flow parallel solving method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111158903A (en) * 2019-12-12 2020-05-15 中国科学院深圳先进技术研究院 Dynamic data planning method
CN111158903B (en) * 2019-12-12 2023-04-25 中国科学院深圳先进技术研究院 Planning method for dynamic data

Also Published As

Publication number Publication date
CN104376366A (en) 2015-02-25
CN104376366B (en) 2017-11-03

Similar Documents

Publication Publication Date Title
US9454408B2 (en) Managing network utility of applications on cloud data centers
US9367344B2 (en) Optimized assignments and/or generation virtual machine for reducer tasks
WO2017128979A1 (en) Resource management method and device
WO2017214932A1 (en) Network-slice resource management method and apparatus
JP6007799B2 (en) Centralized network control system
US9350800B2 (en) Defragmenting clusters with reserved resources
KR20160076968A (en) Technologies for network device flow lookup management
Mennes et al. GRECO: A distributed genetic algorithm for reliable application placement in hybrid clouds
Zhang et al. Improving Hadoop service provisioning in a geographically distributed cloud
WO2016086709A1 (en) Method and device for implementing capacity planning
WO2015021869A1 (en) Method and device for selecting optimal network maximum flow algorithm
CN107454019A (en) Software defined network distribution method of dynamic bandwidth, device, equipment and storage medium
US20170012858A1 (en) Mechanism and Framework for Finding Optimal Multicast Tree Roots Without the Knowledge of Traffic Sources and Receivers for Fabricpath and TRILL
Chen et al. NFV middlebox placement with balanced set-up cost and bandwidth consumption
EP3041170B1 (en) Network planning method and device
US9565130B2 (en) Cloud-based resource availability calculation of a network environment
Prisacari et al. Generalized hierarchical all-to-all exchange patterns
US9906435B2 (en) Method and apparatus for determining intermediate routing node and system
WO2020043120A1 (en) Method and apparatus for dividing internal gateway protocol domain in network
WO2016061952A1 (en) Ethernet service configuration method and apparatus, and storage medium
WO2018009103A1 (en) Power manager and method performed thereby for managing power of a datacentre
WO2016082581A1 (en) Wavelength routing planning method, apparatus, and storage medium
WO2017118431A1 (en) Route selection method and apparatus
WO2016062071A1 (en) Concurrence processing method, apparatus and system for service creation and increment discovery
CN106484725B (en) A kind of data processing method, device and system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14836099

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14836099

Country of ref document: EP

Kind code of ref document: A1