GAPinch : Genetic Algorithm Toolbox for Water Pinch Technology Detchasit PRAKOTPOL Chemical Engineering Practice School, Department of Chemical Engineering, Faculty of Engineering, King Mongkut's University of Technology Thonburi, Bangkok 10140, THAILAND Thongchai SRINOPHAKUN* Department of Chemical Engineering, Faculty of Engineering, Kasetsart University, Bangkok 10903, THAILAND * To whom all correspondence should be addressed. * Tel. 66-2-9428555 ext. 1214 * Fax. 66-2-5792083 * E-mail: fengtcs@ku.ac.th Abstract Wastewater in the chemical industry can be minimized by water reuse. The optimum water usage network leads to a minimum freshwater consumption and wastewater treatment. Genetic algorithm, an objective of this work, is developed for solving the wastewater minimization problem. The optimization model is formulated for both single and multiple contaminants in the class of mixed integer nonlinear programming (MINLP). In this model, there is a set of equality constraints from mass balance that drives the genetic algorithm from addressing the feasible solution. To elucidate this problem, all of variables have to be divided into 2 groups; independent and dependent variables. The values of independent variables come from randomization whereas the values of dependent variables come from simultaneous solutions of a set of equality constraints after assigning the values of independent variables. This method is applied to the steps of Initialization, Crossover and Mutation. The developed program is the MATLAB toolbox that consists of 29 m-file. The graphic user interface was created in order to make the program can be used easily and conveniently. After a user inputs the process condition of the problem into the blank form of GUI, the program will formulate the optimization model and solve for the solution automatically. Then, the optimum results are returned to the user. The program is tested with a process that contains a certain number of water-using operations in which water is used to remove a fixed content of contaminant. In the single contaminant system, this program and Lingo can find the minimum freshwater consumption but the solutions are different in the configuration of water usage network. These alternative configurations give a wide-vision on the analysis of the system. In the multiple contaminants system, this program can find the same or better results in some test problems. Keywords Wastewater Minimization, Genetic Algorithm Introduction In the chemical industry, wastewater is generated from many sources in the process. Because of environmental impact, wastewater must be reduced to an acceptable level before being discharged. Large amounts of wastewater cause high cost for effluent treatments. Prior to focusing on wastewater treatment, wastewater production should be minimized. In addition to reducing treatment cost, wastewater minimization can also reduce the freshwater costs. There are three approaches to reduce wastewater excluding process changes that reduce the inherent demand for water [1]; Re-use, Regeneration re-use and Regeneration recycling. Several studies have been reported showing the application of these approaches. Wang and Smith [1] addressed the case study of minimization of wastewater in the petroleum refinery. Through re-use, freshwater consumption, wastewater generation and total cost was reduced by 20 percent. Adding regeneration process without recycle reduced freshwater and wastewater flowrate by nearly 60 percent and reduced cost by more than 60 percent. In Suriyaprapadilok’s work [2], nonlinear programming (NLP) was formulated to solve for the optimum water-using network in tapioca plant. At the optimum, the freshwater consumption is minimum. A 13.22 percent reduction of freshwater usage is obtained. In developing an optimal design of water using network target to minimize wastewater, engineers face selection of the best choice from a vast number of process alternatives. This is an optimization problem that requires an appropriate technique to identify the best result. In wastewater minimization problem involving single key contaminant, the optimization programming can be formulated as a linear programming (LP) problem. For multiple contaminants, the mathematical representation is in the class of nonlinear programming (NLP). This class of problem has more than one local optimum. The accuracy and efficiency of conventional techniques for finding the global optimum depend on the initial guess. The inappropriate one leads to the solution getting stuck at the local optimum. A wellknown technique for avoiding local optima in improving search is genetic algorithms (GAs). Genetic algorithms (GAs) are search algorithms based on the mechanics of natural selection and natural genetics. They are a direct search method based on principle of evolution and heredity [3]. GAs have been developed by John Holland, his colleagues and his students at the University of Michigan since 1960s. GAs have been successfully applied to a wide variety of problems including multimodal function optimization. Algorithm is started with a set of random solutions called population. Individual solution is represented in encoded form called chromosome. Each chromosome comprises of individual structures called genes. Solutions from one population are used to form a new population. This is motivated by a hope that the new population will be better than an old one. In order to form a new population, GAs use genetic operators and selection process. Genetic operators are used to generate the new solutions (offspring) from the current solutions (parents). Selection is the process of keeping and deleting some solutions from both parents and offspring for the same number of next population. Moreover, selection is the process of choosing some parents to generate offspring also. In the selection process, the solutions are selected according to their values of objective function (fitness). The more fitness has, the more chance of be selected. The algorithms will repeat until a termination condition is satisfied. The best solution is returned to represent the optimum solution. The procedure of GAs can be described in the following steps [4]. 1. Choose a randomly generated population (feasible candidate solution). 2. Calculate the fitness at each chromosome in the population. 3. Selection process with the chosen population to evolve for new population by genetic operation. 4. Create a new population by genetic operator: crossover and mutation. 5. Check termination condition. In 2000, Wasanapradit [4] developed a new effective method of genetic algorithm to solve general MINLP problem. The specific methods for each step of genetic algorithms are as follow: Real Number Representation Real number representation is used to represent the solutions. For the example, the solution has 4 variables, x1 = 20.22, x2 = 1.55, x3 = 0, x4 = 5.09. The vector that represents this solution is < 20.22 1.55 0 5.09>. Arithmetical Crossover Arithmetical Crossover is defined as a linear combination of two vectors. For example, if v1 and v2 are selected to undergo a crossover, then the offspring can be calculated from equations (1) and (2). (1) v1 a v1 (1 a) v 2 v2 a v 2 (1 a) v1 v1 = < 5.22 14.05>; v2 = < 9.95 4.31>; a = 0.4 v1 = 0.4 <5.22 14.05> + (1-0.4) < 9.95 = <8.058 8.206> v2 = <7.112 10.154> (2) 4.31> Transformation Based Mutation By transformation based mutation, a chromosome is selected the positions of genes undergoing mutation randomly. After that, these genes are replaced with new values between the lower and upper bound of those genes. Repair Strategy Repair Strategy is used to convert the infeasible solutions to the feasible ones. The general form of in equality constraints is gi(x) bi In order to repair any solution, the feasibility of any solution is calculated first by equation: S(x) = max(gi(x) – bi) (3) If S(x) is negative that means this solution is feasible. It stays in the feasible area of the problem. The positive sign means this solution cannot satisfy some or all the inequality constraints. It is an infeasible solution. Zero value of S(x) means this solution stay on the constraint boundary. The purpose of repair algorithm is to convert a solution with S(x) > 0 to one S(x) = 0. Such procedure corresponds to the root finding of equation with a numerical method. Therefore, secant method incorporating the bisection method was modified to achieve this goal. The secant method was selected because of its high speed in equation root finding. However, it often diverges when the initial points were not suitable. Thus, the bisection method, the promising method but slower, was combined in order to find the new suitable initial points for secant method. The simultaneous secant and bisection method can calculate the new solution by using equations (4) and (5), respectively. xi 1 xi S ( xi )( x x 1 xi ) S ( xi 1 ) S ( xi ) x i1 x i2 x i 1 2 (4) (5) This is bisection formula. i is number of iteration. Each iteration, there are two solution and the new solution is the middle of these two points that are the solution from the latest iteration ( xi1 and x i2 ). Therefore, xi1 is a solution of iteration ith and x i2 is an another solution of iteration ith. The procedure of the program of the secant method combined with the bisection method is given in Figure 1[4]. Begin Xl , Xr, Fl , Fr, Ib=1 Set iter_maxb i=1,BiS=0 Input max_iter, tol Xnew = 0.5(xl+xr) Input xi-1 xI, Calculate fnew Ib=Ib+1 Calculate f(xi-1), f(xi) Yes No Fnew*fl > 0 Calculate xI+1 , f(xI+1) xl = xnew Fl=fnew i=i+1 f(xI)tol Yes No Yes Fnew tol No I max_iter i max_iter No Bis = 1 Yes xr = xnew Fr=fnew No No Bis =1 Yes Return Figure 1 The Program of Secant Method Combine with Bisection Method [4] Yes Cross-Generation Probabilistic Survival Selection (CPSS) CPSS is the selection method that can keep the diversity of population. This method is developed to prevent a premature convergence problem in traditional genetic algorithms. By CPSS, a selection possibility does not depend on the fitness of solution only. It also depends on the structure of the solutions. A selection probability for each solution can be calculated by using equation (6). h p s (1 m ) m L (6) Where h is the hamming distance between the candidate solution and the solution with the best fitness value. L is the length of the string representing the chromosome. m is the shape coefficient and is the exponent. The hamming distance (h) can be calculated by this equation. h ( v1 v1 ) 2 ... ( v k vk ) 2 (7) Where v i and v i are i gene of the candidate solution and the fittest solution. For the length of string representing the solution (L), it can express as follow. L = max ( h j ); j = 1, …, number of population th For mixed integer problems, the calculation of h and L must be separated between real and integer variables. After that, the results are combined together with a weight factor. Therefore, h and L for mixed integer problems can be determined by using the following equations. (8) h w hR (1 w )hI L w LR (1 w ) LI (9) Where w is the weight factor. Its value depends on the importance of variables. In this work, a value of 0.5 for the weight factor is used. The subscript R and I indicate real and integer variables, respectively. The procedure of CPSS is as follows: 1. Eliminate duplicated structure (new population) from the combined population of parent and offspring. 2. The best solution is kept first. 3. Calculate a selection probability (ps) for each solution. 4. Generate a random number for each solution. If the generated random number is smaller than ps, the solution is selected. Otherwise it is deleted. 5. If the number of current population is smaller than population size, the new structures are generated randomly by the insufficient number. If the number of current population is greater than population size, the fitter ones are selected. 2. Problem Statement The process contains a certain amount of water to reduce a fixed content of contaminant. This water is considered as a contaminant-rich stream. It transfers some contaminants to a contaminant-lean stream; the water. The contaminants may correspond to suspended solid (SS), chemical oxygen demand (COD), or similar quantities whose concentration levels limit the reuse of the effluent water in the other operations. The water using operation represented by the mass transfer of these two streams is shown in Figure 2. Rich Stream Mass Transfer Lean Stream (water) Figure 2 The Process Stream Representation of Water Using Operation From Figure 2, the contaminant concentration of the water inlet and outlet is limited by the concentration at the outlet and inlet of the rich stream, respectively. The lean stream (water) entering any unit operation must have a lower contaminant concentration than the concentration of the rich stream outlet and the wastewater leaving must have a lower concentration than the concentration of the rich stream inlet. Mann and Liu [3] addressed the method to formulate the water networks as linear programming (LP) and nonlinear programming (NLP) for single and multiple contaminants system, respectively. The solution of those models is the optimal allocation of species and streams throughout the process with minimum freshwater flowrate target. Single Contaminant-Water Reuse Figure 3 illustrates the superstructure model of any water using operation in water reuse process. Fi X i , j Xi, j Cj, out i j C i ,in Xj, i Ci, out Operation i Wi F i Ci, out Figure 3 Superstructure Model of Any Operation of Water Reuse Process The objective function which is the minimum total freshwater flowrate can be defined as equation (10). F = Fi ; number of i is equal to number of unit operation (10) i Then, the constraints of the mass balance and maximum inlet concentration are formulated. The water mass balance around each unit operation i in Figure 3 is (11) Fi X i , j Wi X j ,i 0 j i j i The contaminant mass balance around each operation can be formulated as follows: (12) C j ,out X i , j mi C i ,out (Wi X j ,i ) 0 j i j i The average inlet concentration must be smaller than or equal to minimum allowable concentration at the inlet, C imax , in . This constraint is formulated as follows: Ci ,in X j i i, j X j i C i j ,out i, j Cimax ,in Fi (13) The outlet concentration is the sum of the average inlet concentration and the change in concentration due to the fixed mass load of contaminant transferred. To maximize water reuse, the outlet concentration is forced to reach the limiting outlet concentration. Then, equations (12) and (13) become equations (14) and (15), respectively. max j C j ,out X i , j mi C i ,out (Wi X j ,i ) 0 j i X i, j X i, j j i j i (14) j i C ij ,out Fi Cimax ,in (15) Finally, an LP is formulated. The objective is to minimize equation (10) with the constraints of equations (11), (14) and (15). Single Contaminant-Regeneration Recycle The superstructure model with the regeneration process included can be shown in Figure 4. Xi, j Cj, out Fi Fi C i , in Xi,j ij Xj, i Ci, out X i ,r Wi Ci, out Operation i Xi, r Co Xr, i Ci, out Xr, i Ci, out Regeneration Process Xi, r Co Figure 4 The Superstructure Model of Regeneration Recycle Process According to Figure 4, a water balance around the regeneration process is as follows: ; number of j is equal to number of unit operation (16) X j ,r X r , j j j In order to handle this type of process, equations (11), (14) and (15) should be modified to become equations (17) to (19) (17) Fi X i , j X i ,r Wi X j ,i X r ,i 0 j i max C j ,out X i , j j i j i C o X i ,r mi Cimax ,out (Wi X j ,i X r ,i ) 0 X C X C X F X j i j i i, j i, j max j ,out i ,r i (18) j i o Cimax ,in (19) i ,r The linear programming to optimize the water network including the regeneration process is to minimize equation (10) subject to equations (16) to (19). Multiple Contaminants-Water Reuse The superstructure model of water reuse process that is multiple contaminants system is illustrated in Figure 5. Xi, j Cj ,k, out Fi X i , j i j C i ,k ,in Fi Xj, i Ci,k, out Operation i Wi Ci, k, out Figure 5 Superstructure Model of Multiple Contaminants-Water Reuse In the multiple contaminants system, water balance around each process is the same as equation (11) for single contaminant but the contaminant balance and constraints from maximum inlet concentration have to be modified for each type of contaminant. The contaminant k balance around operation i is: C j , k , out X i , j mi , k C i , k , out (Wi X j ,i ) 0 j i j i (20) The constraints from the maximum inlet concentration of contaminant k to operation i is: X i , j C j ,k ,out j i (21) Cimax ,k ,in X F i, j i j i For the multiple contaminants system, the outlet concentration of each contaminant from any operations cannot be fixed. Since, they are unknown then equations (20) and (21) are nonlinear. Therefore, the nonlinear programming is used to minimize equation (10) subject to equations (11), (20) and (21). The mathematical formulations of the single and multiple contaminants system are LP and NLP, respectively. These models target the minimum total fresh water feed subject to water and contaminant balance and maximum allowable concentration at inlet of each unit operation. Methodology In this paper, these following assumptions are made to the process. 1. The mass separating agent (MSA) is water only. It is used in any unit operation throughout the process industries. 2. The mass flowrate of each stream are constant as it passes through the network. 3. Mass load of each contaminant in any unit operation is held at constant. 4. No equilibrium relation governs the distribution of contaminants in water. 5. In single contaminant system, the outlet concentration of any unit operation is equal to the limiting outlet concentration in order to maximize water reuse. 6. In multiple contaminants system, the transfer of any contaminant is proportional to the transfer of the others. In some optimization techniques, such as linear programming, inequality constraints are converted into equality constraints by the addition of slack or surplus variables. In contrast, for genetic algorithms that generate solutions randomly, such equality constraints are a bother. GAs cannot produce solutions that satisfy these constraints randomly and wastewater minimization confronts this problem because of mass balance. Therefore, the problem of this equality constraints has to be handled before the optimization model is solved by GAs. The equality constraints in each type of process can be handled by these techniques. Degree of freedom (DOF) for Single Contaminant-Water Reuse Model In this kind of problem, all of the variables can be divided into three groups 1. Freshwater flowrate (Fi) 2. Wastewater flowrate (Wi) 3. Reused water flowrate (Xi,j) The possible number of freshwater and wastewater stream is equal to the number of unit operation. So, there are 2N variables that represent the flowrate of these streams. They are: F = [F1, F2, . . ., FN] W = [W1, W2, . . ., WN] There are N2-N variables that represent the flowrates of reused stream. All of the possible reused streams from any operations to the others can be represented by this matrix. 0 X 2,1 X X 3,1 X N,1 X1,2 X 1,3 ... X 1,N 0 X 2,3 ... X 2,N X 3,2 0 ... X 3,N ... X N,2 X N,3 ... 0 Hence, the total number of variables is N + N + N2-N = N2 + N variables. The optimization model of this process contains N equality constraints from water balance and N equality constraints from contaminant balance around each operation. Hence, there are 2N equations of N2 + N variables. If the values of N2 – N variables are fixed, the rest 2N variables can be determined by solving the 2N equations simultaneously. In the other words, the value of 2N variables depends on the others. As mentioned early, the number of variables, which are reused water flowrate, is N2 – N. This number is equal to the number of variables that must be fixed. Moreover, after assigned the value of reused water flowrate, the 2N equations are still independent and can be solved simultaneously. Thus, reused water flowrate is selected to be the independent variables from randomization by GAs. The remainders are the dependent variables. Their values come from the solution of the equality constraints after assigned the random value of independent variables. Single Contaminant-Regeneration Recycle When regeneration process is included, there are 2N variables more than water reuse without regeneration. These adding variables are the flowrate of regenerated water to each operation and wastewater from each operation to regeneration process. These variables can be represented by this matrix: R1,r R 2 ,r R R N ,r Rr ,1 Rr , 2 Rr ,N Although there are 2N variables more, there is only one equation excessed. It is the mass balance around regeneration process. So, in regeneration recycle process, there are 2N+1 equality constraints of N2 + 3N variables. In this case, the values of N2+N-1 variables have to be known before solving 2N+1 equations simultaneously. Same as in water reuse, the flowrate of reused water (N2-N variables) is selected to be the independent variables. The rest of independent variables come from matrix R except Rr, N (2N-1 variables). Multiple Contaminants-Water Reuse In multiple contaminants system that contains N operations and M contaminants, there are N+NM equality constraints. They come from N water balance and NM contaminant balance around each operation. These variables can be divided into 4 groups. The first three groups are same as in the single contaminant system. They are the flowrate of freshwater, wastewater and reused water. The number of variables in these groups is N2+N variables which are equal to the single contaminant. The fourth group of variable is the outlet concentration of each contaminant of each operation. The number of these variables is NM variables. Therefore, the total number of variables for multiple contaminants system is N2+N+NM variables. So, the number of independent variable is equal to N2. In this work, the freshwater flowrate and reused water are selected to be the independent variables. 4. Model Set Up According to the previous mention, the wastewater minimization problem of single and multiple contaminants can be formulated as LP and NLP, respectively. In this paper, the problem formulation was developed to be suitable for using with genetic algorithms. Binary variables are introduced to the problem. These variables represent any possible streams in the process. The mathematical representation of these problems is in the class of mixed integer nonlinear programming (MINLP). Binary variable is applied to only independent variables. It is not necessary to apply on dependent variables because the values of dependent variable come from calculations. Binary variables can be included in the optimization model by multiplying the binary variable and the independent variable together. Example An industrial system with three separate water-using operations; called operations 1, 2, and 3 is considered. In this process, only one contaminant is diluted during transferred through those operations. Table 1 shows the limiting process data of the water reuse process of a single contaminant system. Table 1 Limiting Process Data of the process [3; page 36] m lim Operation C (ppm) in (kg/hr) 1 3.75 0 2 1 50 3 1 75 lim C out (ppm) 75 100 125 Then the optimization model is the following: Objective Function F = F1 + F2 + F3 (22) Constraints: 1) Mass Balance around each unit Operation F1 B1, 2 X1, 2 B1,3 X1,3 W1 B2,1 X 2,1 B3,1 X 3,1 0 F2 B2,1 X 2,1 B2,3 X 2,3 W2 B1, 2 X 1, 2 B3, 2 X 3, 2 0 F3 B3,1 X 3,1 B3, 2 X 3, 2 W3 B1,3 X 1,3 B2,3 X 2,3 0 (23) (24) (25) Where Bi, j is binary variable. Bi, j equals one when the reused stream from operation j to i appears in the process, otherwise it is zero. 2) Contaminant Balance around each unit Operation 3750 100 B1, 2 X 1, 2 125B1,3 X 1,3 75(W1 B2,1 X 2,1 B3,1 X 3,1 ) 0 1000 75B2,1 X 2,1 125B2,3 X 2,3 100(W2 B1, 2 X 1, 2 B3, 2 X 3, 2 ) 0 1000 75B3,1 X 3,1 100 B3, 2 X 3, 2 125(W3 B1,3 X1,3 B2,3 X 2,3 ) 0 (26) (27) (28) 3) Maximum inlet concentration of each operation 100 B1, 2 X 1, 2 125 B1,3 X 1,3 0 F1 B1, 2 X 1, 2 B1,3 X 1,3 75 B2 ,1 X 2 ,1 125 B2 ,3 X 2 ,3 50 F2 B2 ,1 X 2 ,1 B2 ,3 X 2 ,3 75 B3,1 X 3,1 100 B3, 2 X 3, 2 75 F3 B3,1 X 3,1 B3, 2 X 3, 2 (29) (30) (31) Then, MINLP can be set up by minimizing equation (22), subject to equations (23) – (31) and boundary limits of all variables. Initialization Initialization is the first step of genetic algorithms. It generates a group of initial solutions randomly. For the wastewater minimization problems that have a lot of equality constraints, it is impossible to produce the feasible solution by randomly generating the value of every variable. Thus, the initialization in this work is divided into 3 steps. The first step is to generate the value of X ij (i j ) as independent variables, randomly. They give the correspondent values to the binary variables for the model. Then, the second step is to calculate the values of dependent variables. A solution that is produced by this method will be guaranteed satisfy all the equality constraints. Finally, the feasibility of the solution should be checked by the inequality constraints and boundary limit of each variable. Crossover and Mutation Crossover and mutation are the methods for producing a new solution from the old one. Because of equality constraints, the new solutions from changing the values of some variables will break the equalities. This new solutions are always infeasible. Thus, crossover and mutation must be requested only on the independent variables. And then, these variables should be used to calculate the dependent variables. Graphic User Interface (GUI) In this work, graphic user interface was built. The user just give the input of the limiting process data and the program will formulate the optimization programming automatically. By this methodology, the GAs based program can be developed. The wastewater minimization problem is formulated as MINLP. By classifying the variables into independent and dependent variables, the initialization, crossover and mutation produce the feasible solutions. After the GAs based program is developed, it is used to solve the wastewater minimization problem. Then, the results are compared to either from Lingo or from literatures. The genetic parameters and the method of genetic operator used in the testing are concluded in Table 2. Table 2 Genetic Parameters and Genetic Operators Genetic Parameters/Operators Value/Method Population size 15 Probability of crossover, Pc 0.3 Probability of mutation, Pm 0.1 Crossover Arithmetical crossover Mutation Transformation based mutation Handling constraint strategy CPSS Selection Selection These parameters are used in GAs toolbox [5] and the series of case study are implemented as in the following sections and in the appendix. Note that the solution of Table 1 is the problem no.1 in the appendix. Results Single Contaminant – Water Reuse The limiting process data for an example problem of water reuse process of the single contaminant system are shown in Figure 6. The results from GAs based program are shown in Figure 7. Then, the results are used to construct the optimum water-using network and compared to the results from [3] as shown in Figure 8. Figure 6 Figure 7 Limiting Process Data for an Example Problem of Single Contaminant – Water Reuse [6] Results of Single Contaminant – Water Reuse Problem As one can see that the minimum freshwater consumption and minimum wastewater generated are the same at 89.375 tons/hr. However, there are some differences in parts of stream and configuration. In the water-using network from Lingo, wastewater from operation 1 is reused in operations 2 and 3 but it is reused in every operation according to the results from GAs. Moreover, GAs allows the wastewater from operation 2 to be reused in operation 3 while this stream does not occur in Lingo’s result. This test problem seems to indicate that the result from Lingo is better because of lower capital cost investment especially a piping. 12 t/hr 25 t/hr 25 (250) 30 (150 ppm) Operation 1 7 (250) 89.375 t/hr (0 ppm) 19.375 t/hr 30 (400) 10.625 55.833 (31.3 ppm) 48.833 t/hr Operation 3 (a) 55.833 (500) Operation 2 70 t/hr (500 ppm) 70 (300) Operation 4 3.542 t/hr 13.8038 7.1813 25 Operation 1 3.6853 (250 ppm) 89.375 (0 ppm) 53.0711 (17.36) 49.3858 Operation 2 1.1854 Figure 8 29.9978 (149.98) (b) Operation 3 29.9978 (400) 19.375 9.0127 14.1333 53.071 (300) 10.6228 Operation 4 89.375 (478.32 ppm) 70 (500 ppm) 70 (300) Optimum Water-Using Network for an Example Problem of Single Contaminant – Water Reuse (a) Results from Lingo [3] (b) Results from GAs Based Program Single Contaminant – Regeneration Recycle The limiting process data for an example problem of regeneration recycle process of the single contaminant system are shown in Figure 9. The outlet concentration of regeneration process is 25 ppm. Figure 9 Limiting Process Data for an Example Problem of Single Contaminant – Regeneration Recycle[3] The optimum water-using networks that are constructed from the results from Lingo and GAs based program are shown in Figure 10. 35.57 13.33 75 0.5 26.67 Operation 1 39.30 Operation 2 Regeneration 0.70 Operation 4 39.43 13.92 4.01 3.82 13.33 21.50 8.17 Operation 3 (a) 13.27 39.04 75 Operation 1 50 Operation 4 40.64 11.73 Figure 10 Regeneration 13.33 Operation 3 Operation 2 13.33 (b) 9.36 Optimum Water-Using Network for an Example Problem of Single Contaminant – Regeneration Recycle (a) Results from Lingo [3] (b) Results from GAs Based Program Even the total amount of flow is the same, complicated network or piping has to be set when simulates with Lingo. Multiple Contaminants – Water Reuse The limiting process data for an example problem of water reuse process of the multiple contaminants system are shown in Figure 11. Limiting Process Data for an Example Problem of Multiple Contaminants – Water Reuse [1] The optimum water-using networks from GAs based program and Lingo are compared in Figure 12. Figure 11 45 Operation 1 45 (15,400,35) 19.5 25.5 108.32 8.5 54.82 8.45 (a) 105.62 (0 ppm.) Operation 2 Operation 3 Operation 2 108.32 34 (111.25,12500,161.25) 54.82 (102.15,25.54,9500) 34 (111.3,12500,161.3) 25.55 (15,400,35) 45 Operation 1 16.79 105.62 2.66 (15,400,35) (b) Figure 12 52.17 Operation 3 54.83 (102.9,45,9500) Optimum Water- Using Network for an Example Problem of Multiple Contaminants – Water Reuse Problem (a) Results from Lingo (b) Results from GAs Based Program From Figure 12, the minimum freshwater consumption from the two programs are different. The results from GAs is 105.82 tons/hr while the results from Lingo is 108.32 tons/hr. The optimum water-using network from GAs based program has the reused stream from operation 1 to operation 3 but the one from Lingo does not has this stream. It shows the freshwater requirement from GAs is less than from Lingo because of the more amount of water reused. The Other Test Problems Several problems are used to validate this GAs based program. The program runs on an AMD Athlon 1000 MHz. computer. Table 3 shows the comparison of minimum freshwater used from this program with the well-known optimization software, Lingo, and the other tools or techniques from literatures such as GAMS, graphical method and the other proposed methods. Table 3 The Results Summary of the Other Test Problems Minimum freshwater Number (tons/hour) Problem Computational Process type of number. GAs Lingo Literature* time (minute) operation [3] 1 Single/reuse 3 56.67 56.67 56.67 [3] 0.15 2 Single/reuse 4 90.00 90.00 90.00 [1] 0.19 3 Single/reuse 4 89.375 89.375 89.375 [6] 3.24 4 Single/reuse 4 63.33 63.33 63.33 [3] 12.26 5 Single/reuse 5 30 30 30 [3] 14.58 6 Single/recycle 3 30 30 30 [3] 0.65 7 Single/recycle 3 60 60 60 [3] 0.52 8 Single/recycle 4 75 75 75 [3] 1.07 9 Single/recycle 4 60 60 60 [3] 1.79 10 Multiple/reuse 2 60 65 60 [3] 6.28 11 Multiple/reuse 2 54 63.33 54 [1] 20.39 12 Multiple/reuse 2 100.57 100.57 104 [6] 14.02 13 Multiple/reuse 3 70 79.67 70 [3] 206.18 14 Multiple/reuse 3 105.62 108.32 106 [1] 215.15 * [ _ ] : references. Discussion The results from test problems show that GAs based program can be used to solve the wastewater minimization problem. It can be found that the minimum freshwater consumption or wastewater generated is equal to the other authors but with different configurations. These alternative configurations give the wide-vision on the analysis of the system. To decide which one is better, all the capital and operating cost must be included in the optimization. In some multiple contaminants problems, GAs give usually better results because genetic operators have the ability to avoid getting stuck in a local optimum like it occurs sometimes in the conventional optimization techniques. This ability leads the GAs based program to obtain global optimum or near the global optimum. For the computational time, GAs spend quite a long time when used with multiple contaminants problems. In some problems, it spends more than an hour to obtain the optimum. So, the algorithm should be improved to overcome this deficiency Conclusion In this work, a genetic algorithms (GAs) based program; GAPinch, is developed to solve the wastewater minimization problem. This prototype covers both single and multiple contaminants system. For single contaminant, it can be used for water reuse and regeneration recycle process. For multiple contaminants, it can be used for water reuse process. The optimization model of wastewater minimization problem can be formulated as MINLP. This MINLP targets to minimize the total freshwater feed to the process subject to water and contaminant mass balance around each operation and maximum inlet concentration of each operation. This problem of equality constraints are handled by dividing all variables into two groups, independent and dependent variables. The value of independent variables come from randomization according to genetic methods and the value of dependent variables come from solving a set of equality constraints simultaneously after assigning the value of independent variables into these equations. By this method, initialization, crossover and mutation can guarantee the feasible solutions. After that, GUI is created in order to make this program can be used easily. Then, GAPinch is tested and the results are compared to the ones given by Lingo. For single contaminant, the results from GAPinch and Lingo reach the same value of minimum freshwater consumption but they present different configurations. For multiple contaminants, GAPinch gives better than or equal minimum freshwater consumption when compared to Lingo because this package could stuck in a local optimum while GAs has an ability to escape from there. The development is still undergoing to put on more conceptual design; such as cost constraints of piping and pump, in this prototype. Nomenclature a b Bi,j Ci, out Random value between 0 and 1 Set of right hand side of inequality constraint Binary variable Outlet concentration of water leaving operation i in ppm Outlet concentration from operation i to operation j Cimax ,in C imax ,out Maximum inlet concentration to operation i in ppm C imax , k ,in Maximum inlet concentration of contaminant k to operation i in ppm C imax ,k ,out Maximum outlet concentration of contaminant k to operation i in ppm Ci, in Ci, k, in Ci, k, out Ci, out Co Fi g(x) Pc Pm Ps S(x) Average inlet concentration to operation i in ppm Average inlet concentration of contaminant k to operation i in ppm. Outlet concentration of contaminant k water leaving operation i in ppm Outlet concentration of water leaving operation i in ppm Outlet concentration from regeneration in ppm Flowrate of freshwater entering operation i in tons/hr Set of left hand side of inequality constraints Crossover rate Mutation rate Selection Probability A function from the set of inequality constraints that returns the maximum value. Flowrate of wastewater leaving operation i in tons/hr Solution of any function at iteration ith Flowrate to operation i from operation j in tons/hr Flowrate of operation i after Regeneration Process in tons/hr Flowrate from operation i next to operation j in tons/hr Flowrate to regeneration from operation i in tons/hr Shape factor of CPSS Total mass load of contaminant transfer from operation i in kg/hr Total mass load of contaminant k transfer from operation i in kg/hr C ij,out Wi xi Xi,j Xi,r Xj,i Xr,i i i, k Maximum outlet concentration to operation I in ppm References [1] [2] [3] [4] Wang, Y.P. and Smith R., 1994, “Wastewater Minimization,” Chemical Engineering Science, Vol. 49, 981 p. Suriyapraphadilok, U., 1998, Network Prototype of Water-Wastewater Management, Master of Engineering Thesis, Chemical Engineering Practice School, King Monkut’s University of Technology Thonburi, 113 p. Mann, J.G. and Liu, Y.A., 1999, Industrial Water Reuse and Wastewater Minimization, New York, McGraw-Hill, 523 p. Wasanapradit, T., 2000, Solving Nonlinear Mixed Integer Programming Using Genetic Algorithm, Master of Engineering Thesis, Chemical Engineering Practice School, King Monkut’s University of Technology Thonburi, 90 p. [5] [6] Prakotpol, D., 2001, “Development of MATLAB Toolbok with Genetic Algorithm for Water Pinch Technology”, Master of Engineering Thesis, Chemical Engineering Practice School, King Mongkut’s University of Technology Thonburi, 113 p. Castro, P., Matos, H., Fernandes, M.C. and Nunes, C.P., 1999, “Improvements for Mass-Exchange Networks Design,” Chemical Engineering Scince, Vol. 54, pp. 1649-1665. Appendix Problem no. 1 2 3 4 Limiting Process Data Results 5 6 7 8 9 10 11 12 13 14 ----------------------------------------------