Network Optimisation using Linear Programming and ... - CiteSeerX

11 downloads 737 Views 46KB Size Report
mechanisms working on populations of solutions in contrast to other search ... Key-words Linear Programming, Genetic Algorithm, Network Optimisation, ...
Network Optimisation using Linear Programming and Genetic Algorithm A. SADEGHEIH Department of Industrial Engineering University of Yazd, P.O.Box: 89195-741 Iran, Yazd

P. R. DRAKE Intelligent Systems Laboratory, System Division, School of Engineering, University of Queen’s Buildings, PO Box 917, Cardiff, CF2 3TE Wales Cardiff, UK,

Abstract: The problem of network is formulated as linear programming and genetic algorithm in spreadsheet model. GA's are based in concept on natural genetic and evolutionary mechanisms working on populations of solutions in contrast to other search techniques that work on a single solution. An example application is presented. An empirical analysis of the effects of the algorithm's parameters is also presented in the context of this novel application.

Key-words Linear Programming, Genetic Algorithm, Network Optimisation, Shortest Path Problem, Transportation Problem, Maximum Flow Problem.

1 Introduction The network problem provides a unified approach to many applications because of its general structure. The minimum cost flow problem holds a central position among network optimisation models, both because it encompasses such a broad class of applications and because it can be solved extremely efficiently. Like the maximum flow problem [1], it considers flow through a network with limited arc (line) capacities. The maximum amount of flow (possibly infinity) that can be carried on a directed arc is referred to as the arc capacity. Like the shortest path problem, it considers a cost (or distance) for flow through an arc. Similar to the transportation problem or assignment problem, it can consider multiple sources (supply nodes or source nodes or sources) and multiple destinations (demand nodes or sink nodes or sinks) for the flow, again with associated costs. Finally, like the transhipment problem, it can also consider various junction points

(transhipment nodes) between the sources and destinations for this flow. In fact, they are all special cases of the minimum cost flow problem. The main reason for high efficiency in solving the network problem is that it can be formulated as a linear programming problem and thus solved by a generalisation of the transportation simplex called the network simplex [2-3], as described in the next section. This paper will introduce the network problem and solution methodology using linear programming as well as comparing this approach with a genetic algorithm.

2 Formulation of the network problem Consider a directed and connected network, where the n nodes include at least one supply node and at least one demand node. The decision variables are:

X ij = flow through arc (i, j); and the given information includes:

C ij : cost per unit flow through arc (i, j); U ij : maximum capacity of arc (i, j); b i : net flow generated at node i. The value of b i depends on the nature of node i, where:

b i > 0, if node i is a demand node; b i < 0, if node i is a supply node; b i = 0, if node i is a intermediate node.

The objective is to minimise the total cost of sending the available supply through the network to satisfy the given demand. Therefore, the network problem may be written as: Minimise: Z =

n

n

∑∑C

ij

X ij

(1)

i =1 j =1

subject to:

∑X k

ki

− ∑ X ij = b i for i = 1, 2, ..., n; (2) j

0 ≤ X ij ≤ U ij for each arc (i, j).

(3)

The first summation in the node constraints (2) represents the total flow into node i, whereas the second summation represents the total flow out of node i. Therefore, the difference is the net flow generated at this node. In some applications, it is necessary to have a lower bound L ij > 0 for the flow through each line (i, j). When this occurs, the translation of variables, X 'ij = X ij − L ij is introduced, with

( X 'ij + L ij )

being

substituted for X ij throughout the model in order to convert the model back into the above format with non-negative constraints.

3 7-Node Example An example illustrating the network problem is given in Fig.1. The nodes are represented by numbered circles and arcs by arrows. The arcs are assumed to be directed so that, for instance, material can be sent from node 1 to node 2, but not from node 2 to node 1. As an example, let Fig.1 represent a car company with plants in two locations 1 and 7. The total production of car units out of

each plant is 200 and 300 units respectively. The negative numbers next to the nodes representing 1 and 7 indicate the available supply of cars at these locations. The demand for cars at each of the other locations is represented by positive numbers next to the remaining nodes e.g. 3 has a demand for 60 cars. The values on the arcs connecting the various nodes represent the unit cost of transporting cars between the indicated locations e.g. it costs 50 to transport a car from 7 to 6. The problem here is to determine the plan with a minimum cost for transporting cars from 1 and 7 to meet the demand for cars at the other locations. It is important to recognise the special structure of the balance equations. It should also be noted that there is one balance equation for each node in the network. The flow variables X ij have either 0, +1 or -1 coefficients in these equations. Furthermore, each variable appears in only two balance equations, once with a -1 coefficient, corresponding to the node from which the arc emanates; and once with a +1 coefficient, corresponding to the node upon which the arc is incident. This type of balance equations is referred to as a nodearc incidence matrix; it completely describes the physical layout of the network.

4 Linear programming applied to the network problem First, a basic feasible solution must be determined. Although, in the case of the transportation problem, an initial basic feasible solution is easy to determine by, for example, the Northwest-corner method, the Minimum matrix method, or the Vogel’s approximation method, in the general case an initial basic feasible solution may be difficult to find. The difficulty arises from the fact that the upper and lower bounds on the variables are treated implicitly and, hence, non-basic variables may be at either

-200 60

90 80

30

3

2

1

60

35 45

35 180

5

90 4

45 25

95

45

7

6 50 70

Fig.1: An example of a network problem

bound. Basic feasible solutions can be obtained by ‘solving’ spanning trees - a spanning tree is a connected sub-set of a network including all nodes and containing no loops. A spanning tree solution is obtained as follows: STEP (1) for the arcs not in the spanning tree (the non-basic arcs), set variables equal to zero; STEP (2) for the arcs that are in the spanning tree (the basic arcs), solve for variables in the system of linear equations provided by the node constraints. To determine whether this initial basic feasible solution is optimal, first the multipliers (dual variables), y i (i= 1, 2,...,n) are determined and then checked if these multipliers satisfy: C ij = C ij − y i + y j ≥ 0 if X ij = L ij (4)

Cij = C ij − y i + y j = 0, L ij < X ij < U ij (5) C ij = C ij − y i + y j ≤ 0

50

if X ij = U ij (6)

-300

If all the above conditions are met then the solution is an optimal one.

5 Spreadsheet Implementation of LP for Network Problem A spreadsheet model for solving the car distribution problem is shown in Fig.2. The cells in column B represent the decision variables. These cells correspond to the arcs in Fig.1 and indicate the number of cars to be transported between each of the locations. For example, cell B9 represents the number of cars to transport between 5 and 3. The total cost associated with any transportation plan is computed in cell G16 using the following Excel formula: =SUMPRODUCT(B5:B15,G5:G15) (7) Essentially, this formula computes the dot product of the two vectors formed by the cells B5 to B15 and G5 to G15. It also serves as the objective function to be minimised for this problem.

B

C

K

L

Car

From

To

Nodes

Net Flow

Demand or Supply

5

0

1

2

6

0

1

4

1

0

-200

2

0

7

0

2

3

90

80

3

0

60

8

0

3

9

0

5

5

35

4

0

90

3

45

5

0

180

10

0

5

4

35

6

0

70

11 12

0

5

6

45

7

0

-300

0

6

5

25

13

0

7

4

95

14

0

7

5

45

15

0

7

6

50

16

D

E

F

G

H

Cost per Unit 30 60

I

J

Total Cost: 0

Key cell formulae: Cell Formula Copied to G16 = SUMPRODUCT(B5:B15, G5:G15) K5=SUMIF(E$5:E$15,I5,B$5:B$15)-SUMIF(C$5:C$15,I5,B$5:B$15) K6:K11 Fig.2: Spreadsheet model for network problem A separate constraint is needed for each while the second SUMIF sums the number node in a network flow problem. If supplies of cars flowing out of 5. Specifically, the are represented by negative numbers and first SUMIF compares the values in the the demands are represented by positive range E5 through E15 with the value in I9. numbers, the flow constraint needed for If a match occurs, the corresponding value each node takes on the following form: in the range from B5 through B15 is TOTAL INFLOW - TOTAL OUTFLOW included in the sum. Since the values in ≥ SUPPLY or DEMAND (8) cells E8, E12 and E14 match the value in For instance, considering the constraint cell I9, the values in B8, B12 and B14 are needed for 5. It must be ensured that the included in the sum. Notice that B8, B12 total number of cars flowing into 5 (from 3, and B14 represent the number of cars 6 and 7) minus the total number of cars flowing into 5 from 3, 6 and 7, respectively. flowing out of 5 (to 3, 6 and 4) is at least The second SUMIF function in the 180 (the number of cars needed in 5). It formula for cell K9 compares the values in should be noted that for nodes with no the range C5 through C15 with the value in inflow, the above constraint relation I9 and, when a match occurs, sums the requires that the total outflow be less than corresponding values in B5 through B15. or equal to the available supply (because So the second SUMIF sums the values in here, supplies are represented by negative cells B9, B10 and B11. Notice that these numbers). cells correspond to the number of cars Fortunately, this type of flow constraint flowing out of 5 to 3, 4 and 6, respectively. can be implemented easily using two Thus, the formula in cell K9 computes the SUMIF functions. The formula shown in inflow of cars to 5. The same formula can Fig.2 for cell K9 illustrates the calculation be copied throughout cells K5 to K11 to of the left hand-side of the flow constraint compute the left hand-sides of all the other for 5. This formula is repeated below: flow constraints needed for this problem. =SUMIF(E$5:E$15,I9,B$5:B$15)To solve this problem one should attempt SUMIF(C$5:C$15,I9,B$5:B$15) (9) to minimise the total cost (in cell G16) by The first SUMIF function in this formula changing the number of cars transported sums the number of cars flowing into 5 between the various locations (cell B5

through B15) while keeping the net number of cars flowing through each location (cell K5 through K11) greater than or equal to the supply or demand for cars in each location (cell L5 through L11). Of course, this will also require that the number of cars transported between locations (cell B5 through B15) not to be less than zero. The settings required to implement these conditions and solve the problem are shown in Fig.3. The Simplex method of solving this linear program is applied by using the Solver facility within Excel which is given the instructions at the bottom of Fig.3.

The values in column B indicate the optimal number of cars that should be transported between each of the locations. The value in cell G16 indicates that the total cost of this transportation plan is 25300 units. Also it should be noted that a total of 230 cars (cell B14) enter 5 from 7 and a total of 50 cars (cell B9) leave 5 going to 3. Cell K9 indicates that this leaves exactly 180 cars in 5 to satisfy the demand there.

K

L

Nodes

Net Flow

Demand or Supply

30

1

-190

-200

4

60

2

90

90

3

80

3

60

60

3

5

35

4

90

90 180

D

E

G

B

C

F

Car

From

To

Cost per Unit

5

100

1

2

6

90

1

7

10

2

8

0

H

I

J

9

50

5

3

45

5

180

10

0

5

4

35

6

70

70

11

0

5

6

45

7

-300

-300

12

0

6

5

25

13

0

7

4

95

14

230

7

5

45

15

70

7

6

50

16

Minimise:G16;

Total Cost: 25,300

By changing:B5:B15; Subject to:K5:K11 ≥ L5:L11; Fig.3: Optimal solution of network problem

6 Genetic Algorithm Applied to the Network Problem The first step in the application of a GA is the coding of the variables that describe the problem [4]. The most common coding method is to transform the variables to a binary string of specific length. This string represents the chromosome of the problem and the length of the chromosome represents the number of zeros and ones in the binary string. By decoding the individuals of the initial population, the solution for each specific instance is determined and the value of the objective function that corresponds to this individual is evaluated. This applies to all members of the population.

B5:B15 ≥ 0

Genetic algorithms require the natural parameter set of the optimisation problem to be coded as a finite length string. For the car distribution example, there are eleven decision variables X ij as follows:

X12 , X 14 , X 23 , ..., X 76

(10) A spreadsheet model for solving this problem is shown in Fig.4. In this figure, the cells in column B represent the chromosome (decision variables) as follows: B5 , B 6 , B 7 , . . ., B15 (11) These cells correspond to the arcs in Fig.1 and indicate the number of cars to be transported between each of the locations. In the spreadsheet, cells K14:K16 and L13:L16 address the constraints, equation

B

C

K

L

Car

From

To

Cost per Unit

Nodes

Net Flow

Demand

5

100

1

2

30

1

-190

-200

6

90

1

7

10

2

4

60

2

90

90

3

80

3

60

60

8

0

9

50

3

5

35

4

90

90

5

3

45

5

180

180

10 11

0

5

4

35

6

70

70

0

5

6

45

7

-300

-300

12

0

6

5

25

13

0

7

4

95

14

230

7

5

45

15

70

7

6

50

TRUE

TRUE

Total Cost: 25300

TRUE

TRUE

Constraints met:

TRUE

16

D

E

F

G

17

H

I

J



Net Flow Demand TRUE

TRUE TRUE

Fig.4: Spreadsheet model for network problem using GA

(8). After applying the following Excel formulae the result is placed in cell L17. =AND($K$5 ≥ $L$5,$K$6 ≥ $L$6, $K$7 ≥ $L$7, $K$8 ≥ $L$8, $K$9 ≥ $L$9, $K$10 ≥ $L$10,$K$11 ≥ $L$11) (12) A steady-state GA is used here. This means that at each iteration two parent chromosomes are selected from the population for reproduction. These parents produce a child which is added into the existing population and the weakest member of the population is then deleted. The alternative generational GA produces a whole new population of children at each iteration. A rank based method is used here. This means that the members are ranked in order of their fitness and the probability of selection is inversely rated to this ranking. The advantage of a rank based approach is that it helps to avoid too rapid a rate of convergence that may lead to the population being swamped by a local optimum due to the loss of diversity [5-7]. The final step in the implementation of the GA is the application of the fitness function. In this case the objective is the minimisation of the network’s cost function, so the fitness value is the reciprocal of this cost. Before this function

is applied, the string must be decoded. Then, once the real value for each parameter is available, the fitness for that specific individual can be estimated. Within the spreadsheet, cell G16 shows the total cost of the car distribution problem is 25300 units. One of the advantages of the GA seen here is that the algorithm is only using fitness values for searching and thus solving the problem, in contrast to linear programming which needs a spanning tree to solve the problem and other specific knowledge of the application. The other attractive property of the GA that is demonstrated is its ease of application.

7 Results of GA The basic parameters of a genetic algorithm are the population size, the crossover rate and the mutation rate. By varying these parameters, the rate of convergence of the GA is altered. Thus, to maintain the robustness of the algorithm, it is important to assign appropriate values to these parameters. A population size of 50, a crossover rate of 0.5 and a mutation rate of (0.001, 0.006, and 0.011) are used in the experiments presented here. In Fig.5 the

effect of mutation rate on the rate of convergence of the GA is demonstrated whilst crossover rate and population size are fixed. With a mutation rate of 0.006 or 0.011 the GA reaches, within 4000

iterations, the optimal solution (25300) identified by linear programming. In contrast, with a mutation rate of 0.001 the rate of convergence is much poorer.

28000

Cost Function

Mutation Rate 27000 Pm = 0.006 Pm = 0.011 26000

Pm = 0.001

25000 0

1000

2000

3000

4000

Ite r a t i o n s

Fig.5: Effect of mutation rate on performance for crossover rate = 0.5 and population size = 50

8 Conclusions The network problem and its solution by linear programming (LP) have been reviewed. It has been shown that a GA can be applied easily to this model and for the example presented an optimal solution has been found without difficulty. It has been shown that the value of the mutation rate is important. As the mutation rate increases so the GA is replaced by a more random search. As mutation tends towards 0 so movement around the search space, and subsequent diversity in the population, is lost due to the comparative rarity in actually applying mutation.

References [1] T. Munakata and D. J. Hashier, A genetic algorithm applied to the maximum flow problem, Proceedings of the fifth International Conference on GA, 1993, pp.488-493. [2] W. Winston, Operations research applications and algorithms, Wads worth, Inc., 1994. [3] T. M. Ozan, Applied mathematical programming for production and

engineering management, PrenticeHall,1986. [4] L. Davis, Handbook of genetic algorithms, Reinhold, NewYork, 1991. [5] D. E. Goldberg and K. Deb, A comparative analysis of selection schemes used in GA’s, in G. Rawlins, ed., foundations of GA’s, Morgan Kaufmann, 1991. [6] J. E. Baker, Adaptive selection methods for GA’s, in J. J. Grefenstette, ed., Proceedings of First International Conference on GA’s, Erlbaum, 1985, pp. 101-111. [7] J. J. Grefenstette and J. E. Baker, How GA’s work: A critical look at implicit parallelism, Proceedings of Third International Conference on GA’s, 1989, pp. 20-27.