Set 6 - min cost

advertisement
Minimum Cost Flows
Goal: Minimize costs to meet all demands in a network subject to capacities
(combines elements of both shortest path and max flow problems)
Attributes of the directed network G = (V, E):
1. xij = flow along i to j
2. cij = cost to send 1 unit of flow through i to j (nonnegative)
3. uij = capacity along i to j
4. b(i) = net flow at vertex i (>0 => supply; <0 => demand; = 0 => transshipment)
5. All demands can be met
6. Total demand = total supply
1
Linear Programming Formulation
minimize ∑ ∑cij xij
subject to
∑xij - ∑ xji = b(i) for all i  V
0 ≤ xij ≤ uij for all (i,j)  E
More generally: allow lower bounds: lij ≤ xij ≤ uij
2
Example – Distribution Problem
•
•
Several models of cars are manufactured at various plants and are shipped to
retail centers all over the country. Each retail center requests specific numbers
of cars of each model. Determine a production plan for each model at each
plant and a shipping pattern that satisfies the demands of each retail center and
minimizes the overall cost of production and transportation.
4 types of vertices:
1. plant – representing the various plants.
2. plant/model – corresponding to each model at a plant.
3. retailer/model – corresponding to each model needed by a retailer.
4. retailer – representing each retailer.
•
3 types of edges:
1. production edges (plant-plant/model) with production costs and possible bounds.
2. transportation edges (plant/model-retailer/model) with shipping costs and bounds.
3. demand edges (retailer/model-retailer) with 0 cost but lower bounds
corresponding to the demand of the model at that retailer.
3
Example: two plants, three car models, two retailers
(plant 1: makes models 1 &2; plant 2 makes models 1, 2, &3;
retailer 1 requires 1, 2, &3; retailer 2 requires models 1 &2)
P11
R11
P1
P12
P21
P2
P22
R12
R1
R13
R21
R2
P23
R22
4
Example – 1 car model
Ford produces cars in Detroit and Dallas. The Detroit plant can produce up to
6500 cars, and the Dallas plant can produce up to 6000 cars. Producing a car costs
$2000 in Detroit. Producing a car costs $1800 in Dallas until 5500 cars have been
produced, at which time overtime is paid and the car production costs rises to
$2100. Cars are shipped to three cities. City 1 must receive 5000 cars, city 2
must receive 4000 cars, and city 3 must receive 3000 cars. However,
transportation considerations allow for no more than 1000 cars from Detroit to
City 3 and no more than 1500 from Detroit to City 2. The cost of shipping a car
from each plant to each city is given below:
From/to City 1
City 2 City 3
Detroit
$800
$600
$300
Dallas
$500
$200
$200
Formulate a minimal cost network flow problem that can be used to
minimize the cost of meeting demand.
5
Network for Ford
1
2
All lower bounds are 0.
All edges with one number represent
total cost with infinite capacity.
All edges with two numbers
represent (total cost, capacity).
Total cost = production cost + transport cost
3
4
6
Example – Inventory Management
•
•
•
A particular material is used in manufacturing a product. An initial inventory
of 10 units is on hand. The maximum inventory capacity is 20 units. An
inventory of 8 units is requires at the end of the next four month planning
period.
Costs:
1. unit price of material – currently $6 but is expected to increase by 1 in
each of the next several months.
2. unit cost of storage is 0.25 per month.
Demands:
1. production demands 12, 19, 15, 20 units of material in the next four
months, respectively.
2. early shipment is possible but production has bounds of [14,18].
• How much raw material should be purchased in each month to
minimize total cost?
7
Network Representation: all edges have (lower bound, upper bound, unit cost)
values of (0, ∞, 0) unless labeled otherwise.
MONTH
Initial inventory: 10
0, 10, 0
II
M1
0, ∞, 6
Purchase: unlimited
PRODUCTION
REQUIREMENTS
P1
R1
14, 18, 0
0, 20, 0.25
0, ∞, 7
14, 18, 0
M2
S
-12
0, ∞, 8
P2
R2
-19
P3
R3
-15
P4
R4
-20
0, 20, 0.25
14, 18, 0
M3
0, ∞, 9
0, 20, 0.25
14, 18, 0
M4
0, 20, 0.25
FI
Final inventory: -8
8
Min Cost Example – Finding a Feasible Flow
1
s
2
2
8,6
11,5
1
9
6
5
1
9
1
7,3
3,9
4
3
4
-7
9
5
3
7
3
12,5
t
3
-3
s
Each vertex has demand/supply.
Each edge has (cost, capacity)
1
2
9
6
5
3
1
4
5
4
1
4
3
3
7
t
Feasible flow:
X12 = 5
X13 = 4
X24 = 6
X32 = 0
X34 = 1
Edges from s and to t are saturated.
Feasible flow exists.
9
Min Cost Example – Is it optimal?
1
1
2
8,6
11,5
9
1
7,3
3,9
4
-7
12,5
Feasible flow:
X12 = 5
X13 = 4
9
X24 = 6
X32 = 0
X34 = 1
2
6
5
1
0
4
4
-7
1
3
3
-3
-3
Each vertex has demand/supply.
Each edge has (cost, capacity)
Feasible flow along each edge.
Cost of meeting demands for this flow:
11(5)+3(4)+7(0)+8(6)+12(1) =127
Is it optimal?
10
Residual Networks
Use residual network to identify opportunities for readjusting flow.
Associated costs on edges indicate the effect on the objective function.
For any flow x, the residual network G(x) is defined by:
 If (i,j) in E and xij < uij, then G(x) contains edge (i, j)
with cost cij and residual capacity rij = uij – xij.
 If (i,j) in E and xij >0, then G(x) contains edge (j, i)
with cost cji = -cij and residual capacity rji = xij.
11
Example
Cost, Capacity
Flows
1
1
2
11,5
9 1
8,6
4 -7
7,3
3,9
9
6
1
12,5
3
-3
2
5
4 -7
0
4
1
3
-3
Residual Capacity
Residual Cost
1
2
9
2
-8
-11 7
1
-3
3
9
4 -7
-12
5 3
1
4 -7
1
4
5
12
3
-3
6
4
3
-3
Negative length cycle: 1-3-2-1
Cost: 3 + 7 + (-11) = -1
Most flow through cycle: min{5, 3, 5} = 3
Push 3 units through and update.
New objective function value =
127 + 3(-1) = 124
1
2
1
2
11
-11
9
1
-7
-3
3
9
4 -7
-12
3
-3
12
2
3
-8
6
9
2 3
1
2
4 -7
1
7
3
-3
4 -7
1
4
3
-3
12
Negative Cycle Conditions
In the previous example, a negative cycle in the residual network G(x)
was an indication that the cost of the flow x can be reduced by augmenting
along that cycle.
Cycle Optimality Conditions
The feasible flow x* is optimal iff G(x*) contains no negative cost cycle.
13
Cycle-Canceling Algorithm
algorithm cycle-canceling;
begin
find a feasible flow x;
while G(x) contains a negative cost cycle do
begin
W = Find_Cycle(G(x));
δ(W) := min{rij: (i,j)  W};
augment δ(W) units of flow along W;
update G(x);
end;
end;
where Find_Cycle is some algorithm (label-correcting) that detects negative cycles.
14
Example
Cost, Capacity
Flows
0
2,4
4 1
2
3,3
4 -4
1,2
2,2
3
1
1,5
3
0
2
3
0
1
3
Cost = 3(2)+1(2)+3(3)+1(1) = 18
4
1
Residual Network
2,1
2
-3,3
-2,3
1,2
1
4
Negative length cycle:
Cycle Cost:
Most flow through cycle: min{ , , } =
Push units through and update.
New objective function value =
-1,1
-2,1
2,1
3
1,4
15
Example
Cost, Capacity
Flows
0
2,4
4 1
2
3,3
4 -4
1,2
2,2
3
1
1,5
3
0
2
1
2
1
3
Cost = 16
4
3
Residual Network
2,1
2
3,2
-3,1
-2,3
-1,2
1
-1,3
-2,1
2,1
4
3
Negative length cycle:
Cycle Cost:
Most flow through cycle: min{ , , , } =
Push unit through and update.
New objective function value =
1,2
16
Example
Cost, Capacity
Flows
0
2,4
4 1
2
3,3
4 -4
1,2
2,2
2
1
1,5
3
0
2
0
2
2
3
Cost = 14
4
4
Residual Network
2,2
2
3,3
-2,2
-1,2
1
4
-1,4
-2,2
3
Negative length cycle:
Cycle Cost:
Most flow through cycle:
New objective function value =
1,1
17
First Example – re-examined
1
2
2
9
1
6
4 -7
3
7
3
-3
1
Residual Cost
Residual Capacity
1
2
11
-11
9
1
1
-7
-3
3
9
4 -7
-12
9
2
4
3
-3
1
2
9
4 -7
-12
-3
3
-3
12
3
1
3
-3
1
4
2
2
4 -7
3
9
Negative length cycle:
Cost:
Most flow through cycle: min{ , , , } =
Push units through and update.
New objective function value =
Negative length cycle:
2
5
-8
-7 8
1
4 -7
1
7
1
11
6
2 3
1
12
3
-3
2
3
-8
9
2
4 -7
1
3
-3
18
Other Algorithms
Generic Cycle-Canceling not the most efficient algorithm.
Choice of cycle can improve upon this (resulting in polynomial-time algorithms):
1. always choose the cycle with maximum possible improvement
2. always choose cycle with minimum mean cost
Successive Shortest Path – moves flow along shortest paths from excess vertices
to deficit vertices
Network Simplex – LP simplex method for networks; use spanning trees to move
from basis to basis and negative length cycles to determine entering and
leaving variables.
19
Facility Location Problem
Suppose there are r existing facilities, located at distinct points on the x-y plane.
You want to locate p new facilities in a way that will minimize transportation
costs between the new facilities and between the new and existing facilities.
The transportation costs are directly proportional to the rectilinear distances
between the two facilities.
•
•
•
•
ith existing facility located at (ui, vi)
jth new facility located at (xj, yj) – the decision variables for j = 1, …, p
Rectilinear distance between two points (xj, yj) and (xk, yk) = |xj-xk|+|yj-yk|.
ajk and dij are cost per unit distance between facilities
p
p
p
r
min  a jk (| x j  xk | | y j  yk |)  dij (| x j  ui | | y j  vi |)
j 1 k 1
j 1 i 1
1. How to transform this into a linear programming problem?
2. Then, how to transform that into a min cost flow problem?
20
Download