A NEW MUSIC-INSPIRED HARMONY BASED OPTIMIZATION ALGORITHM. APPLICATION IN WATER RESOURCES MANAGEMENT PROBLEMS. I. Kougias1 and N. Theodosiou2 Division of Hydraulics and Environmental Engineering Department of Civil Engineering Aristotle University of Thessaloniki 541 24 Thessaloniki, Greece e-mail: ikougias@civil.auth.gr1, niktheod@civil.auth.gr2 ABSTRACT During the past few years a new optimization technique has gained the scientific interest of those involved in optimization simulation. This technique, the music-inspired harmony based optimization algorithm, is based on the observation that the aim of music creation is the quest of the perfect state of harmony. This quest is relevant to the optimization procedures that also seek the “perfect” solution. The fact that this technique is effective and robust in solving large scale problems and simulating complex and multivariable optimization systems, has led to its acceptance by many scientists and to its application in a large variety of problems ranging from sudoku puzzles to space applications. After its first presentation in the year 2000 and especially after 2005, the technique is incorporated in an increasing number of publications. It is even more interesting to note that according to a 2010 literature analysis, 15% of the applications of this technique concern water resources management related problems. In this paper, after a brief presentation of the harmony search (HS) algorithm, as it is also known, an application on a water resources management problem is presented. This application concerns the optimum management of a group of pumping wells. In particular, 4 similar wells are placed in square formation in a flat area, in order to pump water from the underlying (under-pressure) aquifer. The objective of the model is to define the quantity of the water pumped from each well, satisfying the minimum requirement (Qtotal) and minimizing the pumping cost. The problem’s characteristics and basic data are presented along with the optimization procedure. Finally, HSA’s successful convergence to the optimum solution is presented, the results are commented and compared to those derived by the analytical solution. 1 1 INTRODUCTION 1.1 A new music-inspired, Harmony-Based optimization technique. During the past few years, a new optimization method attracted scientific interest. Harmony Search Algorithm, as it is known, introduced a new – daring connection between optimization techniques and music. The idea of the new algorithm was born when Zong Woo Geem [6] observed the creative procedure of a group of musicians playing together and observed the analogy with an optimization procedure. The analogy he used was that in the same way musicians try to improve their music (based on aesthetic criteria), the new algorithm will seek for the values that maximize / minimize the objective function (based on problem’s constraints). And in the same way a music band aims at the pleasant harmony, the new method will aim at the optimum situation (minimum cost, maximum benefits, resources management, scheduling etc). In 2001 Geem et al. introduced the new ‘Harmony Search’ method. 1.2 First Results – further development After even the very first applications, it became obvious that the new method was a promising – robust scientific tool. The Harmony Search projects were resulting to good-optimum solutions. Very often convergence was succeeded faster than the established optimization methods. Sometimes, the final results were even better, compared to the solutions that any of the known optimization technique was achieving. Due to HSA’s encouraging results, HSA gradually gained frequent applicability. The number of publications concerning HSA increased year after year. During 2009 the number of articles was increased by 250% compared to 2008 [8]. Of course, publications are following the quick and broad expansion of HSA in various scientific fields. Although Harmony Search Algorithm was initially designed to solve Hydraulic Problems, by 2010 applications include implementations for the whole range of Engineering sciences. Solutions to various Mathematical problems and applications in computer science are also significant. In 2006 Harmony Search Algorithm was used in satellite design problems. But, although HSA has expanded to various scientific fields, a research made in May 2010 by the authors, resulted that 15% of the total HSA applications concern the solution of Hydraulic – Water Management problems. In this paper, after a brief presentation of the technique and its methodology, a new water management application successfully solved with HSA, is presented. 2 STRUCTURE OF HARMONY SEARCH ALGORITHM 2.1 Basic Elements of HSA: Harmony Memory (HM): The places where harmonies are stored. Harmony Memory Size (HMsize): The number of places that HM has. The best harmony is stored in the 1st place and the rest harmonies are classified according to their performance. Harmony Memory Considering Rate (HMCR): HMCR specifies the probability that the new harmony will choose a value from the historic values stored in the HM. Pitch Adjusting Rate (PAR): Adjusts component(s) of the new harmony, chosen from HM. Randomization: If the new harmony is not based on historic values, a random value is chosen. 2 Maximum number of Iterations (MaxIter): Defines the termination criterion. 2.2 Steps of Harmony Search Algorithm: 2.2.1 Start of the optimization problem HSA Algorithm is mimicking a musician’s choices (when he is playing in a music band) and uses them in order to optimize a specific problem. After filling the Harmony Memory with random values, a specific number of iterations will implement the optimization procedure. In every iteration HSA uses the three following “musical" procedures. 2.2.2 Improvisation of new Harmony - Mechanisms of HSA i. HSA is choosing any value from Harmony Memory with HMCR (%) probability. This process is defined as Memory Consideration. Its importance lies on the assurance that good harmonies (values that give good results) will be considered through the solution. Moreover, these “good” harmonies will be the material (similar with parents in GA) for the creation of new, even better harmonies. ii. The Pitch Adjusting Process (with PAR (%) probability) is performed only after a value is chosen from HM. The new harmony will include xinew which will be: xinew = xi ± Random·bw, where, xi is the existing pitch stored in HM, Random is a random number between 0 and 1, and bw is the bandwidth of the adjustment iii. The third choice is to select a totally random value from the possible value range. Randomization occurs with probability (100-HMCR)%. 2.2.3 Update of Harmony Memory After each iteration, the new harmony is rated. If the created new harmony is better than the worst stored in HM, it replaces it. In that way, iteration after iteration HM includes better and better harmonies-solutions. The repetitive procedure is completed when the termination criteria are satisfied. 3 ANALYZING THE APPLICATION 3.1 Presentation of the Groundwater Management Problem The application which was designed and successfully solved with Harmony Search Algorithm concerns the optimum management of a group of pumping wells. In particular, 4 similar wells are placed in square formation in a flat area. These 4 wells are used in order to pump water from the underlying (under-pressure) aquifer. The objective of the model is to define the quantity of the water pumped from each well. These 4 water supplies must fulfill the minimum requirement (Qtotal) and minimize the pumping cost. The pumping cost for each well is calculated from the following equation: Cost i =A·Q i ·(Δh i +y) (1) where Qi: the water supply pumped from each well, Δhi: the drop of the hydraulic head in each well, y: the distance between the hydraulic head and the ground surface, A: constant cost parameter 3 The total cost (ignoring the installation cost) is regarded as: Costtotal= (2) This particular problem was chosen for various reasons. First of all, it is a well know groundwater management application. Moreover, although it is a representative application of aquifer management, it has simple structure and geometry. The analytical solution of the problem is well known and thus, it is easy to validate the results HSA provides and compare them with the correct results. 3.2 Solving the Problem 3.2.1 Mathematical Solution Calculating the integral of the water supply infiltrated through a random cross-section in the well’s perimeter, results in the following well known equation: (3) where Q: the water supply, h0: the hydraulic head very far from the well, RW: well’s radius, r: distance between the cross-section and the well Κ: hydraulic conductivity, d: aquifer’s thickness The fall of the hydraulic head in each well (with the use of linear superposition) is the sum of 4 terms, similar to the Equation 3. Suggestively, the hydraulic head drop in well nr. 1 is: Figure 1. Position of the 4 wells over the aquifer (4) Similarly one can estimate the hydraulic head drop in every well. Replacing the respective terms from eq.4 in eq.1 and 2 and performing the required mathematical calculations, we have the total cost, as: 4 (5) Where: In the above calculation it was assumed that: and as a result: Where RI= the radius of influence, RW= Wells’ inner radius. It is obvious that the first term in eq.5 is always positive, because . Since , the second term is always negative. For this reason, the cost becomes minimum when the Qi product becomes maximum, and the second term takes the minimumnegative value. This happens (considering that is constant) when: This is the mathematical solution of the problem. It does not depend on aquifer’s characteristics. Moreover, the distance between wells does not affect the final result. 3.2.2 Harmony Search Algorithm Solution In order to simulate the optimization procedure using the HS technique a new computer software was created using Visual Basic 6.0. The required input data are provided through a specially designed mask (figure 2) and include the following: Field and hydrogeological parameters: Dimension of the aquifer field maxX Influence radius of the wells RI The Hydraulic head in infinite distance h1 Hydraulic conductivity K Aquifer’s thickness d Well parameters: The total required water supply which must be pumped from all the 4 wells Qtotal The (inner) well radius RW The vertical distance between each well any of the coordinate axis x,y. The distance between neighboring wells is 2·b The cost-constant Α HSA parameters (as presented in §2.1): Harmony Memory Size - HMsize The percentage of HMCR & PAR parameters (Randomization’s percentage is (100-HMCR)%) The number of the Iterations, termination criterion - Max. Iter. Figure 2. Data insertion mask in the Created Program This is the initial stage of the Algorithm. In the beginning Harmony Memory is empty. We should rather say that before the initial stage, all the places of HM take a uniform - very high 5 value (practically infinite). Obviously, if zero values are assigned, the algorithm will fail. Zero water supply corresponds to zero cost. Thus it is impossible for the algorithm to converge to a better – lower cost. Each place in HM has 4 terms, the 4 values of the water pumped from each well. In the very first iterations, emphasis is given to the Randomization procedure. At that point HSA does not have the required experience as there are no stored harmonies that can be used or adjusted. This initial situation is similar to the very first rehearsal of a music band. In that rehearsal, musicians improvise and create the first melodies, since they have no music material. These very first melodies will be the base for the future music pieces. There is always the question of limiting the Randomization procedure. Permitting values between -∞ and +∞ will significantly slow down the convergence of the model. On the other hand, focusing on specific number range (as many HSA-scientists presented in their published work), can be disorienting and cause convergence to local optima. For this reason, authors decided to use physical limitations such as a hydraulic upper limit. This limit is Qcr, the water supply which causes the critical level-fall in the well. Very soon (after e.g. 2·HMsize≈60 iterations), Harmony Search Algorithm activates all three mechanisms. In every iteration a new harmony is improvised (which means that 4 values of the wells’ water supplies are given). This new harmony (the group of the 4 values) is created either by using Harmony Memory, (adopting a water supply value which was given in a previous iteration) or Improvisation (adopting a random number). As it is already mentioned, a small percentage of the harmonies selected from HM will be adjusted (with a probability equal to PAR). Then, the new harmony is evaluated. If it is more “pleasant” than the worst harmony stored in HM (if the new vector gives a better value to the objective function), it replaces it. After thousands of iterations, the convergence to the optimum solution is achieved. In the 4 wells problem, convergence to the known optimum was achieved successfully. The original input data of the problem were: maxX= 5000m, RI= 5000m, h1 = 400m, K= 10-5m/sec, d= 150m Qtotal= 300 lt/sec, RW= 0.4m, b= 100m, A= 2€/m/(lt/sec) The Algorithm performed several runs, covering 9 different values for HMsize (3, 5, 10, 20, 30, 50, 100, 150, 200). For each value of HMsize, 7 different HMCR percentages were used (1%, 10%, 30%, 50%, 70%, 90%, 99%). PAR index was assigned with a constant value of 5%. Totally, the program was executed 63 times. PAR and MaxIter indexes were defined in test-runs. Based to current literature [1], [4], [6], [9], [11], one could say that many values of the parameters were improper or even unacceptable (e.g. HMsize= 3, HMCR= 1% etc.). Of course, these values were chosen on purpose, in order to watch how HSA behaves near its limits. However, convergence was successful in a high percentage (over 40%). Convergence was accomplished faster after 54387 iterations for a HMsize= 20 and HMCR= 70% (Figure 3). These values are very close to the calibration that current literature suggests. Although almost 55000 iterations were needed to approach the minimum cost, HSA “unveiled” that the total water supply (ΣQi) should be 300lt/sec only after ≈1000 iterations. At 6 that point the calculated cost is only 0,15% higher than the minimum (Figure 3). It is obvious that HSA approaches the optimal solution very quickly, only after ≈1000 iterations. However, it takes thousands iterations (≈53000) to reach the best solution. The followed Statistical Analysis showed that convergence is more likely to be successful when HMsize= 30. The lowest average cost is calculated when HMsize= 20. This value of HM also leads to the average quicker convergence. It is worth mentioning that the model provided good results when HMsize= 100, which is a rather high value. Figure 3 Convergence to the optimal solution The meaning of HMCR is to store and use the “elite” harmonies, harmonies that are likely to give better results. If this rate is too low, only few elite harmonies will be selected. As a result HSA will converge slowly. After several runs, it turned out that low values (10%, 30% even 50%) interrupt the convergence. Pitch Adjustment is similar to the Mutation procedure in GA. Although PAR usually takes small values (<10%), recent literature [10], [11] regards PAR as an important factor, responsible for the convergence. One can think than increasing PAR up to 10 or even 50% will lead to a better performance. After testing these values in the present application, authors concluded that selecting such values causes overshooting and oscillation between local optima. Moreover, often the program fails to converge to the minimum and stops near the global optimum. Considering that HSA’s advantage is the quick approach to the optimum, failing to reach the optimum after hundreds of thousands of iterations reflects a bad calibration of HSA’s parameters. Randomization increases the diversity of the solutions. Although pitch adjustment has a similar role, it is limited to a local area. Randomization can drive the algorithm to explore the whole range and attain the global optimality. 7 4. CONCLUSIONS: In the present paper Harmony Search Algorithm, an optimization technique created during the last decade, was presented. HSA’s advantages led to its broad applicability among a wide array of scientific fields. In order to demonstrate HSA’s qualities, a groundwater-management application was created and simulated with a specially designed computer software. The challenge was to minimize the cost of the water, pumped from a group of 4 wells in a square formation. HSA successfully solved the problem and reached the optimum solution after the required number of iterations. The results were confirmed, compared to those derived from the analytical solution. Although HSA showed a remarkable ability to approach the optimum, calibrating HSA’s parameters is an important step towards the development of an application. The correct calibration ensures the convergence and leads to better solutions. Researchers already presented ideas and alternatives in order to improve HSA. Further research will lead to even better results and expansion of the Algorithm. 5. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. REFERENCES Ayvaz M.T. (2009) “Application of Harmony Search algorithm to the solution of groundwater management models”, Advances in Water Resources, Vol.32, pp. 916-924. Ayvaz M.T. (2009) “Identification of Groundwater Parameter Structure Using Harmony Search Algorithm” from: Geem Z.W. “Music-Inspired Harmony Search Algorithm”, Springer, SCI191, pp. 129-140. Geem Z.W. (2006) “Comparison Harmony Search with Other Meta-Heuristics in Water Distribution Network Design” Water Distribution Systems Analysis Symposium 2006, Proceedings of the 8th Annual Water Distribution Systems Analysis Symposium. Geem Z.W. (2006) “Improved Harmony Search from Ensemble of Music Players”, Lecture Notes in Computer Science, vol. 4251, pp. 86 – 93. Geem Z.W. (2006) “Optimal cost design of water distribution networks using harmony search” Engineering Optimization, Vol.38, no 3, pp. 259–277. Geem Z.W., Kim J.H. and Loganathan G.V. (2001) “A New Heuristic Optimization Algorithm: Harmony Search” Simulation, Vol.76:2, pp 60-68. Geem Z.W., Tseng C.L. and Williams J.C. (2009) “Harmony Search Algorithm for Water and Environmental Systems”, from: Geem Z.W. “Music-Inspired Harmony Search Algorithm”, Springer, SCI191, pp. 113-127. Ingram G., Zhang T. (2009) “Overview of Applications and Developments in the Harmony Search Algorithm” from: Geem Z.W. “Music-Inspired Harmony Search Algorithm”, Springer, SCI191, pp. 15-37. Lee K.S., Geem Z.W. (2005) “A new meta-heuristic algorithm for continuous engineering optimization: harmony search theory and practice” Computer Methods in Applied Mechanics and Engineering , Vol.194, pp. 3902-3933. Mahdavi M., Fesanghary M., Damangir E. (2007) “An Improved harmony search algorithm for solving optimization problems”, Applied Mathematics and Computation, Vol.188, pp. 15671579. Wang C.M., Huang Y.F. (2010) “Self-adaptive harmony search algorithm for optimization”, Expert Systems with Applications, Vol.37, pp. 2826-2837. 8