A boutique brewery has two warehouses from which it distributes beer to five carefully chosen bars. At the start of every week, each bar sends an order to the brewery's head office for so many crates of beer, which is then dispatched from the appropriate warehouse to the bar. The brewery would like to have an interactive computer program which they can run week by week to tell them which warehouse should supply which bar so as to minimize the costs of the whole operation.

For example, suppose that at the start of a given week the brewery has 1000 cases at warehouse A, and 4000 cases at warehouse B, and that the bars require 500, 900, 1800, 200, and 700 cases respectively.

The transportation costs are given in Table 1.

**Table 1** Transportation costs from warehouses to bars

Cost ($/crate) | Warehouse A |
Warehouse B |
---|---|---|

Bar 1 |
2 | 3 |

Bar 2 |
4 | 1 |

Bar 3 |
5 | 3 |

Bar 4 |
2 | 2 |

Bar 5 |
1 | 3 |

Given this data, the brewery management want to know which warehouse should supply which bar.

Since crates of beer are being shipped from the warehouses to the bars, this problem is a bipartite network and can be modelled as a transportation problem.

The supply nodes are the warehouses, the demand nodes are the bars. The total supply is 1,000 + 4,000 = 5,000 and the total demand is 500 + 900 + 1,800 + 200 + 700 = 4,100, so the problem is unbalanced. We can either alter the balanced formulation to incorporate this or add a dummy demand node to receive the extra supply.

Since this is a transportation problem we can use the AMPL model file for transportation problems.

The data file will have the supply nodes as the warehouses:

set SUPPLY_NODES := A B ;and the demand nodes as the bars:

set DEMAND_NODES := 1 2 3 4 5 ;

The supply and demand is given and can be specified:

param Supply := A 1000 B 4000 ; param Demand := 1 500 2 900 3 1800 4 200 5 700 ;

Finally, the transportation costs are easier to specify using a transposed table:

param Cost (tr) : A B := 1 2 3 2 4 1 3 5 3 4 2 2 5 1 3 ;

Note that since the problem is not balanced, the AMPL script file `transportation.run`

(see Transportation Problems in AMPL for details) automatically adds a dummy demand node to the problem.

The AMPL model file `transportation.mod`

also ensures the supply, demand and bound variables are integer so that only linear programming will be necessary (as we will get naturally integer solutions, see The Transportation Problem for details).

By inserting

data brewery.dat;into

`transportation.run`

(see Transportation Problems in AMPL for details) we can solve the Brewery Problem. Figure 1 shows the AMPL output with the solution.
**Figure 1** AMPL output for the Brewery Problem

This shows that the optimal solution is to make the shipments shown in Table 1.

**Table 1** Optimal shipments for the Brewery Problem

Shipment (crates) | Warehouse A |
Warehouse B |
---|---|---|

Bar 1 |
300 | 200 |

Bar 2 |
- | 900 |

Bar 3 |
- | 1800 |

Bar 4 |
- | 200 |

Bar 5 |
700 | - |

There are 900 crates left at Warehouse B.

Notice that CPLEX did not need to use any branch-and-bound nodes, i.e., no integer programming was required. This confirms that a transportation problem has naturally integer solutions. By specifying the supply, demand and bound parameters be integer we guarantee that only linear programming needs to be used.

There are many ways to present the solution to the Brewery Problem: as a list of shipments, in a table, etc. You can use AMPL's `display`, `print` and `printf` commands to create formatted output that can be easily used in your management summary.

For example, `brewery.out` (shown below) was produced by an AMPL script file:

TRANSPORTATION SOLUTION -- Non-zero shipments TotalCost = $8600 Ship 300 crates of beer from warehouse A to pub 1 Ship 700 crates of beer from warehouse A to pub 5 Ship 200 crates of beer from warehouse B to pub 1 Ship 900 crates of beer from warehouse B to pub 2 Ship 1800 crates of beer from warehouse B to pub 3 Ship 200 crates of beer from warehouse B to pub 4

Also, showing the solution as a graphical output can be informative.

- Solve the Brewery Problem. Write a management summary of your solution.
**What to hand in**Hand in your management summary. - The next week the brewery has 3000 and 1500 crates of beer at Warehouses A and B respectively. The demand from Bars 1, 2, 3, 4 and 5 is 700, 1200, 1000, 800, 700. The transportation costs have not changed.
Solve the Brewery Problem using this new data. Write a management summary of your solution.

**What to hand in**Hand in your management summary. - Write a script file to generate the output shown in
`brewery.out`

. Use this script file to create a new output file with the solution to Task 1 displayed.**What to hand in**Hand in your script file and you new output file.

I | Attachment | History | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|---|

out | brewery.out | r1 | manage | 0.4 K | 2008-04-02 - 10:16 | MichaelOSullivan |

Topic revision: r10 - 2008-04-02 - MichaelOSullivan

Copyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Ideas, requests, problems regarding TWiki? Send feedback

Ideas, requests, problems regarding TWiki? Send feedback