Pipe Diameter Optimization using Genetic Algorithm- A Case Study

A systematic study on the application of genetic algorithm (GA) in pipe diameter optimization was carried out. The aim of the study was to develop a genetic based programme and apply it to a case study, distribution system of Weligama water supply scheme. Then the performance of Genetic algorithm was compared with non linear programming (NLP). It was found that the genetic algorithm method using the standard three operators is particularly effective in finding global optimal solution for the case study network. It should be noted that the genetic algorithm technique is ideally suited to discrete problems such as selection of commercially availably pipe sizes.


Introduction
Optimization concept is intrinsically tied to human intuition. A desire for perfection or a search for the best is naturally demanded. As a vital part of the water supply systems, water distribution networks represent one of the largest infrastructure assets of water industrial society. In water supply design point of view, whether the ultimate goal is to assure for more reliable supply of water with respect to space and time, the achievements of economic advantage are more meaningful, because funds available for the development of new infrastructure become increasingly scarce. As a result, pipe network optimization becomes a field of study in its own right. Genetic algorithm is proposed as one possibility of optimum search algorithms. Since the early development by HOLLAND in 1975[4], the algorithms have been theoretically and empirically proved to be a very effective and robust search method. Advantages of genetic algorithm are due to its simplicity, straightforwardness and commitment for better and better solutions. Genetic algorithms were employed in a wide-ranging of pipe network optimization problems and the capability of genetic algorithms were evident in various research studies [7], [8], [12].

Literature Review
Golberg [2] examined the mechanics, power and application of a genetic algorithm to a steady state optimization of a serial liquid pipeline. The objective was to minimize power, while supplying a specified flow and maintaining allowable pressures. Simple three operator genetic algorithm was applied to the on-off control of 40 pumps in 10 pump stations along a serial pipeline. The pipeline model has been programmed in Pascal. Constraints have been adjoined to the problem with an exterior penalty function. The genetic algorithm was run with 100 population size. The probability of crossover and probability of mutation were taken as 0.7 and 0.01. It was found that GA gives near optimal operation pump schedules quickly.
Savic and Walters [7] described the development of the computer model GANET for the least cost design of water distribution networks and further more demonstrated the superior capability of GA against other optimization techniques. Least cost pipe network design was applied to a sample network with a single source at a 210m fixed head and eight pipes arranged in two loops. A binary string made of eight sub strings was used for coding the problem.
The evaluation function determined the cost of a solution. Rank selection was used for reproduction. Ultimate results showed that the CIA produces good design. Meier [5] described the use of a GA to optimize the sampling design. GA was applied to a network model for a small town in Ohio. Probability of crossover and mutation was taken as 0.7 and 0.02 respectively. GA was shown to perform extremely well, matching the optimal solution produced by complete c'liumeration in a series of validation tests.

Study Area
GA is applied to a water supply pipe network in Weligama area in Matara district which has been constructed in 1991. Reproduction operator selects the effective strings from population relying on their objective functions or fitness values. Effective strings are then controlled to breed for new generation by crossover. Hence, new strings are introduced by gathering information from fittest pairs of string or chosen mate. Mutation operator simulates a natural adaptation by transmuting some bits in string to prevent irrecoverable losses of data. Penalty function is introduced to prevent searching in constrained violating domain.
Termination criteria are predefined to stop the search algorithms.

Pipe network Optimization
Water distribution network optimization is a procedure to seek for design variables of a network to its goal of optimality, within the constraints. Objective function or the cost function should be formulated whose least values is searched in an optimization procedure.

General pipe network Optimization Problem
Objective function of the general pipe network optimization problem can be shown as; of the junction and external inflow or demand at the junction node respectively. Where Q in , Q out and Q e are flow into the junction , out of the junction and external inflow or demand at the junction node respectively.
For each loop, Where h, and E are head loss and energy put into the liquid by a pump.
For each node, Where H jt H max and H rain are head at node j, maximum and minimum allowable head respectively.
For each pipe, Where V jt F max and V min are velocity at pipe j, maximum and minimum allowable flow velocity respectively.

Computer Program of Three Operator Genetic algorithm
Microsoft visual C++ version 6.0 was used and the programme was written in C language. Elevation, nodal demand, available pipe diameter sizes and their unit prices were the input data files.
Binary coding is used to code the decision variable. GA generates the initial population of solutions (of say, size N=100) using a random number generator. Number of population

Assumptions and design criteria
The following assumptions were made in hydraulic design.
• The minimum service pressure head in the distribution system should not be less than 10m and the maximum service pressure head should not higher than 50m. To evaluate the fitness of a string , the string must be converted into a design solution by mapping a string value onto a variable value. Assume one bit of one substring for one variable is represented as ai, aa a n , the value of the substring (corresponding diameter index) can be calculated as   The head loss equation is expressed for each pipe and the continuity equation is applied at each node throughout the water supply distribution system. The flow and head loss conditions are determined for each pipe in the loops by solving the two equations iteratively.
Knowing the flow rate through each pipe, velocities can be calculated.
Q, v,= (8) Knowing the head loss and elevation at each node, pressure head can be calculated.
The total penalty cost is taken as the summation of the product of the pressure head constraint violations (Pi) times a specified penalty multiplier (Ri) and the product of the velocity constraint violations (?2) times a specified penalty multiplier (Ri). RI is a measure of the worth per metre attributed to pressure heads below and above the allowable minimum and maximum pressure heads. RI is a measure of the worth per metre attributed to velocities below and above the allowable minimum and maximum velocities.
Fitness of each population is calculated as the summation of network cost and the total penalty cost [8].
Where F(D) = (9) ),,£,), c(Dj,Li) is the cost of the pipe with the diameter D, and the length Li, and N is the total number of pipes in the system.
Then the GA generated new members of the new generation by tournament selection method, where two or more chromosomes are randomly picked from the population, and the best one selected for further genetic processing.
The uniform crossover operator is practiced next. It is the partial exchange of bits between two parent strings to form two offspring strings. A crossover probability (p c ) is assumed between (0.5-1.0). The GA randomly picks two strings from the new population. A uniformly distributed random number is then generated in the range 0.0 and 1.0. The GA applies the crossover operator if the random number is less than the probability of crossover.
To ensure no important genetic material is lost, Mutation operator is applied. A probability of mutation (p m ) is assumed between 0.01-0.1. The GA considers each string bit by bit in the new generation formed as a result of reproduction and crossover. A uniformly distributed random number in the range of 0.01 to 0.1 is generated. GA applies the mutation operator if the random number is less than the probability of mutation. Otherwise the GA does not apply mutation to that particular bit. The mutation operator changes the value of the bit to the opposite value, (i.e. a 0 to 1 or a 1 to 0).This procedure repeats until the optimal value is reached.This solution is tested with the Loop hydraulic simulation model. The case study problem is solved using the nonlinear optimization package, "GAMS". The General Algebraic Modelling System (GAMS) language is formally similar to commonly used programming languages. GAMS analysis is carried out independently of genetic algorithm analysis.
A cost function for pipes is fitted ( Figure 2) and it is given below (Equation 10).

Searching of global optimality
Five runs for the case study network problem using different random number seeds were carried out to check whether the global optimality is achieved. A maximum of 50,000 functional evaluations were permitted for each run. The lowest cost achieved in each run is presented in table 2. The least cost was found at the first of 300 generation. Twenty additional runs were performed to assess the sensitivity of the technique to parameter settings. The quality of solution obtained from GA depends upon several important parameters, such as, population size, probability of crossover (p c ) and probability of mutation (p m ). Each parameter was examined during testing process, in the way that only the testing parameter was changed while the others were kept constant. Table 3 shows the GA parameters and lowest cost results.

Effect of Population Size
Several population sizes were examined. The best number for the population size is taken as 200, since it gives the lowest cost. The probabilities of crossover of 0.5, 0.7, and 1.0 were examined and the effect is shown in the F ; igure 4. It shows no effect of probability of cross over.

Effect of Probability of Mutation
Several probabilities of mutation were examined and the effect is shown in the Figure  5. The best value for the probability of mutation was taken as 0.04 ,since it gives the minimum cost.

Result of Non Linear Program
It gave the least cost as M $ 0.11. The optimization run took 3.5CPU min on a Pentium 4, CPU 1600 MHz, RAM 130,544 KB computer. The solutions given by NLP are shown in Table 5. Many of the values given as pipe diameters could not found in the market. Therefore it is needed to round up the pipe sizes to the nearest available diameter manually and run Loop software to ensure the rounded solution satisfies the constraints. Then the result came similar to that of genetic algorithm.

Conclusions
Non linear optimization is the fastest of the two optimization techniques applied to the case study network. But one needs to fit a cost function to the discrete pipe cost data and this may leads to inaccuracies. On the other hand it is needed to round the continuous solution found either up or down to the nearest discrete pipe sizes manually. Additional computer runs are needed in Loop software to ensure that the rounded solution actually satisfies pressure and velocity constraints. Therefore, although non linear optimization is quick, reaching to a required discrete pipe solution takes days.