Network flow and graph (3)

Over the length of two articles, we introduce the minimum cost network flow model and the algorithm to solve it. Today we introduce the practical application cases of the network flow model, and propose more efficient solution algorithms for some special scenarios.

Portal: Network Flow and Graph (1) Network Flow and Graph (2)

1

Shipping and Distribution Issues

The transport problem is a special minimum-cost network flow model where each node is either a pure supply node (all arcs point in) or a pure demand node (all arcs point in).

Its standard form can be expressed as:

da8bdff5a5fe6bca57ffc22c23e1a640.png

To give an example close to reality - the problem of naval .

The U.S. Naval Corps' officer transfer program is a real mass transportation problem. In extraordinary times, thousands of officers and soldiers will be transferred from their daily posts or left in their original positions. However, not every officer meets the assignment requirements in terms of rank, experience, or training received. The transfer selection can be represented as the virtual directed graph below. A supply node represents a group of officers who are currently in the same location and may meet the assignment requirements. For example, the first node represents a captain who is trained as an intelligence officer; the demand node represents the demand for officers with specific qualifications in an active area during an extraordinary period. For example, node 2 represents the need for one or more officers who serve as liaison officers for the local government.

96db2273be8ee8a522381683eb9ce114.png

An arc exists between two nodes when the officer represented by a supply node is qualified to fill the position corresponding to a demand node. Therefore, the District Officer is connected to the Local Government Liaison Officer. For the officers at any source node, there may be multiple feasible assignments, for example, the affairs officer can also be the first unit communicator.

The Navy's first priority is to fill all the positions it needs, but in reality there will always be some positions left that cannot be filled. At this point we represent the possibility of not being able to fill a position with an artificial supply node connected to all demands, and the high cost on its arc is used in the objective function as a penalty for not being able to fill a position . Once as many requirements as possible have been met, the second consideration is to minimize variation. That is, try to assign officers to the same units as they were before the transfer, or at least assign them to adjacent units by minimizing the total travel costs.

The naval movement problem is reduced to standard form using the following concepts.

0542621ae3c2d9ebc2512e6ab84b6c93.png

The assignment problem is another special kind of minimum-cost network flow problem, which is used to obtain the optimal pairing or matching between objects in two different sets.

The allocation problem is modeled with discrete decision variables:

2c4dcb759e6a8df723068159992bbf55.png

Denoting the set of feasible assignments (i, j) with A, we can formulate the linear assignment model as a bidirectional flow problem:

4469b927ce15f184508fed87e14da025.png

The first set of constraint equations ensures that each i is assigned exactly once by summing over all possible assignments j; the second set of constraint equations does the same to ensure that each j is assigned exactly once.

The formula is an integer linear programming (ILP) problem, and the decision variables are only allowed to take discrete values ​​0 or 1. But we will find that the discreteness can be ignored when computing the optimal solution.

To give a real example - CAM allocation problem .

A computer-aided manufacturing (CAM) system automates jobs, each consisting of a series of required machining and assembly operations, through a computer-controlled factory workstation. By case, the same operation can be done on several different workstations. Therefore, the computer control system must make corresponding operation decisions. Whenever a certain step of a job has been completed, the system must select one of several workstations that can realize its next operation to undertake the job. A near-optimal way to accomplish this control decision is to periodically solve the allocation model. For illustration, the table below assumes 8 jobs i are either waiting to be moved to the next workstation, or will complete the current operation within the next 5 minutes. At the same time, the table also lists 10 workstations j that may undertake the work. The entries in the table represent: time to transport to the station + time to wait for the station to become empty + time to process operations in the station. That is, the shortest time they assign work i to j. Missing data represent infeasible assignments.

9fc366c0c9c0c2b0f0b23a03b6357f27.png

Let the set A denote the feasible (i,j) pairs, and cij denote the time in the table. The above problem can be transformed into assigning work to workstations in a way that minimizes the total time. Since there are more workstations than jobs, pseudo-members need to be introduced to solve this problem.

If the sizes of the two sets that need to be paired in the allocation problem are inconsistent, the smaller one can be expanded by using pseudo-members. These pseudo-objects can be assigned to all members of another collection at zero cost.

In CAM application, the pseudo-job i=9,10 is introduced. Then its standard form can be expressed as:

38024d5c8163e7b0d6eadfed75a6c84f.png

To solve this problem, you can use the algorithms mentioned in the previous two sections (elimination circle algorithm, simple circle method), or you can use any algorithm of linear programming (simplex method, interior point method, dual method). But for this type of allocation problem, we have a more efficient algorithm to solve it - the Hungarian Algorithm (Hungarian Algorithm)

2

Hungarian algorithm

First give the algorithm steps directly:

35c60769e26bc2c9417e4f31edf093b4.png

Let's take an example to digest this algorithm. The following table shows the cost/weight that four objects from source set I={1,2,3,4} need to pair to sink J={5,6,7,8} objects:

59f9a55e21b1af42f167db6edf32d7b9.png

Initialization, first calculate the dual value of the source set:

9c7eb0ad1b79fdf02b9690a1f2b729bc.png

Then compute the pooled dual solution:

b703722b4e3c9d792abceebc34fa84ac.png

Calculate the marginal cost reduction:

645fadb00f8d5513b3e4f32573f0639c.png

Then build the equal subgraph:

56ecb1bc1048fa76a16aea8618284c38.png

Entering the de-expansion, first, the root i=1 marked as "even" is assigned to the unassigned and unmarked j=5, and (1,5) is added to the solution set; then the root i=2 of "even" is assigned to is assigned to j=6, and for the root i=4 is assigned to j=7. Since 5 is assigned, the root i=3 is not assigned. Got (thick red line means allocated):

ffcbfc39726d92eed2b36011f07f098d.png

4597564a667e5954bd798333ef922194.png

Then the tree grows, leaving only the "even" node i=3, pointing to the assigned but unmarked node j=5. Therefore, insert (3,5) and (1,5) assigned to j=5 into the tree, mark j=5 as "odd", and i=1 as "even", and get (the dotted line indicates that it is included in the tree):

ba09502ca11ae90d0f7cbba75e50806d.png

Go back to step 1, but this time there is no "even" label to unassigned, unlabeled node. Therefore, go to step 2, and there is no arc satisfying the condition, go to step 3.

A is the complete graph from source set to sink = {(1,5),(1,6),(1,7),(1,8),(2,5),(2,6),... ,(4,7),(4,8)}, by definition,

dd16f37add116d70e56c31141953b274.png

Then update the dual value and matrix:

db9bc9f7d56e9919ecdfa0a520d2ceb3.png

Update equality subgraph (green is new edge):

dd403cfbaf8406d1ee3505b9648a0efc.png

Then return to step 1, node 5 has been marked, so it does not meet the "unmarked" condition; node 6 has been unassigned, and does not meet the "unassigned" condition; so enter step 2, (3, 6) meets the conditions, proceed Tree growth and record path (3,6), (2,6):

caf60d07ec30ef9b1882120cf6440063.png

Then return to step 1, if the conditions are not met, go to step 2 again, record the path (2,7)(4,7), and get:

a5da358ca4f98d851d7635d55e2a998a.png

Return to step 1, (4, 8) meet the conditions, and perform solution set expansion:

32bc8464309ed5ef6171807d965c671e.png

So far, the iteration ends. The optimal solution has been found!

Guess you like

Origin blog.csdn.net/qq_27388259/article/details/129222763