Network flow and graph (1)

The linear programming problem is the most basic problem in operations research. We have learned a lot of solutions. Today, we will continue to learn another efficient algorithm for linear programming problems - network flow problem (network flow problem)

1

network flow model

In order to better introduce the ins and outs of the algorithm, as before, start from the case - the optimal furnace (OOI)

Optimal Ovens, Inc. (OOI) manufactures home toaster ovens at facilities in Wisconsin and Alabama . The finished furnaces are shipped by rail to one of OOI's two warehouses in Memphis and Pittsburgh , and then distributed to customer sites in Fresno , Peoria and Newark . A small amount of furnaces can also be transferred between the two warehouses with the company's trucks. Our task is to make a distribution plan for the new E27 stove next month. Each factory can ship up to 1,000 furnaces during this period, and there are currently no stocks in warehouses. Customers in Fresno, Peoria and Newark requested 450, 500 and 610 stoves, respectively. The number of transfers between warehouses is limited to 25 furnaces, but there is no charge. See the table below for unit costs of other feasible streams.

deecc81cfe95df9954c4209d239d5247.png

We turn the OOI case into a network model representation: 2 factories, 2 warehouses and 3 customer points constitute the 7 nodes of the directed graph. The arc represents the feasible flow of the furnace, and the direction is indicated by the arrow.

9c7551bddb3f11c5245f01f445db633a.png

The core of describing the operations research model is the decision variable. From linear programming to the network flow model, the first thing to find is the description of the decision variable:

a0d11b9bc9f632d3b21820caf299a6d9.png

In addition, we want to introduce the cost of traffic flow and the upper and lower bounds (ie capacity) of traffic on the arc:

c1c32805281cefc2a9648b1070bfcbf2.png

Further, for each node, we hope: total inflow - total outflow = net demand specified by the node , expressed in symbols:

def8a24324f60bfeb062ebd1ddbd1302.png

In summary, we get the minimum cost network flow model :

22d243ada38867a7c4b65b3d5e438d57.png

For nodes, there are three types. A sink or demand node is a consumption flow, such as a customer site in the case of OOI. The source (source) or supply (supply) node produces the flow, such as the factory of OOI case. Transshipment nodes just deliver flows, like warehouses for OOI cases. Obviously, the net demand is positive at the demand node, negative at the supply node, and 0 at the transshipment node

We can write the OOI case as a minimum cost network flow model:

fc9f8c55aeb04603501e6e4ba5a8a4e0.png

It should be noted here that there are 8 more nodes than the original OOI network. For the network flow model, traffic is only generated at the supply node and consumed only at the demand node. Therefore, to achieve flow balance, the following must be satisfied: total supply = total demand. So we have to follow the principle:

If, in a given network flow problem, aggregate supply is less than aggregate demand, then the problem is infeasible. If total supply exceeds total demand, a new sink node should be added to consume the excess supply via zero-fee arcs from all source nodes.

In the OOI case, total supply=1000+1000>450+500+610=total demand, and the excess 440 determines the demand of node 8. The figure below shows an optimal solution for the OOI case.

4e35ac82e70a7d62b0a800435df8bccb.png

2

Network Flow Search Circle Direction

Search methods need to assume that there is an initial feasible solution, especially for network flow problems. The only new element in the context of network flow is the creation of an artificial model that is itself a minimum-cost network flow problem, enabling common algorithms to be applied. To do this, we simply place a flow with zero flow on all arcs of the original model and add an artificial node. Use an artificial arc to connect this special node with all other nodes whose net demand is not zero to realize the requirements for supply and demand.

An artificial network model and starting point for computing an initial feasible solution to the minimum-cost network flow problem can be created by: (i) assigning zero-flow flows to all arcs in the original model; (ii) introducing a artificial nodes; (iii) create artificial arcs from each supply node k to artificial nodes and make their flow equal to the given supply; (iv) add artificial arcs from artificial nodes to each demand node k and make flow equal to the given demand

For example, in the OOI case, we add artificial node 0 to obtain the artificial network model:

45cef55ef14252a7d4ee7630b0d30083.png

The network flow model is a special kind of linear programming model, so it can be written in the familiar standard form of linear programming:

96b65545717a74931f095c119697b1fb.png

In the network flow model, the main constraint matrix A is a special structure, and we need to associate it with the directed graph of the network flow. Such matrices are called node-arc incidence matrices , and they represent both flow balance requirements and algebraic descriptions of directed graphs.

The node-arc correlation matrix has a row for each node and a column for each arc. There are only two nonzero entries in each column, one -1 at the row where the corresponding arc leaves the node, and one +1 at the row where the arc enters the node.

Still taking the OOI case as an example, their node-arc correlation matrix can be expressed as:

96fa7ef8f07686ea0f1fa49bdb9c93f1.png

The focus of the linear programming algorithm is to construct feasible improvement directions. In order to get a feasible improvement direction for the network flow problem, we need to understand the concepts of chain, cycle, and path . The path has been given in the shortest path problem, so I won't repeat it here.

A chain is a sequence of arcs connecting two nodes. In the sequence, each arc has exactly one node in common with its predecessor, and no node is visited twice. A cycle is a chain whose starting and ending nodes are the same.

A chain does not need to consider the direction of the arc, which is what makes a chain different from a road.

A path is a chain connecting all arcs in the forward direction, and a loop is a circle in which all arcs are in the same direction.

Circles can connect arcs forward (forward direction) or backward (reverse direction). A cycle direction for a minimum-cost network flow model increases flow on forward arcs and decreases flow on backward arcs given a cycle in a directed graph:

03da3c05b6a826fd815d66394bd10844.png

For example, in the following circle 1-3-6-4-1, the first two arcs are all forward, the last two arcs are all backward, and the rest of the arcs are not part of the circle.

0925b44f839c8004644551d7a11b249a.png

It can be seen from the improved search feasible direction that AΔx=0 must be satisfied to maintain the feasibility. For the node-arc correlation matrix, the circle direction satisfies the condition of "net change is zero": it is feasible to adjust along a certain circle direction in the network flow model Stream, which enables the constraints of stream smoothness to be satisfied.

As an example to demonstrate this principle, consider the following directed graph:

9f166d7a2e8d70a33062a9d055b7ffda.png

For circle 1-2-7-6-5-1, the flow balance of node 6 is guaranteed. By definition, the circle direction satisfies:

20a42bc5740d9a882ad9d2f70637e88b.png

Its node-arc correlation matrix is:

c19f6f88a2341c9d453ebca4e07acfec.png

For node 6, the proof principle satisfies that the net change is zero:

8f3dcea0e055b7c479e4c1c320f7c0ca.png

Next, we need to find the conditions for the direction of the feasible improvement circle , first of all, the necessary and sufficient conditions for the direction of the feasible circle:

9be38d944571e7c995abaac8d6e04097.png

For example, use (u,x) to represent the capacity and arc flow. For the figure below, judge whether each circle direction is a feasible circle direction.

18b18339880da5bf12ac7e376c1c28d3.png

(a)1-2-7-6-5-1

This circle direction is feasible because the current flow of all backward arcs is positive: (2, 7), (6, 7), (5, 6), and the flow of all forward arcs is not up to the upper limit: (1, 2), (5, 1)

(b)3-4-6-3

This circle direction is not feasible because forward arc (3,4) flow has reached capacity and cannot increase any more

(c)1-3-6-5-1

This circle direction is not feasible because the flow in the backward arc (6, 3) is 0 and cannot be reduced any further

The next step is to judge the direction of improvement:

36bdeff498b97bb03cf1e28033edf0f1.png

Finally, it is the judgment of the step size:

ba3e22271b1d160b0f0efe37a9bc55b4.png

To illustrate with an example, we have marked the cost, capacity and current traffic (c,u,x) of the OOI case on the network diagram, and the orange traffic represents the initial flow:

dd8177cef89093ba39931b32477ff226.png

The cost is: 7*560+4*1000+25*450+6*500+17*610=32540

We find a feasible improvement circle direction: 2-4-7-3-2. The forward arc flow is less than the capacity, and the backward arc flow is greater than 0, which is a feasible circle. And the difference between forward arc cost and backward arc cost is 12-21<0, which is an improvement circle.

Then find the maximum step size:

6d3737e7736e95cc56ceed7576291150.png

update stream:

c6e10fa43d426d8c825434e60029819a.png

The cost becomes: 7*560+4*390+7*610+25*450+6*500+5*610=27050

In summary, we get the search steps for the direction of the degenerate circle:

8669cba6b29d59495ff9f37d0331df64.png

Guess you like

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