Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
INFORMATION TO USERS
This manuscript has beem rspriPduosd fiwn the microfilm mas te^ UMI film the
text directly fiun (he orQinal or copy submiüed. Thus, some thesis and dissertation o o p k are in QpwfiW fhœ, whik O(hur may be frwn any type of cornputer printer.
In the unlikely evemt lh8t Ihs WfnOT did not $end UMI a cornpiede manuscr@t and hem are missing pagms, üiese wil be notbd. Aho. if unaut)iorired copyright
matenal had to be removeâ, a W wiH indikate the de(etion.
Oversize maderials (e-g.. m a p . drawïngs. &arîs) am m p d w d by secücming
the original. beginning 1 the uppw ieftIharid corner m â continuing from îeft îo
right in equal sections wiîh small ovedaps.
Photographs induded in üm original manudpt haro bëen nproduced
xerographicaliy in this c m . Hihu pusMy 6' x 9" #Pck and white photographie
prints are availabk for any phdographs or illwrtrstions appmring in this copy fiw
an additional charge. Corifect UMI di* bo Ocder.
Bell & Hauilell lnfwmation and Leaming 300 North Zeeb Road, Ann Arbor, MI 481iB-1346 USA
NOTE TO USERS
Thh riep~uction is the ûestcopy avaiIabîe
STORAGE- AND PUMPING SYSTEM OPTIMIZATION USING GENETIC ALGORITHMS
TOBIAS A, BLOCH
A THESIS SUBMTTED IN CONFORMITY WITH THE REQUFMENTS FOR THE DEGREE OF M4STER OF APPLIED SCENCE
GRADUATE DEPARTMENT OF CLVII, ENGINEERING UNIVERSITY OF TORONTO
.8 Copyright by Tobias A. BIoch 1998
Acquisitions and Acquisitions et Bibliogmphic Sentices services Wiraphiques
The author has granted a non- L'auteur a accordé une Iicmce non exclusive licence allowing the exclusive permettant à la National Library of Canada to Bibliothèque nationale du Canada de reproduce, loan, distniute or seil reproduire, prêter, distribuer OU copies of this thesis m microform, vendre des copies de cette thèse sous paper or electronic formats. la forme de microfiche/film, de
reproduction sur papier ou sur format électronique.
The author retains ownership of the L'auteur conserve la popnété du copyright in this thesis. Neither the droit d'auteur qui protège cette thèse. thesis nor substantial extracts fiom ït Ni la thèse ni des extraits substantiels may be printed or otherwise de celle-ci ne doivent être imprimés reproduced without the authoc' s ou autrement reproduits sans son permission. autorisation,
Bloch, Tobts, 1998. Storcrge undpumping sysfem opfulïzation mng genetic algorithm A thesis submitted in codormity with the requirements for the degree of Master of Applied Science, Graduate Department of C i . Engineering, University of Toronto.
Water distributions systems generally do not operate at or their optimal points.
The operational procedures of these systems shouid be reworked to make them more
economicaily efficient. The ability to optimize (Le., for economic efficiency) the
operation of water distribution systems is hhdered by the dimensionaily (Le., many
different subsystems to optimize simuitaneously) inherent in these systems. This is
especidly true for small time steps. pumping systems utilizing multiple pumps and
distribution networks with multiple storage tanks.
A branch of computer science cailed Genetic Algorithms has been show to be
very effective for optimizhg comples systems. Genetic Algorithms are utilized in Two
computer programs developed in this thesis. These programs were tested against simple
water distribution systems and produced optimal solutions in a very short period of time.
The architecture (i.e., program structure) for hture computer progams that are based on
the platform created in this thesis is also presented. These proposed versions should be
useful in the optimization of large water distribution systems. something which has never
been possible bsfore.
ACKNOWLEDGMENTS
1 wish to express m y gratitude to m y supervisor, Professor Bryan W. Kamey, for
his continuous guidance, direction and patience in the writing of this thesis. 1 would also
like to thank my second reader, Professor R o m C. Andrews for his help in the editing of
this thesis. 1 wouid like to thank the Natural Science and Engineering Research Council
of Canada for their financial support of m y studies-
1 would like to thank the graduate students of the Environmental Enginee~g
Section of the Civil Engineering Department for a very enjoyable and enterfaining two
years. Especially Martin Pendlebury with whom 1 shared an office.
Findly, my family, whose support for ail of this made it ai i possible.
Tobias A. Bloch
TABLE OF CONTENTS
........................................................................ Introduction
2 . The System and its Costs ............................... 2.1 The Water Distrib-ttion System Structure 4
2.2 Water Demand Rates. ..................................................... 6 ........................ 2.3 The Control Volume and System Constraints. 8
2.4 The Cost of the Pumping System. ..................................... 9 2.5 Cost of the Elevated Storage Tanks ..................................... 10 . . 2.6 Cost o f Electncity ......................................................... 11 2.7 Discount rate, Inflation rate and Operathg Life ....................... 12
.................................................................... 2-8 S 15
3 . The ~undarnentals of Genetic Algorithms 3.1 Introduction ................................................................ 17
................................. .. 3.2 Naturad Evolution: The Inspiration .. 17 3 -3 Genetic Algorithms ........~..~.~.~~~...~~~~~~.~.~.....~.....~......~.....~~ 19 3.4 Crossover ................................................................... 22 3.5 Crossover Methods Cornparison ........................................ 26
................ ........................... . 3 .5 1 One-point crossover ,, 30 3 S.2 Two-point crossover ..... .. ...................................... 30 3 -5 -3 Unifonri crossover- ........................................... 31
3 -6 Parent Selection .................................................... 31 ................................. 3 .6.1 The Roulette Wheel Technique 33
............................................ 3 -7 Evaluation and Fitness Value 36 ................................................................ 3.8 BitMutation 37
3.9 Surnmary ............................*-...................................... 41
4 . The Structure of GAHOS ................................................................ 4.1 Introduction 43
4.2 Overview of GAHOS-1- ..................................................... 43 4.3 OverviewofGAE-IOS-2 ...................................................... 45 4.4 Evduation. ................................................................... 47
................................................................ 4.5 Reproduction 51 4.6 Mutation .................................................................... 54 4.7 Input and Output .......................................................... 57 4.8 Mode1 Validation. ......................................................... 59
............................. 4.8.1 First Stage ....................... ..... 60 4.8.2 Second Stage ...........................~....................... 61 4.8.3 Third Stage ........................................................ 62
4.9 Summary ................................................................... 65
5 . Future Versions 5.1 Introduction ................................................................ 67 5.2 GAHOS-3BIuepnnts ................................................... 67
..................................................... 5.3 GAHOS-4 Blueprints 70
6. Conchsions and Recornmendations ............................................. 73
.................................................................................... Refereaces 75
Appendices
Appenir 1 Appendix 2
Appendix 3 Appendix 4 Appendix 5 Appendix 6 Appendix 7
Appendix 8 Appendix 9 Appendix 10 Appendix 1 1 Appendix 12 Appendix 13 Appendix 14 Appendix 15 Appendix 16
Results o f the effect of S K ratio on DaiIy Electrïcity Cost ........... 78 Results of the effect of mazdincation exponent on D d y
............................................................. Electncity Cost 83 Generating an equation for the capital cos of storage reservoks ... -85
......................... Affect of the mutation values on the Gp value 87 Tables conceming the mode1 validation (third stage) ................. 91 Average day water demand rates (AVRDAY 1) ....................... 93 Description of various fitnction used in the GAHOS
.............................................................. computer code 94 GAHOS-1 compter code ............................................. 96
................................................ GAHOS-2 cornputer code 111 ........................................... The Rouiette wheei subruirune 134 ........................................ Starting storage to capacity ratio 147
.............................................. ENLlMERO cornputer code 153 ................... ................... Toronto Hydro Electricity Rates .. 170
........................................................ Input file bit-15.m 174 ....................................................... Input file test4 5.tut 176
........ Output file showing the effect of the absolute-best hction 178
LIST OF FIGURES
............................................ The water distribution system layout 5 ................................................................ GAHOS FIow Chart 21
............................................. An example of a one-point crossover 23 Example of a one-point crossover usuig "Head" and "Taii" illutrations ... 24
............................................. An example of a two-point crossover 25 ........................................... An example of a three-point crossover 25
................................... An example of the UlUfonn crossover method 26 ......... An example of the schema plincipal in a real engineering problem -27
................................... The solution to the real engineering problem 28 .................. Detennining all the schemata for a particuiar chromosome 29
................................................... Problematic one-point crossover 30 ................................. The roulette wheef parent seIection algorithms 34
................... An example of the rouiette wheeI parent setection method 34 ............................................. Chromosome structure of GAHOS-1 45 .................... Chromosome structure of GAHO S-2 c.- ..... ..-. ........... 47
.......................................... The effect of the absolute-best fùnction 53 ................................................................... The Bit Switching 56
.................................................... An example of binary addition 61 ....................................................... GAHOS -3 pumping systern 66
LIST OF TABLES
........................................... The common method of bit mutation 38 . ICMM vs CMM run times ..................................................... . 40
........ A summary of the three versions of GAHOS used in the validation -60 ..................... Cost properties for five Storage tanks of varying sues ... 62
......................................... Cost properties for fÏve different pumps 63 ............................... Total System Cost for al1 possibie combinations -63
List ofAbbreviatiois and Acronyms
B C CE c m CP Cs cv GA GAHOS-1 GAHOS-1 GAHOS-3 GAHOS-4 GAs GP H 1 ICMM L M 4 I M
NS O O&M P P Q RP Rs RWM SCR TDH Vf
Number of bit mutations per one hundred bits nie maximum capacity of the storâge tank Daily electricity cost Commoa Mutation Methods Capital cost of pwnp Capital cost of storage tank Control Vohme Genetic Algorithm First version of GAHOS Second version of GAHOS Third version of GAHOS Fourth version of GAE-IOS Genetic Algorithms n e nwnber of generations before optimal solution reached Head of water Inflow Rate Individual Chromosome Mutation Method The length of each chromosome in tenns of number of bits Magnification factor The number of bits to niutats per chromosome chosen for mutation Network Solver Outflow Rate Operation and Maintenance Magnification exponent The mutation probability per chromosome Water flow O & M costs of the pump as a percentage of C, O & M costs of the storags tank as a percentage of Cs The Roulette Wheel Method Starting water volume to maximum Capacity volume Ratio Total Dynamic Head Volume of water in the CV
1. INTRODUCTlON
Nearly 7 percent of the electncity produced in the United States is consuxned by
municipai water utilities (Jarnieson at el., 1989). The vast rnajority (typicaily 95%) of
this elecûicity cost is associated with m g the pumping system. These figures are
based on data collected in the United States, however they are comparable to those of
Canadian municipal water utilities. The vast majority of these water UtiIities do not
operate at or near their optimal IeveIs (Omsbee and WaIski, 1989). There is much room
for improving the operationai and design aspects of municipal water utilities (Ormsbee
and Walski, 1989).
There are several methods by which water supply operations can be optinized.
The two most popular methods are Dynamic programming and Lagrangean relaxation
(beckwith and Wong, 1 995). Ho wever, both these methods require signincant cornputer
resources and are inadequate for real time optirnization. Dynamic programming suffiers
from explosion in dimensionally and thus h d s it difncult to solve (Le., optimize)
complicated water distribution systems (beckwith and Wong, 1995). Lagrangean
relaxation find complicated systems difficult as well since it can become entrapped in
Local minima and thus never find the true minimum cost solution (Le-, the optimal
solution),
In this thesis an optimization tool caiied Genetic Algorithms (GAs) was used to
optimize the operations and design of a hypothetical water distribution system (referred
to as the "system" or "problem?'). Genetic Aigorithms were inspired by the theory of
nature selection. Using GAs has been shown to be a very effecfive approach for
optimjsration purposes (beckwith and Wong, 1995). The research conducted during this
thesis produced two cornputer programs (i.e., two versions), both these programs utilize
the principals of GAs. The propmc were entitied under the heading of GAHOS
(Genetic Algorithm Hydraulic 0ptimj;riltion Software). In this thesis ccGAT30S" is used
to refer to the s o h a r e (i.e., all versions).
The first version of the program was cdied GAHOS-1 and was created as a tool
for the optimization of the day to day operation of a water distribution systern. GAHOS-
1 is capable of detemÿning the optimal pumping schedule as weil as the optimal way of
managing the storage reservoir. A pumping schedule is the iist of tïmes the pump is on or
off. Electricity costs Vary between different times of a day. Reducing the amount of
hours the pumping system consumes electricity duhg the expensive period is an
effective way of decreasing the operational costs of the water utility.
GAHOS-2 was created as a tool for the design (and operation) of efficient water
distribution system. This version of the sohvare c m also optimize the pumping schedule
and storage reservoir management in the same marner as GAHOS-1. However,
GAHOS-2 goes M e r by determining the bea pump and storage tank type to install.
When operating GAKûS-2, the user inputs an uiventory of pumps and storage tanks that
the program c m consider in its optimization procedure. From this inventory, GAHOS-2
will determine the most optimal combination of pump, storage tank, pumping schedule
and storage reservoir management procedures.
Chapter 2 describes the creation of the hypothetical water distribution system, as
well as how this hypothetical system differs from one that can be found in practice.
Water demand rates and system constcaints are discussed- Capital cost equations for the
purchase of pumps and reservoirs as well as operation and maintenance Iiabilities and
electncity costs are presented. The Chapter f i s h e s by introducing the eqwtions that are
used to evaluate the perfomiance of different solutions (Le, combinations of pumpicg
schedules , pump types, storage types etc.).
The reader is presented with a brief history and basic principals of Genetic
Algorithms in chapter 3. The reader is introduced IO a novel mutation method devefoped
in this thesis. This method is different than all other documented methods and is many
urnes quicker (i-e., computationaliy more efficient) than other methods. The chapter also
discusses mutation methods. crossover methods and parent selection methods.
Chapter 4 describes the subroutines used in GAHOS as well as the typical
parameter ranges calibrated for the input data presented in the appendices. The validation
procedure that GAHOS-I and GAHOS-2 undenvent are also documented in chapter 4.
Chapter 5 which provides recommendations for future cornputer programs based on the
GAHOS platform. These recommendations will enhance the engineering usefulness of
GAHOS. The thesis f ~ s h e s \vit11 a sununary of the conclusions and recommendations.
2. THE SYSTEM AND ITS COSTS
2.1 The Distribution Network Structure
The fïrst task in any optimization project regardLess of its numerical method (Le.,
Dynamic programming, Genetic Aigorithms, Lagrangean relaxation, etc.) is to dehe the
system's structure. This promotes a better understanding the system's intemai
components and theù purpose. In this thesis, the author has constnicted a hypotheticai
water distribution system with the intention of partially ophizing it. The term partially
optimizing is used since ody a few components of the system will be optimized (the
pumping device and schedule, as well as the size of the r=servoir).
The physical structure of the hjpotheticd distribution system is for the most part
similar to those employed in practice. However some simpiifications and assumptions
were necessary to cope with the cornplex and Iargely uninvestigated nature of the
problern. This approach was prudent since in the beginning of this research it was not
known how well genetic aigorïthms would cope with a multi IeveI opthkation.
The water distribution system consists of four major components, a wet weU,
purnping system, reservoir and distribution network. The wet well stores the potable
water that has been processed throufli the water treatment plant. The amount of water
retained by the wet well is of suEcient quanùty so as to ensure an ample supply of water
to the pumping system, even during times o f hi& water demand rates. The wet well acts
as a buffering mechanisms, aiding the water treatment plant combat fiuctuating water
demand rates.
Figi 2.0: The water distribution system layout
Pumping System
A typical pumping system consists of pump(s) and valve(s). The number of
possible configurations of pump(s) and valves is limitless (each version of the software
plainly defines the specific configuration used in its purnping system). Water is
transported fiom the wet well through a pumping system and up into an elevated water
reservoir. From the resewoir, water flows by gravity into the distribution network. The
major simplifications that make this system dif5erent fiom one that may be encountered
in practice are Iisted below:
1. The pumping system consist of only one pump (with no bypass valve), which is only
ailowed to operate at one speed. This means that the pump can be represented by only
three parameters; its head. discliarge and efficiency. Whatever the pump speed
chosen. the corresponding head must be laqe enough to allow the water to reach the
top of the reservoir (the pressure head provided by the pump must be equal to or
greater than the eievation Merence between the pumplag system and the top of the
storage tank).
2. All water that enters the distribution network must first pass thugh the pumping
system and resemoir. The pumping systern can not directly supply water and pressure
to the distribution network
3. The energy required to supply water to the nodes at above a specifïed minimum
pressure (Le. 30m of head) will be provided by the elevation difference between the
reservoir and the distribution network. ïhis assumption holds tme for aU water
demand rates.
Aithough these assumptions are constrictive and make the initial versions of the
G M O S impractical (GAHOS-1 and G-AHOS-2), they were initially necessary. The
knowledge and data gained by experimenting with this simplified water distribution
system was extremely beneficial. The experiments conducted by applying GAHOS-1
and GAHOS-2 have enabled the author to begin pretirninary design of hture versions of
the softu'are that avoid these assumptions (GAHOS-3 and GAHOS-4 which are discussed
in chapter 7).
2.2 Water Demand Rates
The water demand rate is defined as the sum total of all the water drawn fiom al1
the nodes in the distribution nenirork during a specific block of tirne. In this thesis, these
rates are given in cubic meters per second and are partitioned into one hour sections. The
24 water demand rates repre~entlng the 24 hours in a day are de- in dl GAHOS input
files. These rates are located in the second block of input data, folIowing the electncity
cost parameters (see Appendix 14 and 15 for an example ofan input file).
Two daily flow demands are of interest: i) maximum day and ii) average day.
The maximum &y demand rates rqresent the critical demand requirement the system
might encounter. The maximum day demands are often used to test how the system
functions during these extreme periods (Wdski, 1993). The mean rate of water
consumption during the maximum day is an important value. It represents the threshold
with respect to pump flow. Any pump that can supply water at a rate higher than or equai
to the rnean fiow rate is eligible for consideration as a possible option. However, al1
pumps that supply water at a rate lower than the mean flow rate can wver be considered.
This is because these pumps can never replace the water drawn from the reservoir within
24 hours of the start of the maximum day simdation.
The average day flow rates represent the average (nom historical data) demands
that the system may encounter. The average da>- rates are lower then the maximum day
rates, yet they are important stili. The average day simulation provides a more realistic
estimation of how the system will fünction during day to day operations (Ormsbee and
Walski. 1989). It is for this very reason that in GAHOS, the a ~ u a l electricity cost is
estirnated by taking the electricity cost of the average day simulation and multiplying it
by 365. In both GAHOS-1 and GAHOS-2 the average day simulation provides the basis
for estimating the electncity cost associated wïth the pumping operations. The average
&y water dernand rates used in this thesis are d e d AVRDAY-1, and are included in
Appendix 6-
23 The Control Volume and System Constrauits
A water distriiution system must balance the suppIy and demand of water and its
pressure. Previously it was assumed that the pressure requirements of the network were
met automaticdy by the elevation head of the storage tank (assumptions 2 aud 3 located
in section 2.1). Thus the problem (or operators obligation) is now reduced to the
satisfaction of the water demands generated by the consumers (ie., ensure that the
storage reservoir never runs out of water).
The best way of tracking the quantity of water in the storage reservoir is using
wliat is called a Control Volume (CV). Since the storage tank is the only link between
the pump flow ( i.e., inflow) and the network demand (Le., outQow) it must be included
withui this CV. Becaw the pump can not directly introduce water into the distribution
network (dl water must pass through the storage tank), than the CV can simply be
defined as the storage tank itselE
The CV has only one inflow and outnow point. The inflow rate O, is equal to the
pump displacement when the pump is turned on. When the pump is turned off, 1 is equal
to zero. The outflow rate (O), is equal to the water demand rate. Assvming
incompressible flow the control volume equation is given as
in which Vf is the volume of water on the CV (storage tank). The above m o n is
used to track the amount of water in storage (Miïes and Moore, 1995).
There are two system constraints that must be satisned. The fïrst is that the
demand flow (generated by the average day demand data) must at ai i t i w s be met. The
second constraint is that Vf must be greater than zero and less than the capacity of the
storage tank. Equation 2.0, provides the means by which these constraints are related.
2.4 Cost of the Pumping system
The costs associated with a pumping system can be divided into capital, O&M
(operation and maintenance) and electricity costs. This section discusses the first two,
while the third group (electricity cost) will be covered in the section 2.6 entitled "Cost of
Electricity". Capital cost of a pump is the sum of the purchase price plus any shipping
and installation costs. While O&M cost is the cost generated by maintenance, repair,
wages of operators etc.
There are hundreds if not thousands of pump manufactures around the world that
produce centrifûgd pumps for water-supply applications. With each manufacturer
producing several Merent pump sizes the results in an almost overwhelming number of
pumps (that cm be considered in the pump selection process).
Each manufacturer prints cataiogs that describe the pumps and provide important
characteristics and specification ( WalskL 1 993). These include: purchase price,
efficiency vs. disch arge graph, discharge vs. h
estimated life of various intenial components.
ead graph, cost of repIacement parts and
Sinfe the purpose of thk project was to simply create and validate GAHOS, it
was not vital to use genuine pump data (i.e., discharge, head and efficiency), only data
that is reasonably accurate- Thus a hypotheticai inventory of pumps and their properties
was constnicted (these pumps exhibit redistic properties) (Clingenpeei, 1983). 'The
capital cost of these pumps was approximated ushg equation 2.1,
Capital c o s = % (690 000) Q O - ' H ~ - ~
Q = water flow [m3/s]
H = head of miter [ml
this expression was adopted fiom Walski et ai. (1987). Equation 2.1, was used to
approximate the capital cost of &e pumps in the inventory. The yearly O&M cost of
these purnps is given as a percentage of the capitai c o s which in this study varïed
between 5% and 15% (the more expensive hi& efficiency pumps were around 5%, while
the cheaper lower efficiency pumps were doser to 15%). This percentage value c m
easily be altered and can be graduaIl?- incrsased by the use of an innationary constant
(which is discussed in section 2.7).
2.5 Cost of the Elevated Storage Tanks
A hypothetical inventory of elevated storage tanks similar to the pump inventory
was also constructed. The O&M costs were assumed to be a percentage of the capital
cost and the user may alter them via the s a m r inflationary value (sze section 2.7) as the
pumps. The capital cost of elevated storage tanks was approximated ushg the following
equation,
Capitai cost = $ 300 000 + 140 C (2-2)
C = the maximum capacity ofthe tank [dl
equation 2.2 was created via a linear regression routine (Appendix 3) h m data presented
in Muir (1991).
2.6 Cost of Electricity
There are two methods by which electnc utiiities bill their clients. The first is
time-of-use rate structure. The second is the peak-demand (or peak consumption) rate
structure (Lackowitz and Petretti, 1983)- The time-of-use rate structure is a proactive
method by which utilities can peoalize user that demand power during peak jmiods. The
electric utility charges a higher price ('er kilo&-att-hour) for electncity durhg peak-
period and a lower price at off-peak hours (Muir, 199 1). Utilities typicaily define peak
periods as 09:OO to 2 1 :00, however this is purely dependent on the electricity
consumption patem of the population. Toronto Hydro charges its costumers more in
\\inter than it does in m e r (when cornparhg winter peak period rates to summer peak
period rates, and doing the same for the off-peak comparison) (Appendix 13). Regardless
the season the off-peak period rates are substantily Lower @eak periods can be as much as
3 tinies more expensive than off-peak periods) than t i e peak period rates (Chao, 1979).
For example, Toronto Hydro gives its customen a 58% discount in winter and a 63%
discount in summer (Appendix 13).
The peak-demand rate structure is typicaiiy defineci by the the higest dernand
charge established in any 15-minutes window for the month (Clingenpeel, 1983). This
type of rate structture is oniy applicable to customers with large monthly demands
(greater than 2500 kW).
The peak-demand rate structure is most applicable for pumping stations with a
battery of pumps. If an unusudy large number (more pumps on at one time than is
normal) of these pumps are active, then the probabiIity of peak-demand rate b i h g
increases (Walski and Omsbee, 1989). Since both GAHOS-1 and GAHOS-î are based
on a single pump system. This justifies the use of the timesf-use rate structure (since
peak-demand rate stmctre is only applicable for large electrcity consumers using multipal
pumps). The füture versions of GAHOS (GAHOS-3 and GAHOS-4) proposed in chapter
7 would incorperate many pumps and these proposed versions of the software would
utilize both billing methods.
2.7 Discount rate, Inflation rate and Operating We
In order to successfilly couiplete an econornic analysis of the hydraulic system
we must group ali system costs into one economic indicator (which must incorporate all
applicable costs as well as the time value of money, inflation and operating He). The
most commonly used indicator is referred to as present worth or its opposite present cost
(White et al. 1989). Present day cost is used as an indicator since it is more pleasing to
use positive values to represent costs, then negative values representing benefits.
In sections 2.5 and 2.6 the capitai cost of both pumps and storage tanks was
defined. For the sake of sImpli.ficatÎon, the operator of the hydraulic system îs assumeci
to pay the capital cost of the pump and resemok tank on the first day of the projest Me.
These capital costs by definition are already discounted to the v e n t day and such need
not be manipdated. There are cases in which the operator does not posses the capital to
pay for the pump and storage tank entirely. Under such circumstances the operator
typically bo~ows the capital in the form of a bond or evena Ioan . In these cases the rate
of interest, amount borrowed and time for debt repayment must be used to adjust the
present worth of the capital cost of the pump and storage tank However, the overall
changes to GAHOS are minimal and would total less than 5 lines of code.
There are also two other costs that must be accounted for. The first is the daiiy
electricity cost, and the second is the O&M costs of the pump and storage tank. Both the
electrkity cost and O&M costs are assumed to by paid at the end of each of every
operating year throughout the Iife of the project (or tirne horizon). Since the Iife of a
project can be anywhere fiom 10 to 40 years, the time value o f money as weil as the
potential for inflation must be considered.
For simplicity, it is assumed that the rate of inflation of both electncity and O&M
cost are subject to the same rate of inflation of r %. Thus, by multiplying the first year's
electricity and O&M costs by a present worth factor and adding to that the capital costs of
the pump and storage tank, dl the costs of the entire project are Nmrned into a single
present worth total cost. The present worth factor is defmed as:
(P/A i ç 9) = pronounced P given A or present worth given an
annuity of n y-, at a discount rate of i, and an
inflation rate of r.
Equation 2-3 was taken fkom W d e et al- (1989).
Using the present worth factor we can sum al1 the costs of the hydraulic system
Total Project Cost = Cp f CS + (PrA i, r, n)-(365-C~ + Cp-Rp f CS&) (2-4)
Cp = capital cost of pump [$]
Cs = capital cost of storage tank [$]
CE = daily eleciricity COS [$/day]
Rp = O & M costs of the pump as a percentage of C ,
Rs = O & M costs of the storage tank as a percentage of CS
The daib electricity costs (CE) is calculated fiom equations 2.5 (fiom Roberson and
Crowe, 1993) and 2.6 show below;
where P is the power requirement [kW, 9 is the pump efnciency, Q is the discharge rate
[m3/s], H is the pump head [ml and y is the specific weight of water FN/rn3]. In order to
convert the power value calculated in equation 2.5. we m u t first manipufate it using the
electricity rate as shown below;
CE = P - (Energy Charge) - (Time Period) (2-6)
where the Energy Charge is dictated by the electricai utility [$/kW-hr] and the T h e
Penod is the length of tüne the pump was in use.
2.8 Summary
This chapter focused on two major areas: i) the physical organkation of the watet
distribution system, and ii) the economif amibutes of that same system. The topics
discussed in this chapter are essential Ï n order to understand the design and operation of
GAHOS. A list of simplifications (i-e., assumptions) is presented below summariPng
those simplifications presented in this chapter. The iist is applicabIe to both GAEIOS-1
and GAHOS-2.
The purnping system consists of a single pump, which operates at one speed.
A n y pump can be represented by only three parameters; head, discharge and
efficiency .
AI1 water that enters the distribution mstem mcst pass through the pumping system
and storage reservoir.
The elevation head of the storage reservoir provides all the pressure needed to satisfy
al1 the requirements of the distribution network.
Water demand rates are presented as the sum total of dl the demand rates (fom al1 the
nodes) of the entire distribution network.
The water level (in terms of volume) in the storage reservoir mua be maintained
between zero and maximm capacity-
The economic analysis conducted within the sofnvare is based on the average day
water demand rates.
NOTE TO USERS
Page($) not included in the original manuscript are unavailable from the author or university. The
manuscript was microfilmed as received.
16
This reproduction is the best copy available.
UMI
3.1 Introduction
In the previous chapter the reader was introduced to the physical and economic
attributes of the hypothetical water distribution system developed in this thesis. As
discussed before, this water distribution system would be partially optimized using a
computer program c d e d GAHOS. The 'brain' (or numerical engîne) that nms GAHOS
belongs to a subset of computer science cded Genetic Algorithms.
Genetic Algorithms (or GAs) are based on principals developed by scientist
researching the theory of nature evolution. Genetic Aigorithms when used in system
optimization have shown great promise (Miles and Morre, 1995). The abiiities of GAs
were reconfirmed by the experiments conducted on two versions of GAHOS (see section
4.7). The purpose of this chapter is to give the reader the fundamental knowledge
required to understand how genetic algorïthms function.
3.2 Natutal Evolution: The Inspiration
Looking at the complexity and diversity of biological species on our planet, one is
Iefi with curiosity and admiration for '-whom" ever or "what" ever has made this
possible. For the Iast two centuries biologkts have invested much of their time (Back,
1996), detemiinuig the principals behind the '-whaf'. In the course of their research they
have given their field a name - natural evolution (Back, 1996).
Even as we m a c h end of the 2om centary, the mechanisms of nsnaal evolution
are not M y mderstood- However some general attributes of the theory are widely
accepted (fiom Davis 1 99 1):
O 'Tvolution is a process that operates on chromoornes rather than .
on the living beings they encode-
9 'Natural selection is the iink betwem chromosomes and the
performance of their decoded structures. Processes of natural
selection cause those chromosomes that encode successfid
structures to reproduce more ofien than those that do not.
m 'The process of reproduction is the point at which evolution takes
place. Mutations may cause the chromosomes of biologîcd
children to be different fkom those of their biological parents, and
recombination processes may create diffèrent chromosomes in the
children by combining material f?om the chromosomes of two
parents.
9 ccBiological evolution has no memory. Whatever it knows about
produciag individuah that will fiuiction well in their environment
is contained in the gene pool - the set of chromosomes carried by
the current individuais - and in the structure of the chromosome
decoders."
Through the late 1960s and early 1970s, John Holland (working at the University
of Michigan) conducted research into merging the principals of natwal evolution into a
computer algorithm @IichaIewicz, 1992). Hoiland believed that, by incorporatïng tâese
principals in a computer algorithm, they might yieid a technique which is able to solve
very ciifficuit problems in the same way nature does - through evolution. Instead of using
DNA to encode individuals, he used strings o f binary digits (1's and 0's); he calleci these
binary strings chromosomes. Holland (1975) observed that a population of Iow-grade
solutions which undergo simuiated evolution codd field advanced solutions to dinicuit
problems. As the potentiai of these types of algorithms k a m e more evident, Holland
named them genetic algorithm.
3.3 Genetic Aigorithms
Syaem optimization can be described as the search for the best solution.
Solutions can be compared to one another by way of their quality- In Genetic Algorithms
this quality is called ''fztness". The 'Fmcss" value assigned to a solution reflects its
abiIity to meet the objective(s) and constraint(s) associated with the system (Halhal et ai.,
1995). The better the solution, the higher is its fitness value-
A solution's chromosome can be tliought of as the detailed bilI of materials. The
chromosome contains ail the uiformation required to perfectly depict the particuiarities
of the solution. In order to simpliS. the labor required in the evolution of these
chromosomes, their contents are encoded in a structure much like the DNA double helix.
However, this results in the inability to directly acquire the fitness of the encoded
chromosome. One c m parallel this with trying to analyze a chromosome that encodes a
particular combination of a certain type of pump, storage tank size and pumping scheduie
without testùig (or simuiating) this combination nrst
ln order to acquire the fitness value, a chromosome must pass through two
different procedures (a c'decodery' and an cCwaI~ator") . In the c'decder" the data stored
within the chromosome is dtered into a raîÏoonal set of instructions. in the "evaIuatoryy the
data composed in the decoder is evaluated and is assigned a fitness value-
Genetic Algorithms just like species in nature require a number of breediag
individuais in order to guaranty the survival of the species. The sum of these breeding
individuals is called a ~ o p u l a t i o n ~ . nie size of a population used in GAs varies with
respect to the type of system involved. A normal range would be between 10 and IO00
individual chromosomes. The Iiterature reviewed in this thesis recommends that the
po pu1 ation size remain constant through the entire simulation (i.e., generation after
generation). This is exactly the case in both GAHOS-1 and GAHOS-2 (as weli as the
proposed GAHOS versions presented in chapter 5).
Fig. 3.0, shown on the next page is a flowchart of GAHOS. The figure illustrates
the execution order of the main subroutines. Before reviewing Fig. 3.0, it is
advantageous to define the purpose of these subroutines in simple terms:
Crossover - The creation of new chromosomes by mating current chromosomes (refemed
to as parent chromosomes). after which the parent chromosomes are deleted.
Fig. 3.0: GAHOS Flow Chart
Input systern m + Process eIectncity and demand data
population of chromosomes
Crossover G' Mutation Q
Evaluation 7
simulation data
Retum to screen the best
chromosome
Mutation - Randody applying mutation to a îked percentage of the new chromosome
population.
Evaluatïon - Evaluate each chromosome in the population and assigning it a fitness
value.
Roulette Wheel - The roulette wheel method is a specinc technique that is classifieci as
parent selection. This subrouthe chooses which chromosomes of the cunent generation
would be fit enough to be re-labeled as parent chromosomes.
The remainder of this chapter is devoted to a discussion of the various subrouthes
depicted in Fig. 3.0. The material presented in the remainder of this chapter is essentid
in creating for the reader, a better understanding of Genetic AIgorithms. Also, this
chapter introduces some new Genetic Algorithm techniques developed during the
compktiun of this thesis.
The review of the crossover techniques described in section 3.4 were based upon
a review of these publications: Back (1996)' Davis (1991), Michalewics (1992) and
Syswerda (1 989).
3.4 Crossover
Crossover occurs when two parents exchange non-overlapping parts of their
respective chromosomes to produce clddren. The order of the crossover is d e h e d by
the number of sections which the parent's chromosome are divided into. Below is an
example of a one-point crossover of a 6 charac~er chromosome.
The chmmosome used in Fig- 3.1 used 6 characters (or sectors), where each
sector c m be occupied by either a zero or a one- This type of encnding (Le., using zen>s
and ones) is often used for systems that require scheduliag of simple devises. The pump
as defked in this thesis (Le., GAHOS-1 and GAHOS-2) is considered simple since it can
be either on or off (i.e., only two choices). The digit zero is used to represent the pump
king tunieci off, whiie the digit one represents the pump king tumed on. In order to
simplïfjr Fig. 3.1, it was given a chromosome of only 6 sectors (schedule made of 6 time
uni&)- The simdations done in GAHOS are aIways 24 hours long and thus the mallest
pump scheduling chromosome is 24 sectors long (using 1 hour time seps). The larges
pump scheduling chromosome is 96 sectors long (using 1.5 min. time steps).
Fig. 3.1 : An example of a one-point crossover.
Two parent chromosomes (1 and 2) are to under go a one-point crossover d e r the fourtb character position (Le. caIIed loci-). Parent 1 : (1 - 1- 1,l- 1-1) and Parent 2: (0,0,0,0,0,0)-
Parent 1: 1 1 1 1 / 11 ChiId 1: 1111 100
Parent 2: 0000 1 OO CMd 2: 0000 1 1 1
The loci at which the crossover occurs is randomly selected by the computer. I f the computer has a retumed the integer 2 as the crossover loci, the genetic exchange would have looked like this;
Parent 1: 11 1 I I 1 1 Child 1: 1 1 1 0000 =
Parent 2: 00 1 0000 ~ h i l d 2 : 00 11111
One can imagine that during a one-point crossover, each of the two parent
chromosomes are divided into nvo separate sections. The Left side (or start) of the
chromosome is called the ccHead"T dY1e the ri& side (or end) of the chromosome is
called the "Tail? This is illustrated in Fig. 3.2, shown below.
Fig. 3.2: An example ofa one-point crossover using "Head" and "TailY illustrations. r Parent 1: Hl-TI Child 1: Hl-T2
3
1 Parent 2: H2-T2 Child 2: H2-Tl . 1
Once the parent chromosomes are divided into a '-Head" and "Tail" sections, the
cornputer produces two children which use the "Head" of one parent and the "Tail" of the
other parent* Hl must be the same Iength as H2 and TI must be the same Iength as T2.
However, the '%ead" and "Tail" sections need not be the same Iength. As can be
observed fiom Fig. 3.2, a one-point crossover produces two distinct children. The first
child (Le., Hl-T2) uses the head of parent #1 and the tail of parent #2. The second child
(i-e.. H2-T 1) uses the head of parent #2 and the tail of Parent #1 .
The one-point crossover method is the technique used in both GAHOS-I and
GAHOS-2. This particular techniques was chosen afier a carefüi review of two other
methods (a summary of this review can be found in section 3.5). An introduction to the
two other crossover techniques is presented below (these are the two-point crossover and
the uniform crossover)r
A two-point crossover shply requires the deEinition of a middie section
represented as M. The first parent will be represented by Hl-Ml-TI, and the second
parent by H2-M2-T2.
Fïg. 33: An example of a two-point mssover.
Parent I : Hl-MI-Tl ChiId 1: Hl-M2-Tl -r.
Parent 2: H2-W-T2 Child 2: H2-MI-T2
The template used for the two-point crossover technique can be used for higher
order crossovers as we& This is accomplished by breaking up the "Middleyy part of the
parent chromosome into sections. In Fig. 3.4 shown below, the letter and subscript are
used to identifjr the section, while the number in nomial font is used to identify the parent
which it belonged to.
Fig 3.4: An example of a three-point crossover.
Parent 1: Hl-Mil-M21-Tl Child 1: Hl- M12-M21-T2 =
Parent 2: K2-M12- M22-T2 Child 2: H2- MI 1- M22-TI
The h a 1 crossover technique that wiLl be described is the d o m crossover
method (Syswerda, 1989). The method is ben explained as foiiows. For each bit
position of the two children, the computer randomly draws which parent will contribute
its bit to which child (Fig. 3.5).
Just as in the previous techniques two parents are selected. The computer
randomly generates either a O or 1 aad repeats this procedure as many times as there are
bits in the chromosome. This string of zeros and ones is c d e d the template. Once the
template is complete an exact opposite of the templaie, called the anti-template c m be
constructed. The template is used ta constnict child 1, while the ad-template is the basis
for child 2 (The bits of Parent 2 are bolded in order to show their final locations).
Fîgi 3.5: An example of the uniform crossover method
Parent 1 1 0 0 1 0 1 1 Parent 2 O 1 0 1 1 0 1
Template l L O l O O l
Anti-template O O 1 O 1 1 O
Child 1 L O O 1 1 0 1 Child 2 O 1 0 1 0 1 1
- - -
As cm be seen in Fig. 3.5, the anti-template is constmcted by taking the template and
simply substituting a zero in place of a one and visa versa. In both the template and anti-
template string, the number one represents parent 1 and number zero represents parent 2.
3.5 Crossover Methoas Cornparison
In the previous section the reader was introduced to the most current and popular
crossover techniques to date (Michalewics, 1992). The curent discussion focuses on the
advantages and disadvantages of the one and NO-point crossover method, as well as the
uniform crossover technique. Crossovers that utilize more than two points will not be
discussed since they are generally found to be inferior to the other methods (Michalewics,
1 992).
Before comparing different crossover methods it is advantageous to first introduce
the reader to the notion of the schema. A schema is a special chromosome (Le., string of
bits) that is made of a combination of 1, 0, and "*". The symbol "*" is interpreted as a
don 't cme symbol. The bit at which the "*" symbol is foimd can be changed to either a
zero or a one with no effect on the solution (Michdewicz, 1992).
A popuiar question is, how does a schema fit into the scope genetic algorithms?
The answer is that genetic algorithms strive to find solutions to ciifficuit problems optimal
(but usually settle for near-optimal). Most engineering problems are such their absolute
best solutions are impractical. For example, afier analysis of a water distribution system,
it was concluded that the best solution is to buiId a storage reservoir with a capacity of
4398.15 m3. Of course no engineer would insist on building that exact storage tank, but
would settle for a similar and commercially available substitute. The fÏtness (i.e., quality)
of this substitute solution would be very close to the absolute best solution and both
solutions would be practically identicai in physical form. In such cases (these as weiI as
in the problem stated in this thesis) it would be advantagcous to create a template (i.e.,
schema) for near optimal solutions. The following exarnple demonstrates the use of a
schema.
Fig 3.6a: An example of the schema principal in a real engineering problem
As a civil engineer you are face J with a storage tank size optimi7;ition problem. At your disposal are the following eight tank volumes.
1200 1400 1600 1800 2000 2200 2400 2600 (allinm3) A colleague has heard of your problem and has written a very advanced GA routine. The colleague has concluded that the optimal tank volume is 1800 m3. Never-the-less you proceeded and write your own less sophisticated GA program, but could not converge on a single answer. For the past 50 generation your program could not reduce the nurnber of possible solutions below 5. The fmal 50 generation of solutions produces the following tank volume.
2032 2020 2015 1989 1975 How could the use of a schema have helped you converge earlier?
Fig 3.6b: The solution to the r d engineering problem
Looking at the 5 solutions your program has generated, one c m see that for each of the five so1utions the closest storage tank volume is 2000m5. You as a human being cau make the judgment to settle for a commercia.Uy available tank size. However, how c m you tell the computer to do the same thing.
Fust convert the five solutions into binary fom: 2032 -. 011111110000 2020 3 Oll1ll1OOlOO 2015 011111011111 1989 -. 011111000101 1975 OllllOllOllL
As can be seen nom the binary form alI five chromosomes, they ail have identical nrst five digits (startïng from the right side). In fact the schema 0 1 1 1 1 * * ***** can represent a l l five of these solutions
The schema O1 11 l***++** can be used as a rounding off method for binary chromosomes in this particdar problem. It is important to remember that the schemata for the eight available tank sizes must be done pnor to executing the Genetic Algorithm.
The previous example could have been solved without the aid of a schema By
converting the computer solutions (Le., 20Zm3, 2020m3, 20 15m3, 1989m3, 1975m3) to
cornmercially avaiiable tank sizes (Le ., 20 00m3) the program wodd have terminated
sooner as it converged onto 2000m3 tank volume.
Schemata can be usefid not ody for the purpose of raunding off solutions. There
are many situations in which schema significantIy aid in the convergence of a solution.
Schema are able to do this by identiQing bits (sections in the string) that have linle or no
effect on the fitness of the chromosome as a whole.
Imagine, for instance- a 12 bit chromosome composed of four independent
sections. The first section being 3 bits long encodes parameter A. The second section is
3 bits long and encodes parameter B, and so on for section 3 and 4 for parameter C and D
respectively. By using a schema generating subroutine the program may idenw which
if any of the four are important This type of information wouid only be available via a
sensitivity analysis, which is a large undertaking
It can be helpfùi to think of a schema as a way of representing strings. For
example, the scherna (*,1) represents the *ngs (1,I) and (0,l). The schema (I,I ,0,1)
represents one string only: (1,1,0,1). The schema (*,*,*,*) represents al l strings of length
4. It is obvious that every schema matches exactly 2d strings, where d is the number of
don 't core symbols in the schema. On the other hand, string of length b is matched by
2b schemata The following example illustrates these concepts.
Fig 3.7: Determining dl the schemata for a particular chromosome-
Determine how many schemata there are for the chromosome (01 101) and show al1 oi them.
There are a total of 32 schernata that confom to the chromosome (O 1 10 1) Since z5 = 32 (O1 101) ("1 101) (O* 1 O 1) (01*01) (01 1*1) (O 1 IO*) (**101) (* 1 *01) (*l PI) (* 1 1 O*) (0-0 1) (* 1 *O*) (O* IO*) (01*"1) (O 1*0*) (O 1 1 **) (***01) ( * V I ) (**IO*) (O*** 1) (O* 1 * I) (O**O*) (01 ***) (O* 1 '*) (*1 i**) (*1**1) (O****) pl***) (** I **) (***O*) (****Il Y****>
In the previous pages we have concentrated on understanding the principals of the
schema. This was a i i done for the purpose of assishg the reader through the next three
important sections which use the theory of scheme as a tool for cornparhg different
crossover rnethods-
3.5.1 One-point crossover
The major advantage of the one-point crossover is its simplicity. However, in
ce;iain cases (especially in long and muiti-parameter chromosomes) one-point crossover
schemes are slow to converge. One such example is given below, as can be seen fiom
Fig.3.8 a one-point crossover is unable to combine al l of the high performance
eghlighted) bits.
Fig 3.8: Problematic one-point crossover.
Parent 1 I l O l O l l 1 0 0 1 0 0 Parent 2 0 0 0 1 0 0 1 0 1 0 0 1 0
Using one-point crossover, the above parents are unable to create the schema shown below,
The reader can see this by looking at the way the high performance bits altemate (Le.! zigzag) between the two parent chromosomes- This zigzag action resuits in the inability to divide the parent chromosomes into a "Head" and "TaiI" section that can be recornbined into the schema shown above.
3.5.2 Two-point crossover
A two-point crossover is by far the most popular crossover technique (Davis,
1991). The high performance bits in the chromosomes shown in Fig. 3.8, could have
been combined via the two-point crossover. However there are schemata that the two-
point crossover cm not combine. For example the scherna (*,1,0,0,1,+,1) when divided
into the schemata (*,l, l ,O,O,*,l) and (*,0,0,1,1,*,0) can't be reassembled using the two-
point crossover method.
3.5.3 Unirorm cmssover
The uniforni crossover Big- 3.5) method has the distinct ability to combine ail
combinations of schemata. However, the method is quite 'violent' in the sense that it can
cause a great deal of harm to whatever is good in a chromosome. It is thus advantageous
to not use this method especially in problems which converge easily ~ c h a i e w i c ~
1992). This is because problems that converge easiIy require crossover methods proceed
g r a d d y (Le.? gentle).
3.6 Parent Selection
Sections 3.4 and 3.5 discussed various crossover methods >y which parent
chromosomes pass on theix genes to the children chromosomes. However, the techniques
of choosing which chromosomes would become parents was not discussed.
A population of individuais (parents) reproduce and thus create a new generation
of individuals (chiIdren). The new population of children are evaluated on the basis of
their fitness (i.e., their ability to contend with their environment). Only the fittest
children are allowed to become parents and rhus pass on their genes to future generations.
The term bC~urvival of the fittest" is the basis of the previous paragraph. It is been
used to describe everything fiom prey and predator evolution to climbing the corporate
ladder- Genetic ALgonthms utilize the idea of "survivai of the fitted' within the parent
selection procedure. When an entire generation of chromosomes (Le., solutions) pass
through the parent selection procedure, these chromosomes undergo a process that is best
desmied as "survival of the fittest". In the parent selection subroutioe, the chromosomes
that best meet the objectives and coIlStraints dehed for the systern are the ones which
have the highest chance of passing on their genes. In nature, hi& performing individuals
tend to Iive longer and thus procreate more than low performing individuals. However,
within the reahn of Genetic Algorïthms (which exist within a cornputer), ali chromosome
live the same length of tirne. Thus, the only way of exercising the idea of "survival of the
finest" is to allow high performing chromosomes more chances of procreating (which
takes place withùi the Crossover subroutine), and do the opposite to low performing
chromosomes. In other words, the genes of the fittest chromosomes wiU survive (by
means of passing the genes to children chromosomes).
Sometimes "Survival of the fittestYy can also lead to species or population
extinction if taken to the extreme. Imagine for a moment a specie that has evolved into a
form which fits perfectly with its environment. whose mutation rate is very low and the
gene pool of the species is very small. If the environment should suddeniy change, there
is a good possibility that the species would become extinct.
There are several documented methods of choosing parent chromosomes in GA.
By far the most popular one is called the wheel" (Michalewics, 1992). The
basic principals of the roulette wheel parent selection technique is explahed in the next
section. A comprehensive discussion of how this method is utilized in GAHOS is given
in section 4.2.
3.6.1 The Rouiette W h d Technique
Physicaüy, a typicai roulette wheel is a circle divided into equdy sized slices,
with each slice havuig an equal probability of king chosen. Imagine for a moment a
roulette whe+l with n equaI sfices. Each of the n slices being ailocated to a specîfic
chromosome (ic., child). Next dl n chromosomes are evaluated and docated a fitness
value. A new biased rouiette wheel is constructed- It has n slices, with the size of each
slice being proportional ta its chromosome's fitness- In other words, the ratio of slice
area to the entire wheel is equal to the ratio of the chromosome fitness to the sum of the
entire population's fitness.
By simulakg where a bal1 will stop in this biased roulette wheel we can choose a
new parent (Le., new generation). This bali throwing is repeated n &es. One can
imagine that there is the possibility of producing duplicates within this new generation
(Le., hi& fitness cbromosomes are chosen more than once). This is absolutely normal
and shouid not be inhibited. The sirnplest way to explain this is to parailel this
characteristic of GA to nature. In nature, individuals with better than average fitness will
Iive longer than average Lives and thus produce a higher than average number of
offiring. However, in the make-believe world of GA, all individuals live the same
length of tirne. Thus, each paring of chromosomes is only aliowed two children.
Therefore the oniy way to increase the influence of high penomance chromosomes is to
allow multiples of themselves to be placed in the pool of fûture parents.
The basic algorithms of the roulette wheel parent selection technique is presented
in Fig. 3.9, shown below @Iichalewics, 1992).
Fig. 3.9: The roulette wheel parent selection algorithm
1. For each generation evaluate al l the n members based on their fitness.
2. Place a l l the members of the population in an imaginary queue, the queue need not be
in any particuiar order.
3. For each member in the queue assign a number which is the sum of its fÏtness and the
fitness of every member before it, c d this value the cCrunning total". The "ninnuig
total" of the last member in the queue is assigned the speciai name of "totaI fitness7'.
4. Generate x, a random number between O and totaI fitness.
5. Return the fïrst population member whose correspondhg ninnug total is greater than
or equal to x.
6. Repeat steps 4 and 5 for as many times as there are members wanted in the for coming
generation.
7. Repeat steps 1 through 6 as rnany times as there are generations required.
As previously discussed, certain high perfomiance chromosomes will be represented
vat-ious times in the population. Thus it should not corne as a surprise that low
performance chromosomes not be represented in subsequent generations (Le.. become
extinct). The proceeding example demonstrates the multiple-representation and
extinction characteristics of the roulette wheel parent selection technique.
Fig. 3.10: An example of the roulette wheel parent selection method
Imagine 10 chromosomes with 10 distinct fitness values. nese chromosomes wiii not be
mutates nor wiil they undergo any crossovers. Simply these chromosomes will be used
to illustrates how the roulette wheel method is biased towards the higher fitness
chromosomes in any given population.
The table beIow represents the fitness and ninning totds of the original population.
The total fitness of generation O (Le. original generation) is equal to 76. The next step is
to generate 10 random numbea between O and 76. And to retum the first population
member whose cozresponding Nnning total is greater than or equal to 76 (i.e. steps 4 and
The table above represents the second generation (the f5st generation is the original
population). One can notice that already some chrom~somes are represented twice while
Chromosome Fibiess
Runaing Totai
others have gone extinct.
8 8
2 1 7 7 1 0 1 2 7 59
66 8
Random Number (x) Chromosome Chosen
3 69 66
7 76 34
The above table represents the third generation. As c m be seen the hi& performance
64 8
Chromosome Fimess
chromosome # 3 is present in 6 out of the 10 possible chromosome types. One must
36
9 2
2 5 1 55 3 1 7
1 1
remember that this example is with reference to only parent setection, no crossover or
1 2 3 4 5 6 7 - 8 9 1 0 2 1 2 1 1 7
48
Rumine: Total 1 7 12-4 135 1 3 7 149 7
P
57 f 2 3 1 8
Randorn Number (x) Chromosome Chosen
mutation is occurrhg.
17
48 6
59 1 93 3 1 8
The table shown below summaries how the roulette wheel parent selection rnethod
2 [ 57 1 ) 7
48 6
51 2
52 3
56 3
converges on chromosome #3-
8 3 7 2 6 2 3 1 7 8 2 12
Generation Chromosomes Chosen to continue 1 1 2 3 3 5 6 7 8 9 1 0 2 1 1 i 3 3 1 0 4 7 1 8 3 7 8 3 7 7 1 0 3 4 3 1 0 4 7 7 3 7 8 3 7 3 7 3 5 3 7 7 3 7 3 7 7 3 7
9 2
68
73 1
12 3
1 7 ' 8
57 3
94 11
76
22 3
7 87
3.7 Evaiuation and Fitness Value
Section 3.6 discussed how chromosomes are selected to become parents based on
their fitness value- It also discussed how the fitness value is obtained fiom the evaluator
subroutine. Aii the evaluator subroutines used in GAHOS are based on equations 2.0,
2.3, 2.4, 2.5 and 2.6. Equation 2.4, the total project cost is repeated below in order to
assistance the reader.
Total Project Coa = Cp + CS + (P/A i' r- n)-(j6j-CE + Cp-Rp + CS-&)
Cp = capital cost of pump [$]
Cs = capital cost of storage tank [$ ]
CE = daily electrïcity cost [$/dayJ
Rp = O & M costs of the pump as a percentage of C ,
Rs = O & M costs of the storage tank as a percentage of Cs
In GAHOS-1, equation 2.4 is simplified since the capitd a d O&M costs of the pump
and storag e tank are irrelevant-
The total cost assigned to a chromosome is the sum of the cost given by equation
2.4 plus any associated penalties. The convergence of these costs into a fitness value is
explaineci in detd in section 4.2.2,
3.8 Bit Mutation
There are instances during the creation of the children chromosome whaeby
certain parts of the chromosome are dtered in such a way that they dini from both
parents. This naturalLy occumhg event is called mutation. It is a sporadic yet important
aspect of evolution (both nanilal and cornputer oriented). In cases were certain bits in the
entire population are identical, it is the only way by which to expand the gene pool.
However, mutation to a certain extent bypasses naturd selection, since it may create
characters in chiidren that may have been extinct- As discussed previously in section 3.2,
natural selection is an excellent optiniization tool and thus should not be bypassed
without reason. In the author's opinion, mutation is better described as the "art" rather
than the "science" of balancing population convergence and diversity.
One of the most common methods of bit mutation is to generate uniformly
distributed random numbers (U(0,l)) for ail bits, and if the random number is below the
mutation probability (Le., fiequency), then the bit is altered (Davis, 1991). The mutation
probability is defined as the number of bit mutations per 100 bits. The above example
used a mutation probability of 0.15, however in most cases the probability is below 8%
(or 0.08). The mutation probability best suited for a particular problem or genetic
algorithm c m only be determined by experimentation. The recommended mutation
parameters of GAHOS-1 and GAHOS-:! are available in chapter 6.
In Table 3 .O, when a random number is below the 15% mutation probabiiity (Le.,
0.15) is it boIded. As weU, the bits that are mutated are also bolded.
Table 3.0: The common method of bit mutation (0.15 mutation probabilÏty).
Old Randorn New Chromosome Numbers Chromosome
In the author's opinion the method shown in Table 3.0 (taken fkom Davis, 1991)is
cüïrnbersome and slow. Requesting the computer to generate as m a q rmdom numbers as
there are bits is a huge waste of tirne. A better way to approach the mutation process is
on an individual chromosome level. In this thesis çuch a technique was developed and is
called the Individuai Chromosome Mutation Method (ICMM)-
The mutation method presented in Table 3.0 is caiied CMM (Common Mutation
Method). CMM relays on only one user dehed parameter B, the number of bit
mutations per 100 bits. ICMM requires three such variables. The first is L, were L is the
tength of each chromosome in ternis of number of bits. The second is PI were P is the
mutation probability per chromosome. The third is N. were N is the number of bits to
mutare per chromosome chosen for mutation.
B =L-P-N (3 -0)
B = Number of bit mutation per 100 bits
L = Length of each chromosome
P = Mutation Probability per chromosome
N = Number of bits to mutate per chromosome chosen for
mutation
As can be seen from equation 3.0, the product of L-P-N is actually equal to B, however
the ICMM hoIds a signincant advantage over the CMM.
Both the CMM and ICMM achieve the same bit mutation probabilities, only
ICMM cm do it signiIicantly faster and alIows the user to customize the mutation process
to the systern involved. For example, compare the NO methods on a GA which nas a
population of 1000 chromosomes of 6 bits each. The user would like the bit mutation
probability (Le., £3) to be 0.05. In this example the CMM must generate 6000 (1000 x 6)
random numbers and compare this random numbers to the number 0.05 an equal number
of times.
Lets say the user wouid rather use the ICMM- The user would like to alter one bit
in each chromosome designated for mutation. This means that N is equal to 1, and L is
equd to 6 (6 bits in a chromosome). Therefore P is equal to 0.00833 - 0.008 (since
BILL-NJ or 0.05/[1*6] = 0.00833). In other words 0.8% of the chromosomes should be
chosen for mutation, with one bit mutated in each of these. The ICMM wouid require to
generate 16 random numbers and ody 8 of these need to be compared to the variable P.
A remarkable reduction fiom 6000 random numbers and 6000 comparïsons-
Suppose the user wants two bits to be mutated in each chromosome designated for
mutation. Therefore N would be equal to 2, and thus P would be equal to 0.0042. These
new parameters fûrther reduce the cornputer t h e required- More importantly it shows
how the ICMM aiiows for more flexibility over the comrnon method. Table 3.1. shown
below compares the execution time berneen the common method and ICMM (based
upon a population of 1000,6-bit individuals).
Table 3.1: ICMM vs. CMM nui times
Even at a mutation probability of 50% (B = 0.50), the ICMM is still superior to its
cornterpart. As welf we c m see that at Iower mutation probabilities. the ciifference in run
times are significant. It is for these reasons that ICMM is used in ai l GAHOS versions
presented in this thesis.
.
The ICMM has one inherent shortcoming when compared to the CMM; it may
mutate the same bit(s) M c e thereby eliminating or reducing the extent of the mutation.
The ICMM randomly select chromosomes fkom the generation that WU undergo
mutation, it then randomly select bits (positions) within these chromosomes that will be
mutated. As one can imagine there exits the possibility that the same chromosome could
be selected more then once, and that in the second mutation procedure, some (if not dl)
of the mutations done in the f ist mutation procedure may be erased. The likelihood of
such an event is very smd. For instance. the example suggested in Table 3.1 used a
Mutation probability (B) 1 ICMM (sec) 0-0 1 1 1 0-1 6
CMM (sec) 15-4
popdation of 1000, L quai to 6, N equai to 2 and P equd to 0.0042. For this particula.
example the probability that a bit wodd be mutated twice is 1 .96x10d (based on - [IV / L ] ~ ). However, if one wishes to eIiminate this possibility it may be done using only a
few extra Lines of computer code. The user can insert an 'If-Else block' immediately
proceeding the section that generates the random number (th& represents the
chromosome to be mutated). Using these new Lines of code the computer will be able to
reject random numbers that were previously picked.
3.9 Summary
Chapter 3 presented the reader with the fundamental principals and techniques of
genetic algorithms. The objectives of this chapter were twofold: i) to provide the reader
with a general understandhg of holv genetic algorithm fhction ii) to increase the
readers understahg of how genetic algorithms are employed this thesis. Below is a
summary of the most important themes discussed in this chapter.
GA where inspired by the theory of natural evaluation.
The solutions used in GAs are called chromosomes~
The sum of al1 the chromosomes is calied the popul-it- ion.
The size of the population is kept constant throughout the simulation.
Chromosomes are in coded form and must br decoded before being evaluated.
Chromosomes are evduated for the purpose of determining their fitness value.
The fitness value reflects the a b i l i - of a solution (Le., chromosome) to meet the
objective(s) and constraint(s) associated with the system.
Crossover occurs when parents exchanpe of non-overlapping parts of their respective
chromosomes to produce chiidren.
O The crossover technique utilized in GAHOS is the one-point crossover method.
Parent selection is the process by which certain children chromosome are selected to
become parents and thus pass on their respective genes.
O The rouiette wheel method is the parent sefection process used in GAHOS (discussed
in M e r detail in section 4.4 and Appendix 10).
a Mutation may cause the chromosomes of children to hclude bits that were not present
in either of the parent chromosornes~
a The ICMM (Individual Chromosome Mutation Methoa) holds a nibstantial advantage
over the CMM (Common Mutation Method).
Even thought the ICMM is computationally faster than the CMM, both these method are
used in GAHOS-1 and GAHOS-2, The reasons behind thk decision c m be found in
section 4.5.
The next chapter (chapter 4) \vil1 discuss in detail how the different versions of
GAHOS are able to optunize the hypothetical water distribution system. This chapter
wilI also includes a section that describes how GAHOS-1 and GAHOS-2 where
vdidated.
4. THE STRUCTURE OF GABOS
4.1 Introduction
This chapter summanPs the various subrouthes used in GAHOS-1 and GAHOS-
2. The purpose of this chapta is to give the reader a better understanding of how
GAHOS-1 and GAHOS-2 are st~ctraed as weil as how ta use these progrm. The
chapter ends with a review of the verification process which GAHOS-1 and GAHSO-2
undement.
4.2 Overview of GAEOS-1
As previously discussed there are two versions of GAHOS presented in this
thesis, GAHOS-1 and GAHOS-2. The nrst GAHOS-1, was designed as a tool for the
opthization of the day to day operation of a water distribution system. The program is
capable of determinhg the most optimal pumping schedule as well as the optimal way of
managing the water within the storage reservoir.
The pumping schedule is simply the timetable of processes occUmng within the
pumping system. Since the hypothetical water distribution system created in this thesis
uses only one pump with only two settings (Le., on or off). The pumping schedule is
essentially a list of times the pump is turned on or off.
The amount of water stored in the reservoir at the start of the simulation (i.e., tirne
zero) has a profound effect on the characteristics of the optimal pumping schedule as weii
as its associated electricity cost (see Appendix 1). In this thesis a variable has been
defined that refiects the quantity of water at time zero, this variable is called the SCR
(Starting volume to Capacity volume Ratio). The volume of water at time zero can be
found by mdtipIying the SCR by the maximum storage capacity of the reservoir-
GAHOS-1 c m simuitaneously determine the optimal pumping scheduie and SCR value-
Since time zero is defined by the user, thus the SCR vahe deteRnined by GAHOS-1 is
the optimal volume of water at that specified tune. Also since the program can control
the volume of water in the tank @y i) controllhg the pump and ü) smce the program
hows how much water is d m .. out) that is equivalent to managing the volume of water
in the storage tank throughout the simulation. In other words GAHOS-1 optMizes the
pumping schedule and resemoir operation simdtaneously for a 24 hour block of tirne.
Like all Genetic Algorithms, GAHOS-1 uses chromosomes to encode sets of
instructions representing solutions. Each chromosome contains a complete (24hr)
pumping schedule and an associated SCR value. GAHOS-1 (as well as GAHOS-2) uses
time steps between 15 and 60 minutes (typically either 15, 20, 30, 40, 45 or 60 minute
time steps).
Each and every chromosome in GAHOS-1 has at its disposal a 97 sector long
array. The first 96 sectors are reserved for the pumping schedule (each sector storing
either a zero or one), whüe the 97& sector is reserved for the SCR value (storing an
integer between zero and 1000). A pictonal view of the chromosome structure used in
GAHOS-1 is shown below as Fig. 4.0. The entire chromosome is defhed as a static
array (array of integer values) and thus does not change (static array as opposed to a
dynamic array is used). When the t h e step is 15 minutes, the entire chromosome is
utilized (Le., sector 1 through 97 are storing relevant instnictiom). However, when the
time step is defined as one hour, only the nrst 24 and the 97* sectors are dized, sector
numbers 25 through 96 are empty. This of course is a waste of memory, however the
simpiicity of statîc anays is a major advantage.
Fig. 4.0: Chromosome structure of GAHOS-1
1 Sectors 1 through 96 1
As mentioned previously the nrst 96 sectors can either be O or 1, where O is pump
off and 1 represents the pump on (the pumping schedule is 96 sectors long because there
are 96 fifteen min. sectors in 24 hours). The 97h sector is a whole number between O and
LOO0 (representing SCR x 1000). An integer requùes Iess cornputer resources, and thus it
is advantageous to define the array as integer, with the fiaction created by dividing the
integer of the 97'h sector by 1000. This would be equivdent to a three decimal float.
4.3 Ovemew of GAHOS-2
GAHOS-2 was created with the intention of becoming a design tool for water
distribution systems. This version of the software can also optimize the pimiping
schedule and SCR value in the same manner as GAHOS-1. However, GAEfOS-2 goes
fiirther by detennining the best pump and storage tank to couple with the pumping
schedule and S C R value
The input nle for GAHOS-2 (explaiwd later in the chapter) contains a list of
pumps and storage tanks that the program c m consider (as options) in its anaiysis. The
program sirnultaneously detemiioes the optimal combination of pump, storage tank, SCR
value and pumping schedule.
The chromosomes used in GAHOS-2 are very similar to those used in GAHOS-1.
The only Merence is that the later versions has more sectors in each chromosome and
because of this is divided into two parts. The first part is 96 sectors long and is reserved
for the pumping schedule. The second part is 3 sectors Iong and is reserved for the SCR
value, the storage tank identification and pump identification.
Each and every pump and storage tank option considered in the optimization
process is given an identification number. For example, if GAHOS-2 was given 6
separate pumps and 4 separate tanks to consider. Then pump identification numbers will
range nom 1 through 6, while the tank identification numbers WU range 1 thugh
4. For each and every chromosome in this example the foliowing two properties must be
true:
1. The 2nd last sectors (i.e., 9grn sector) must contain a number between 1 and 6.
2. The last sector (Le., 9gm sector) must contain a number between 1 and 4.
Fig. 4.1, shown on the next page presents a pictorial view of a GAHOS-2
chromosome. In Fig. 4.1, the $CR value is 0.547, and as can be seen the number
presented in the 97m sector is acutely 547 (the product of 1000 x 0.547). This particuiar
chromosome entails the use of storage tank number 2 and pump number 5.
Fig. 4.1: Chromosome structure of GAHOS-2
Bits 1 through 96 4
4.4 Evaluation
The evaiuation of the chromosomes in GAHûS-1 is different than that of
GAHOS-2. In GAHOS-1, the objective is to h d the lowest possible daily electricity
cost This is accomplished by using equations 2.5 and 2.6 introduced in section 2.7
entitled "Discount rate, Inflation rate and Operating life".
In GAHOS-2, the objective is to find the lowest possible project cost. For this
purpose equations 2.3, 2.4, 2.5 and 2.6 are used. Evaluating the chromosomes of
GAHOS-2 is more complicated than those of GAHOS-1. O S - 2 considers the initial
purchase cost of the pump and storage tank. Also the O&M cost of the pump and storage
tank is c o n s i d d GAHOS-2 is based on the total project CO% thus the length of project
(in years) can be of great inauence on the characteristics of the optimal solution. As
discussed in section 2.7, when evaluating a long temi project it is best to use a m e n t
woah factor that assesses discount rate, inflation rate and off course the length of the
project itseK
Both versions of the software evaiuate the chromosomes over a 24 hour
simulation. In these simulations smaller t h e steps have the ability to decrease the
calcdated costs. This occurs because smaller tune steps d o w the pumphg scheduies to
be more flexible. However, the smaiier the time step the higher the computatioIlZLL
difnculty. The previous sentence is not meant as a deterrent for using small time steps
(15 min. time steps as opposed to 60 min. time steps). The statement was included
simply because it is true. As well, one of the main advantages of GAHOS over
conventio~ optimization method (like dyaamic progpmming or Lagrangean relaxation)
is that these conventionai method are crippled when required to use smail time step (60
min. or Iess).
As previously discussed in aiis thesis, the fitness value of a chromosome reflects
its ability to meet the objective(s) and constraints(s) associated with the system.
Chromosomes that fail these constraints mut be p e d d by decreasing their fitness
values. In both GAHOS-1 and GAHOS-2 the measured characteristic is cost, and it is the
objective of these programs to find the lowest cost solution (Le., optimal solution). Thus
the simplest way of penalinng chromosomes that fail to meet constraints is to increase
their associated costs-
There are three different coI1Straillts defined in GAHOS:
1. The storage capacity of the water reservoir can not be exceeded.
2. The water demand must be meet at al l times (i.e., the storage tank must always contain
a sufEcient quanti@ of water to sati* the demand).
3 - The simulation must tenninate (i-e., end the 24 hr simulation) with at least an e q d
amount of water in the tank as it started with. In other words the SCRo must be greater or
equal to the SCRW
The second and third constraints are more troublesome than the first. Constraints
No. 2 and No. 3 are considered troublesome since by violating these constraints a
chromosome can achieve a lower cost than by not violating them. Because lower cost
chromosomes are superior to higher cost ones, the Genetic Algorithms naturally would
favor (i.e., give an advantage to) the solution that violates coIlStraints No. 2 and No. 3.
For instance, a chromosome violathg constraint No. 3 can obtain very low
electricity costs. A high SCR value can allow for the pumping schedule to reduce (if not
eliminate) the quantity of times the pump is turned on. By not stipulating that the SC& 2
SCR24, the electricity cost of the first day (i.e., hours zero through 24) is reduced at the
expense of the every day following.
A chromoorne that is not penal'id for violating constraint No. 2 may be at an
advantage over a chromosome that has not violated the constraint- The supply of water to
a population requires monetary expenditures- Therefore if a chromosome is not obliged
(i.e., forced or peaalized) to supply the necessary amount of water, than it would simply
choose not to supply the water.
Constraint No.1 is different than its cornterparts It is physically impossible to
exceed the volumetric capacity of a storage tank Any chromosome that attempts (via its
pumping scheduie) to exceed the maximum capacity of the storage tank must be
discouraged (Le., stoppeci). In GAHOS-1 and GAHOS-2 this is done by simply
eIiminating that volume of water that surpasses the storage capacity (howcver the pumps
were still running and wIISUII1i11g electricity at those times). By eliminating this excess
volume of water the chromosome was not able to violate the Iaws of physics. There are
non-violating chromosomes which can generate the same amount of water in storage (and
in the same time h e s ) but at lower cost. Thus the violating chromosomes will
naturally become extiact. Therefore there is no need to assign a monetary fme to this type
of violation.
Constraints No. 2 and No. 3 must be monetarily penalized- These penalties are
derived in such a way as to make it impossible for a violating chromosome to be
economicaily cornpetitive with other non-violating chromosome. For example, in the
simulation described in Appendix 2, the daily electncity cost for even the worst non-
violating chromosome was less than $200 (actually $151.03). The optimal chromosome
resdted in a M y purnpiag cost of only $53 -68. Therefore, for this padcular example, a
violating chromosome must not be able to achieve (at a minimum) a pumping cost Iower
than $53.68. It would even be better if the violating chromosome was penalized to a
point that its cost would be higher than even the most inefficient solution.
For the input files contained in the appendices of this thesis the penalties levels
were investigated and set to the fo11owing values: i) The software charges the
chromosome a penalty of $2000/m3 for every cubic meter of demand not met This
analysis is done in every t h e step. ii) The software charges the chromosome a penalty
of $200/m3 for every cubic meter of storage volume below the initial volume. This
analysis is done once at the end of the 24 hour simulation.
The above three penalties are ail Iocated within the evaluation subroutine (called
evuZ() ) of GAHOS-1 and GAHOS-2. The acnial fines are defined withh the cornputer
code, thus the user in unable to directly altered these fines. However, the fines can be
altered at the source code (Le., the actuai C* code that is available in the appendices 8
and 9).
4.5 Reproduction
The basis of the reproduction procedure of GAHOS is the roulette wheel parent
selection method. The roulette wheel parent selection method used in the software has
two variables (as discussed previously in section Appendix 10). The f h t is the
magnification factor (M) and the second is the mapnincation exponent (P).
The input parameters as defïned in the appendices do not require a magnifÏcation
factor (see section A10.3). However, a magnincation factor might be needed if the input
parameters signifïcantly alter the costs associated with the chromosomes (Le., alter the
cost fiom their current values). Section A10.3 located in Appendix 10 describes a
f o n d a that shodd be used to detemine if a d o r what the M value shodd be. In both
GAHOS-I and GAKOS-2 the magnÏfication factor is a constant defined witbia the code,
In order to alter this constant the user must alter the definition of the M value within the
evaluation subroutine (called evalo).
The magnifïcation exponent (M) is much more important than the magnilïcation
factor (P). This is because the P value controls the degree that the roulette wheel method
is biased (see section AI0.3). The value of P must be customïzed to the specinc system
in question. If the P value is to low, the software wiil take a long time to reach the
optimal solution. Too high of a magnification exponent will cause floating point errors
and fitness value tnincations. The author suggests that P be defied between IO and 15
while running GAHOS-1. W e Ruining GAHOS-2 the P value shodd be between 2
and 8 (Appendix 4).
The software developed in this thesis cornes with a built-in safety procedure
called absolute-best. The procedure works iike so: every generation, the chromosome
with the lowest cost is replicated and its copy is stored for future use. Once a
chromosome with a lower cost is found, the old chromosome is erased and its place is
taken by the new chromosome. Without the absolue-best fûnction, the simulation
outcome would be completely dependent on the results of the 1st generation. This is
dangerous because many times the GA rnay find the optimal solution and then begin to
oscillate. The absolwe-besî hc t ion ensures that the optimal solution (Le., best solution
-found during the e n t h simulation) is returned regardless of the red t s of the nnal
generation.
In order to encourage the soha re to investigate the specincs of the absolute best
chromosome, the absolute best chromosome is introduced once into every generation
prior to crossover. This is done by randomly erasing one chromosome and replacing it
with a copy of the absolibe best chromosome. If the previous generation naturaUy
produced the absoIute best chromosome then the absolute-best fünction is redundaat
because the roulette wheel method will reproduce that chromosome. However if the last -
generation did not have a high perfonning chromosome, then the absolute-best hc t ion
wiii help the population recover.
Fige 4.2: The effect of the absolute-best hction.
- With absolute- best
. .# - - .Without absolute- best
Number of generations
As can be seen fkom Fig. 4.2, the absolute-best function can on average decrease
the number of generation GAHOS requires to find the optimal solution (Le., the Gp
value). It is important to remember that the term 'caverage" was used in the above
statement. This is because no two executions of GAHOS are exactly the same (Le., they
all utiüze random number genenitors which are by dennition random). Thetefore it is
fdse to state that a GA utilking the absolute-best hc t ion will at dl times outperfom an
identical GA wiaiout the absolute-best function. However, on average the absolute-best
fimction will reduce the Gp value and produce best solutions at any given generation
(Appendix 16).
4.6 Muîation
Section 3.9 entitled "Bit Mutation" descriibed two techniques: i) a conventionai
method c d e d the CMM (Common Mutation Method). ii) A new and in many ways a
superior technique cded the ICMM (Individual Chromosome Mutation Method). The
ICMM is used in both version of GAHOS and is sometimes complimented by the CMM.
A discussion of this is available in the following paragraphs.
In both GAHOS-1 and GAHOS-2 the individuai Chromosome Mutation Method
is used to conduct mutation on the chromosome sectors representing the pump schedule
(i.e., the first 96 sectors of the chromosome). The user inputs the mutation probability
per chromosome (P), as well as the number of sectors (Le., bits) to mutate per
chromosome chosen for mutation ( N ) (reader may find it helpful to review section 3.8).
A second mutation procedure called 'bit switching" is utilized in parallel with the ICMM.
Bit switching was developed in this thesis specincaüy for GAs that incorporate
scheduling. The idea stems from the fact that as the GA approaches the optimal solution
the scheduling portion of the chromosome needs an extra boost that conventional
mutation (even ICMM) methods can not deliver- As the chromosomes of GAHOS
approach the optimal solution, their schedules may have the correct number of zezos and
ones but a few of them are d y in the wrong location. "Bit switching" can sometimes
alleviate this problem by randomly switching these bits.
An example of "bit switching" is given in the following paragaph. Imagine a
pumping schedde that uses two hour time steps. The SCR value, tank size and pump
discharge are dictated by the user. It is also detemiined that the pump m u t be running 20
hours per day (determined by cornparhg the average water demand rate and the pump
capacity). The electric utility has set 14 peak hours (Le., high electricity cost) and 10 os
peak hours (Le., low electricity cost). Imagine that the GA is producing many near
optimal chromosomes (i-e., two bits must exchange their values). These chromosomes
are only using ody 8 of the off-peak hours and thus the pump is on for 12 of the peak
hours. These chromosomes wodd be optimal if they could somehow manage to reduce
the peak pumping by two hours and at the same time increase the off-peak pumping by
two hours.
Bit switching allows for pairs of bits to switch identities as shown in Fig. 4.3.
This works well for near optimal schedules since it does not change the numbers of zems
and ones, only a few of their locations (i-e., one or two pairs of bits are switched).
Fig. 4.3: The Bit Switching procedure
Bit switch thk pair
Resulting chromosome
Bit switching ai& in scheduliog where there is an off-peak and peak penods. Also in
cases where there is a cost associated with turning on a pump, bit switching will
consolidate the pumping bits of the chromosome (ie., altempt to group di the 1 bits
together in the most economical way).
In both GAHOS-1 and GAHOS-2 the user must spec* the number of pairs to
switch. Of course not ali the chromosomes in a population must undergo bit switching,
only a few chromosomes are chosen for this procedure. Thus there is a specified
probability per chromosome.
So far the reader has been presented with a discussion of how ICMM and bit
switchùigare used on the scheduling bits of a chromosome. However the chromosome
retains Information on more than just the pumping schedule. For exampie, the
chromosomes used in GAHOS-1 hold data on the SCR value and those of GAHOS-2
hold data on the SCR, pump type and storage type- These bits must dso undergo
mutation. For these sectors the common bit mutation method is used. In order to
simpli@ the code, a single bit mutation probability represents ai i 3 data types.
The next section will focus on the manner in which input is presented to the
cornputer prognims. The input and output mes of both GAHOS-1 and GAHOS-2 will be
discussed and references made to exampies of these files (available in the appendices).
4.7 Input and Output
The input data required to nm both versions of GAHOS are divided into two
fomis: i) input file and ii) data entered via the keyboard. The input nle specificatiom for
GAHOS-1 m e r fiom that of GAHOS-2. This is also true for the data entered via the
The input file of GAHOS-1 (see Appendix 14) b e g h with 24 numbers (one
number per line) representing the electricity demand data in units of $/kWh The first
electricity cost figure represents the cost of consuming electricity at time zero (fïrst hour
of simulation), while the 24& number (i.e., line) represents the eiectrkity cost for the last
hour of the simulation. The next 24 lines (one number per h e ) represent the water
demand rates for time zero through 24 (the units used are m3/s). This is the complete set
of data (in input nle form) needed to nm GAHOS-1, note that the file is only 48 h e s
long-
The input nle for GAHOS-2 (see Appendix 15), uses the same format as that of
GAHOS-1. However, adadditional Lines of data are required (lines 49, 50 and higher).
Line 49 is actually a blank line us& to divide the above data from the storage tank data
discussed below. Every storage tank that GAHOS-2 must consider is describeci by 3
parameters Iocated in a single line starting at h e 50. The first parameter is the capital
cost (Le., in current value Canadian dollars) followed by the O&M cost for the nrst year
(represented as a percentage of the capital cost). The third parameter is storage capacity
in m3. The reason behind the use of these panuneters are available in section 2.7.
M e r the storage tank data is completed cornes another blank h e foiiowed
immediately by the pump patameter data Just Like the tanks, every pump is described in
just one h e (however using 5 parameters not 3). The parameters in order fiom left to
right are: capital CO* O&M cost for the nrst year represented as a percentage of the
capital cost, pump flow in m3/s, head in m, and pump efficiency represented as a f'raction
not a percentage.
The data prompt (requested or asked) by the software is very simple to
understand. This includes the input nle name, time step size, population sue, number of
generations required and mutation parameters. It is important to note that the input file
must be in a simple text only format (Le., unfonnatted). The reader c m make sure of
this by editing the fik in a word processing software (i.e., MS Word, Word Perfect or
even MS DOS file editor) and saving it as a text file (Le., ".O@). However once this file
is saved as a 'Itxt" nle, the name of the nle can change. For example "data-txty' can be
changed into ccToronto.mayyy. GAHOS does not need the input nle name to end with
cC.w*
4.8 Mode1 Validation
The customary method of validating an optimization mode1 is to produce what is
caiied an exhaustive enumeration search. This search requires the creation and
evaluation of every possible solution. GAHOS-1 was validated d g exhaustive
enumeration, however do to practical reasons GAHOS-2 could not be validated this way
(as will be discussed below).
GAEIOS-1 and GAHOS5 are much iike a flight of stairs. Each version is based
on the structure of the pnvious one, yet each new program incorporates more complex
optimization objectives. For example, the original version of GAHOS-1 (cded
GAHOS-1A) optimized the pumping schedule for a given set of conditions; a specined
pump, a specified storage tank and a specined SCR value. The final version of GAHOS-
1 (called GAHOS-1B) did not need a specified SCR value since it could optimize it (Le.,
SCR) dong with the pumping schedule. GAHOS-2 could optimize the pumping
schedule, SCR value, and choose the best combination of pump and storage tank.
The mode1 validation process was conducted in three separate stages. The nrst
stage is based on G - S - I A . The second stage is based on GAHOS-IB, while the third
stage is based on GAHOS-2. As previously rnentioned, each version of the softwate is
based on its predecessor. Therefore components that have been validated in previous
versions were not revaiïdated.
Table 4.0: A summary of the three versions of GAHOS used in the validation
4.8.1 F h t Stage
GAHOS-1A could only optimize the pumping schedule. It required the user to
input the SCR as weil as the pump and storage tank parameters. The pumping scheduie
could be partitioned between 15 minute to one hour segments. In other words the
scheduiing chromosome could be between 24 to 96 sectors long depending on the time
step specined. The program was executed using a one hou tirne step based on the
average day demand rates (caiied AVRDAY-1 and discussed in section 2.2 and in
Appendix 6).
Name of Version GMOS-1A
GAfIOS-1B
GAHOS-2
A special computer code called ENUMERO (named as such because it is based
on complete enurneration) was constructed to test every possible combination of pumping
Main Attribates Determines the optimal pumping schedule. User must define the ' SCR value, Determines the optimal pumping schedule. The software also determines the best SCR value. Determines the optimal pumping schedule, SCR value, as weli as the best pump and tank types. The user must define (in an input nle) an inventory of possible pump types and pump types.
J
schedule and retum the chromosome with the lowest pumping cost (Appendix 12).
ENUMERO created ali z2" combination of possible chromosomes using binary additïon,
an example ofthis is d e r n o m in Fig. 4-4 shown below.
Fig. 4.4: An example of bi- addition
. * . . . . * . * . . * . . * . . . - - - - - . 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l l O l I l l l l l l l l l l l l l l l l l l l l l l O l l l l l l l l l l l l l l l l l l l l l l l l
These procedures took several hours and could not have been possible if the tirne step
was much smaller than 15 or 20 minutes. The structure of ENUMERO is very simple
since it only has two main duties: i) The creation of chromosomes using binary addition
and ü) The evaiuation of every chromosome created. ENUMRO is considered to be a
"dumb algorithm" since the vast majority of the chromosomes it produces violate the
hydraulic constraints.
4-83 Second Stage
The scheduhg capability of the software has been verified in the first stage
(GAKOS-1 A). The next step is to test the capability of GAHOS to optirnue the pump
scheduling and SCR value simultaneously. This version of the software is calied
GAJ3OS-1B.
The verification of GAHOS-1B is done by running GAHOS-1A approhately
200 times using the entire range of SCR values, fiom O to 1.00 (see Appendix 1). This
experiment identifid the optimal range of SCR values ratios and the corresponding daily
pumping cost. The d t are shown in Appendix 1. By examinhg the solution produced
by GAHOS-lB, it was evident that the program renimed the SCR value which was in the
optimal mge as weil as with corresponding pumping scheduies that generated the
minimum pumpbg wsts.
4.8.3 Third Stage
Based on the results in the first two stages, one can be confident that GAAOS-1B
can op- both the pumping schedule and the SCR value. GAHOS-2 Ïs even more
advanced than GAHOS-1B (and of-course GAEIOS-1A) since it can optimize the pump
and storage tank as weil. The question arises as to how to valiâate this version ?
GAHOS-2 was vaiidated by ninning GAHOS-1B a total of 25 times. It was
decided to examine the results fiom 5 différent pumps and 5 different storage tanks (i.e.
25 combinations). The storage tank and pump options are shown below in Tables 4.1 and
4.2 respectively.
Table 4.1: Cost properties for the five diffierent storage tanks examined
Designation Tank 1 Tank 2 Tank 3 Tank 4 Tank 5
Storage size [ma] 1 P ~ c i p a l Cost [SI 2000 1 580000
M Br O Cost [W 1 7.0
4000 7000 12000 18000
860000 1280000 1980000 2820000
6.9 6.8 6.7 6.6
The lowest cost combination is tank #1 with pump #4. GAHOS-2 is able to corne
to this same conclusion in less than 2 minutes (on an IBM 6x86, 133 MHz processor).
GAHûS-1B provided the M y electricity cost for each of the 25 combinatiom. Then by
hand the capital cost and O&M costs were added.
Tabk 4.2: Cost properties for the five different pumps examined
The project life was assumed to be 20 years with an idlationary constant of 3% and a
discount rate of 10% (realistic for engineering projects, White et al. (1 989)). The resuits
are shown in Table 4.3, below.
The type of validation conducted on GAHOS-2 has a few uncertainties associated
L
Designation
P U ~ P 1
P U ~ P ~ Pump 4 P U ~ P 5
with it. GAHOS-1 A and GAHOS-1B reached the optimal solution (with 100% certainty)
Principal Cost [SI
1 ,116,090 1,023,706 1,178,509 133 1,594 1,193,829
M & O Cost PI 10 13 9 8 11
during the validation process. However, this might not always be the case. AU Genetic
Algorithms suggest that the most optimal chromosome is the one cc~scovereâ" during the
Flow [m3~sl 0.19 1 0.1 80 0.203 0.23 1 0.196
simulation. Yet there is no guaranty that the chromosome suggested by the GA is
actuaily the mathematical optimal solution of the system. Even if the nurnber of
Head [ml 60.3 53 -9 62.1 55.3 68.2
chromosomes and quantity of generations were set equal to absurdly large values.
Efficiency 1x1 78 81 77 76 79
Table 43: Total System Cost for ail possiie combinations
Total System Cost [SI 3,582,489 3 -673,742
Corn bination 1 Eiectricity Cost [Slday] Tank 1 - Pump 1 Tankl-Pump2
3,60 1,887 3245,599 3,898,475 3,986,837 4,090,859 3,998,460 3 ,947,456 4,292,39 1 4,676,8 17 4.80 1.068
~ a n k 1 - ~ u - 3 8 1 -44
~ank3-Pu1&3 Tank 3 - Pump 4 Tank3-mmip5 Tank 4 - Pump 1 Tank 4 - Pump 2 Tank 4 - Pmnp 3
1 Tank 5 - pumi 5 1 58.65 1 7,554,959 1
77.53 66-85
Tank 1 - Pump 4 Tank 1 - Pump 5
When validatiqg GAHOS-2, the author created a poblem with a total of only 25
combinations of pumps and storage tanks- Each of these combinations was tested using
GAHOS-IB. The 25 different optimal solutions where compared and the lowest cost
solution was taken to be the "optimal one". GAHOS-2 was run once and considered a l i 5
pumps and 5 tanks. GAHOS-2 suggested the same combination of pump, tank, pumping
schedde and SCR value that the 25 GAHOS-1B executions did. However, imagine that
by some chance one of the 25 separate executions was defected, and the true best solution
73 -42 85.99
1
5;789-294 6,156,276 7,252,250 7.37650 1
~ a n k 4 - p m i 4 42.39
53.10 42.39 58.65 53 -68 5 1.64 51-21
Tank4-Pump5 Tank 5 - Pump 1 Taok5-mimp2
Tank 2 - Pump 1 Tank2-Pump2 Tank2-Pump3 Tank 2 - Pump 4 Tank 2 - Pump 5 Tank 3 - Pump 1 Tank 3 - Pump 2
4,679,113 4,6 12,544 4,979,526 5,649,3 77 5,977,8 19 5,848,657
58-65 53 -68 5 1.64
58 -79 51 -45 60-66 54.02 64-51 53 -68 5 1 -64
was not found. The faft that this chance exists is the major flaw of the validation used on
GAIEOS-2.
Although some may be uncornfortable with this type of vaIidation, an exhaustive
enumeration would have been impossible. For example an exhaustive enumeration on a
problem with 5 pump options, 5 tank options, 15 min. time steps and an S/C ratio
partitioned in 5% intervals wouId redt in 3.961 x 1d1 possible combinations. Even if a
cornputer could evaluate one billion of these combinations in a second, it would take
1.256 x 1015 yeats tu validate the code.
4.9 Summriry
Chapter 4 presented to the user information pertaining to the: chromosome
structure, evaluation subroutine (including penalties), reproduction subroutines and
mutation submutines. The chapter also introduced the reader to the three stages used in
the mode1 validation process. The key conclusions that cm be drawn fiom chapter 4 are
list below:
O The chromosomes of GAHOS-1 are 97 sectors long
a The chromosomes of GAHOS-2 are 99 sectors long
a The tirne steps used may Vary between 15 and 60 minutes
a Penalizing chromosomes that fail to meet the constraints of the system is crucial
a The absolute-best hc t ion created in this thesis can increase the probability that
GAHOS cm find the optimal solution
r GAHOS uses three mutation methods in p d e l : ICMM, CMM and 'bit switching"
The foiIowing chapter (i.e., chapter 5) focuses on two proposals for the M e r
advancement of GAHOS. The information presented in chapter 4 wili aid the reader in
the comprehension of the recommendations and proposals presented in chapter 5.
5. FUTURE VERSIONS OF GAEEOS
5.1 Introduction
This last chapter is meant to provide the reader with suggestions for M e r
research using the GAHOS platform. Two proposals are presented for developing more
advanced versions of the cornputer software (GAHOS-3 and GAHOS4).
5.2 GAEOS-3 BImeprints
GAHOS-1 and GAHOS-2 incorporated a pumping system consistùig of a single
pump. However in reality most pumping systerns consist of a battery of pumps. These
are typicaUy located in a p d e l format (Walski and Onnsbee, 1989). The proposed
pumping system which could be incorporated into GAKûS-3 is shown below as Fig. 5.0.
Fig. 5.0: GAHOS-3 pumpuig system
- - - - -
As c m be seen fiom the illustration, there are only two types of pumps. Before
each pump there is a valve that controls whether or not the water wiU pass through the
pump. There is also a valve located at the junction where the flow is divided into the
parallel configuration. This particular valve has three distinct settings; it may open both
branches ef the parallel pipes, only one or none. If both branches are open than the
operation of the pumps must be identical for both. This is because the total dynamic head
P H ) produced by the pumps (in each branch) must be identicai in order to unite the
flow again @Ersel, 1989).
There are a total of 7 possible combinations ofpumps. Three for when both
branches are open, three for when only one branch is open (it does not matter which of
the branches is closed and which one is open) and one for when the entire system is
closed These seven wmbinations were based on the assumption that each of the two
pimip types have only a single operating point. In other words a specifïc head, discharge
and energy efficiency ratio. Let us assume that there are actuaily 2 operating points for
each of the two pumps. In other words a high and a low settings.
Pump # 1 Off Off Low
Tbis would result in 17 possible pump combinations. As can be seen there are eight
possible pumping combinations for the single branch and another eight possible pumping
Low Low m3h High Hish Off Off Low Low Low
Kgh
Pump # 2 Hi& Low Off
Branches Both Both Both
I
Low mgb Off
I W h Off Off
Both Both Both
One Irrelevant
Low High Kgh Low Off Low W h Off
Low
Both Botll One One One One
, One One One
combinations for the parallei configuration. The last (Le-, 174 pumping combination is
for when aii pumps are tumed o E
Unlüre previous versions of the computer program, GAHOS-3 would incorporate
both a fime-of-use rate structure and the previously unused peak-demand rate structure.
The program couid evaluate both rate structures, but would only utilize the one with the
higher cost. GAHOSl and GAHOS-2 did not use the peak-demand rate structure since
this type of rate structure does not make sense for a pumping system employing a single
P m P -
The chromosome structure WU be identical to that of GAHOS-1. The only
difference is that instead of simple "zeros" and "ones", ths range of number would be
between zero and 16. A separate array (of 17 sections) will store the electrkity
consumption data for the 17 possible combinations.
It is the author's estimate that the recoding of GAHOS-1 into GAHOS-3 wouid
take between 15-35 hours. The venfication process on the other hand will take
si@cant computer resources and rnight be impossible to do. This is because of the
large number of pump combinations which have a profound effect on the number of
possible purnping scheddes. For example, for the system shown in Fig 5.0 ushg single
operating point pumps (ie., 7 possible pumping combination), one h o u time steps and
using 5% separation for the S/C ratio, this would result in 3 . 8 3 ~ 1 0 ~ ' (or 7 2 4 ~ 0 ) possible
pumping scheduies.
The reader should note that GAHOS-3 would not be Iimited to only the pumping
system ihstrated in Fig. 5.0. It is up to the user to decide on the pumping system
configuration. The software only views the pumping system as an array of possible
pumping combinatiom. Each of these combinations is represented by three numbers; the
total discharge, head and elecfncity collsumption.
5.3 GAHOS-4 BIaeprhits
Even though GAHOS-3 can manage compiicated pumping system that use
multiple operating points, it would not be able to comprehend the complex nature of the
distribution network it supplies water to. Presuming that an elevated storage tank will
meet the pressure requirements for ail nodes in the network is a poor and unreaüstic
assurnption (Chao, 1979). The presence of this asswnption in GAHOS-3 (as weil as in
GAHOS-1 and GAHOS-2) undermines the utiiity of software.
A new software version cded GAHOS-4 wouid attempt to address the
inadequacies of its predecessors. GAHOS-4 wouid be identical to GAHOS-3 as far as
chromosome structure, mutation, crossover and pumping configuration options. The only
difference lays in the evduation subroutine. GAHOS-4 wouid utilize a steady state
network solver for the purpose of gathering data on dl nodal pressures.
The Network Solver (NS) does not need a sophisticated user interface because it
is not in direct contact with the user. However, the NS h a to be very fast since it is used
many t b e s for each chromosome. GAHOS-4 creates an input file for the NS that
indudes information such as the pumping system configuration (Le., which pumps are on
and at what speed), nodal demands and pipe properties. Once the NS has assessec€ the
system, is produces an output file that contains idionnation such as pipe veIocities, pipe
head 10s and n d pressure. GAHOS-4 than analyzes the output file and assigns
penalties for constraints not meet (Le., hadequate nodal pressure).
The size of t h e siep used in the pumping schedule dictates the number of times
the NS must be used before the chromosome is assigned a f ia l fitness value. For
example, a chromosome using a 30 min. time step in its pumping schedule and one hour
time steps for the nodal demand data will require 48 separate evaiuations by the NS. This
occurs because every time the pumping system or demand profile is changed, GAHOS-4
must ensure that the constraints are met It is the srnailest time step of either the pumping
schedde or nodal demand profile that dictates the size of t h e step used in the evaluation
subroutine (i.e., the number of times the NS is used per chromosome).
It is generally the case that the pumping schedde time step is smaller than the
time step used in the nodal demand profile. This is typically do to the fact that gathering
nodal demand data is expensive and thus is not readiiy available. The pumping schedde
time step on the other hand is simply a question of cornputer resources. Maximum
benefit can be drawn nom the software when the time steps are equal.
There are two ways in which to incorporate the NS in GAHOS-4. The first is to
insert the entire NS code into the GAHOS-4 code- The second method is to define the
NS as a separate executable entity, which is called (Le., activated) by GAHOS-4. The
first method had the advaatage ofhaving the entire software within one file which resuits
in quicker communication between the different subr~utines~ However, the disadvantage
is that the NS code must be altered in order to be compatïïle with the rest of the GAHOS-
4 program. Method number two requires no changes to be made to the NS. However,
the communication between the NS and GAHOS-4 is done using input and output mes
which greatly increase the execution tirne of the total program.
Even though a steady state network solver was suggested for use in GAHOS-4, other
types of NS can aiso be used A more accurate type of NS wodd be one that considers
transient flow as opposed to simply steady state flow (Frey et ai., 1996). The type of NS
used in GAHOS-4 should reflect the sort of analysis the user is interested in.
6. CONCLUSIONS AND RECOMENDATIONS
The focus of this thesis was the creation of a cornputer software program that
utilizes the theories of Genetic Algorithms for the purpose of optimizing a water
distribution systems. The cornputer program was caiied GAHûS (Genetic Algorithm
Hydraulic ûptimhtion Software) and applications oftwo versions of this program were
presented.
Below is a list of the concIusions that resulted h m the research conducted in this
thesis. These conclusions represent both general statements dealuig with Genetic
Algorithms and conclusions based on GAHOS.
1. The speed with which a Genetic Algorithms can reach the optimal solution is highly
dependent on the time required to evaluate an individual solution. A slow evaiuation
subroutine (i.e., cumputationally extensive) c m render a Genetic Algorithms
impracticai for real the andysis,
2. Genetic Algorithms including GAHOS-1 that are designed to execute in real thne
must utilize a fast evaluation procedure (a minimum of 2 chromosome evduations per
second).
3. GA'S including GAHOS mut be able to proficiently use "penalties" in order to reach
the optimal chromosome quickly. Penalties are the only means that a GA has to
restrict the use of chromosomes that violate the systems constraïnt(s).
4. The fitness value is a method by which a GA can promote high performing
chromosomes.
5. AU GAs must have their mutation, crossover, and parent sefection procedures custom
made for a specific system.
6. The parameters required for the above three procedures m u t be tested (i.e.,
codigured) to the system using input data that is M a r to that expected in practice.
7. The population size (i.e., number of chromosomes in each generation) and the number
of generations req, are two important parameters. They have a profomd effect on
the probability of finding a optinial solution in a simuIati011,
8. The parameter used in GAs are opfimized to a system and its input data for the
purpose of decreasing the Gp value. These parameters also have a profomd effect on
the confidence associated with the results produced by a GA at the and of its
execution.
Reco~nmendations for future work using GAHOS are summarized below:
1. GAHOS-1 should be redesigned to incorporate both a the-of-use electricity rate
structure and the previously unused peak-demand rate structure. The pumping system
should also be enhanced by using multiple pumps (using pumps in series and parailel).
This recommended version was entitied GAHOS-3.
2. GAHOS-3 can be further enhanced by using a ne~rork solver to evaiuate how the
chromosomes meet the hydraulIc constraints of the water distribution network. The
installation of the network solver was entitled "GAHOS-4 Blueprints".
REFERENCES
Back T., Evolutronary Algorithm in Tleory and Practice. New York, NYi Mord
University Press, 1996-
Beckwith, SI., and K.P. Wong, A Genetic Algorithm Approach for EZechic Plcmp
Schedulng in Water Supply Systems. IEEE International Conference on Evolutionary
Computation, 1995.
Chao, Junn-Ling, Cm w-Peak Pumping Cut UtiZity Power Costs?, J o d of the
AWWA, pp. 259-263, May 1979.
Chase, D.V., and L.E. Onnsbee, Comrpuer-Generated Pumping Schedules for Satimng
Operational Ob#ecrn>s, Journal of the AWWA, pp. 54-61, July 1993.
Clhgenpeel, WH., Oplimizing pump operating costs, Journal of the A W A , pp. 502-
509, October 1983.
Davis, L., H d o o k of Genetic Algorithms. New York, N'Y: Van Nostrand Reinhold,
1991.
Frey, J.P., A.R Simpson, G.C. Dandy, LJ. Murphy, and T.W. Farriil, Genetic Algorithm
Pipe Network Optirnikatrion: The next Generation in Distribution System Analysis. Public
Works, Vol. 127, No. 7, june 1996.
H a M , D., GA. Wdters, and D. Quazar, Smctured Messy Genetic Algorithm Approach
for the Optimal Improvement of Wuter Distribution Systemr. IEE conference Publication
No. 4 14, genetic Algorithms in Engineering S ystems, 1995.
Hirrel, T.D., System Cumes and Pump Selection. Journal of the A W A , pp. 67-73, July
1989,
Holland, H- J., Achptatztion in Namal und ArfÏfciaZ System. Ana Arboc The
University of Michigan Press, 1975.
Lackowitz., G.W., and P.J. Peîretti, Improving energy eflciency througir compter
modeling. l o d of AWWA, pp. 5 10-5 15, October 1983.
Miles, PX., and CL Moore, Genetic Based Leaming of a C M Engineering Proalem.
IEE Conference Publication No. 414, Genetic Algorithms in Engineering Systems, 1995.
Michalewicz, Zbigniew. Genetic Algorithm + Data Structzîres = Evolution Programii.
New York, NY: Springer-VerIag, 1992.
Omisbee, L.E., and TM. Walski, Identiirzg Efj ient Pump Combinatiom, Journal of
the AWWA, pp. 30-34, January 1989.
Syswerda, Gilbert Unifonn crossover in genetic algorithms. In J. David SchaBer (ed.),
Proceedings of the Third Internafirnafional Conference on Genetic Algorithm. Sm Mateo,
Calif.: Morgen Ka* Publishers, 1989.
Walski, T.M., Tips for S&ng en erg^ in Pumping Operutiom. Journal of the AWWA,
pp. 49-53, Juiy 1993.
Walsh, T.M., and LE. Onnsbee, Developing System Head Curves for Wuter DistribWion
Pumping. Journal of the AWWA, pp. 63-66, Juiy 1989.
Walski, TM-, E.D, Rill, J- Gessler, LC. Goulter, ItM
Liebman, L. Mays, DR. Morgan, and L. Onnsbee,
Jeppson, K. Lansey, H
Batrle of rhe Network
Li, J-C-
Models-
Journal of Water Resource Planning and Management, ASCE, pp. 19 L2O3,l987.
White, LA., M-H. Agee, and KE. Case, Principrls of Engineering Economic Anabsis-
Third edition, John Wiley and Sons, New York, 1989.
Wong, K.P., and Y.W. Wong, Genetic And GenetidSimuIated-Annealing Apprwches to
Economic Diquich. IEE Conference Publication No. 141, pp.507-5 13,1994.
Appendix 1 - E f f i of SCR on Daily Ekfricity Cost
In order to understand the effect the SCR has on the operatiod cost of the
hydraulic system, an expriment was undertaken to provide data that wodd correlate the
operational cost vs. SCR. Since varyhg the SCR does not have an effit on any wst
parameters (Le. maintenance, deprecation, discount rate etc.) except the electricity cost,
It was therefore numeridy efficient to simpLy examuie the effect the SCR has on the
daily eIectricity costs.
The table below is a s-es one such expriment. The experiment used the
above shown hydraulic system and GA panuneters that were used as input data for
GAHOS-1A. The electricity cost data and water demand rates were provided by the
input file 15-bittxt show11 in Appendix 14.
Hydraalic System Parameters:
Pump: flow = 0.191 [m3/s], head = 60.3 [ml, efficiency = 78%
Storage tank: storage capaciq = 12,000 cm3]
GA parameters:
Number of generations: 300
Population: 100
Tirne step: 15 min.
Probability of mutation: 0.09 or 9 % / Population / Generation
Switches per chromosome: 2
Table Al-1 : Starting storage volume with corresponding Daily electricity wst fcr a 12,000 m3 tank.
SIC ratio [%]
O
Shrting Storage WI
O
Daiïy Electricity Cost [$/day ]
60.5
AnalyPng the data available in Table Al-1 one can conclude that an optimal SCR
range exists (between 5% and 68 %). By repeating the experiment on severai storage
tank sizes the construction of Table A102 was possible. The optimal SCR ranges for the
100,2000, 4000 and 8000 m3 storage tanks are shown in Table Al-3, Table Al* Table
Al-5 and Table A l 4 respectively- The experiments on these siorage tanks used the
same input data that was documented at the start of this appendDr.
Table Al-2: Optimal SCR range for several storage tank sizes
b
Maximum. Storage Capacity [mal 100
2000 4000 8000 12000
I
Optimal SCK range [%] 90 - 95 0.5 - 30 5 - 10 I O - 50 5 - 68
L
Table Al-3: Optimal SCR range for a 100 m3 Capacity Tank
Table A14: Optimal SCR range for a 2000 m3 Capacity Tank
SCR (5) O
SCR [?hl Daily Pumping Cost [S/day) O 78.3
Daily Pamping Cost [Sdayl 133-4
Table Al-5: Optimal SCR range for a 4000 m3 Capacity Tank
Table AM: Optimal SCR range for a 8000 m-' Capacity Tank
b
SCR [%] 1 Daily Pumping Cost [Uday] O 60.5
SCR [xi O
0.125
Daily Pumping Cost [Wday] 60-5 5s-S
0.25 1 58 .Y 1.25 58.8
Appendir 2 - Effbct of magnification exponent on Daily Electricity Cost
The foliowing data was gaîhered by nrnning GAHOS-IA under Merent
magnification exponents. This version of GAHOS is only allowed to optimlle the
schedule and SIC ratio. The input füe 15-bit-txt (shown in Appendix 14) was used in
combination with the hydrauiic system and GA parameters defined below.
The d y s i s done in this appendk is required when d i t i n g a GA.
Maeniflcation exponents and other GA parameters must be cdibrated in order to
optirnue the pedormance of the GA Calibrating these parameters is a simple exercise of
test the pedormance of the GA using different parameter values (Le. magnification
exponent of 2O,lS, 10 or 5 ?).
Hydraalic System Parameters:
Pump: flow = 0.19 1 [m3/s], head = 60.3 [ml, efficiency = 78%
Storage tank: storage capacity = 12,000 [m3]
GA parameters:
Number of generations: 600
Population: 1 O0
Time step: 15 min.
Probabiiity of scheduie mutation: 0.09 or 9 % / Population / Generation
Switches per chromosome: 2
Probability of S/C mutation: 9 % f Population / Generation
Magnification factor: 1000
Table A24 : A amparison of the best daily cost at different generation numbers and
using two ciiffirent magnincation exponents.
J
O
Magnification exponent P = 10
Generation number
MagDification exponent P=20
1
Best cost 151.03
Averagecost 1 Best cost 2400038 1 15 1.03
Average cost 24000.38
Appendix 3 - Generatimg an approximate equation for the capital cost of storage
reservoirs
The figure below shows the cost data points gathered fkom Muir, 1991. The &ta
was used in a linear regression procedure which resulted in the followîng equation
Cost [$] =305691 + 142.33 x Capacity [m3] . R~ =0.9819
Figure A3- 1 : Capital cost vs. reservoir capacity
The above equation was reduced to the form shown below
Cost [$] = 300000 + 140 x Capacity lm3]
Table A N : Cost data fkom Muir, 199 1
Resewoir Capacity [cubic meters] w
Total Cost [SI 500 340000
Appende 4 - Effeft of the mutation esponents and mutation parameters on the
average Gp vdue and its respective standard deviation
Table below A44 through A4-3 were generated by shown hydraulic system and
GA parameters thit were used as input data for GAHOS-1B. The electricity cost data
and water demand tates were provided by the input file 15-bittxt shown in Appendix 14.
Hydriaiie System Parameters:
Pump: flow = 0.19 1 [m3/s], head = 60.3 [ml, efficiency = 78%
Storage tank: storage capacity = 12,000 [m3]
GA parameters:
Number of generations: 10,000 , the GA was stopped prior to this if the Gp was reached.
Population: 100
T h e step: 15 min.
Probability of mutation: an experimentai varaible, look at the tables
Switches per chromosome: 2
Note: Each ccrun" shown in the tables is a complete execution of the GA tiii completion.
Please don3 confuse a nui with a generation, each run can simulate up to 10,000
generations.
Table A4-1: Gp values for v ~ o w Magnification exponents (P)' mutation Parameters
A summary of the above table.
Runs \P 1 20 15 193 1
2 3 4 5 6 7
8 I
183 233 125 175 237 121 195 110
Standard Dcviation of Gp 733
Magnification Erponent (P) 2.5
10 1 70
9 f 150
Gp Average 1203
373 667 455 576 599 289 471 424 8 12 560 359 545 367
10 11 12 13 14 15 16 17
5 182
448 1630 1093 518 811 868 809 638 1505 3614 1100 948
2982
233 177 272 206 144 260 207
254 219 229 164 172 153 228 223
216 222 33 1 268 294 309 3 15
147 118 167 139 234 176 172
260 230 277 258 294 285 284 27 1
390 230 155 279 189 203 SI8 137
3 447
3 16 205 217 336 294
18 19
L
20 21 22
156 #
138 220 192 220 285 323 172
250 255 294 261 66
23 24 25
Average Gp S.D. of Gp -
2.5 1496
662 361 33 1 337 422 542 360
19t
156 162 230 195
- --
62
2 12 193 203 190 67
1034 I
10 19 920 1287 1 124 1359 1210
519
209 138 241 228 154
289 182 348 194
J 63
548 926 821 491 191
1603 169
813 1610 830 1203 733
325
228 150 173 258 120
I 1 94 243 169 250 222
Table A4-2: Gp values for various Mutation values when P=15
24 854 233 162 144 123 134 113 56 25 50 1 278 230 208 165 64 60 77
- Average Gp 872 336 195 156 129 93 83 80 S.D. of Gp 347 110 62 39 31 20 18 19
L
A summary of the above table.
L
Standard Deviation of Gp 347
Mutation Parameters 0.03
Gp Average 872
Table A4-3: Gp values for various Mutation values when P=10
A summary of the above table.
d
Mutation Parameters 0.09 0.12 0.18 0.25
Runs \ Mutation 1 2 3 4 5 6 7 8 9 10 11 12 13 -
Gp Average 194 158 125 I I I
14 15 16 17 18
0.09 170 147 118 167 139 234
0.30 109 68 112 146 147 163 94 106 113 99 113
Standard Deviation of Gp 63 34 22 17
0.35 148 102 112 90 139 13 1 IO0 274 124 153 249
O.= 15 1
2
158 2% 104 186 100 4 13 238 182 182 471 184 120
0.12 202 140 190 155 117 126
'
176 172 169 254 219 229 L 15
151 172 153 228 223 194
0.18 103 200 120 130 129
147 130
147 190 165 168 181
0.25 132 104 91 86 113
123 199 245 141 142 116
120
108 145 115 115
19
140 I 128
135 214 175 97 123
243
135 1 96
L 10 1 LO 111 142 134 148
164 347 % 174 289 223
115 93 119 73 116 118 1 24
120 1 1 1 105 100 184 100 94
126 122 104 98
20 21 22 23 24
119 93 II7 130 106 105 115
IO6 134 125 Il 1 t 19 t 43
126
144 213 152 196 299 401 27 1
136 48
115
I 111 91 L 10 124
102 79 88 117 95 119 125
224 102
77
111 I
138
169 250 222 289 182
102
204 176 142 136 121
Average Gp 17 1 26
166 194
25 158 34 1 22
348
S.D. of Gp 125
63
Appendix 5 Tables concerning the mode1 vaüdation (third stage)
Table AS4 : Total System Cost for di possibIe combinations
Combination Tank I - Pump 1 Tank 1 - Pump 2
Elecîricity Cost [Sfday] 77-53 66.85
3;601;887 t
3,545,599 3,898,475 3 986,837
1
Tankl-Purn~3 .
I
Tank2-hmip2 Tank2-himp3 Tank2 - Pump 4 Tank 2 - Pump 5 Tank 3 - Pimip 1 Tank3-Pump2
Total System Cost [SI 3,582,489 3,673,742
Tankl-hunp4 Tank 1 - Pump 5 Tank 2 - P u m ~ I
t
~ a n k 3 - Pumi 5 Tank 4 - Pump 1 Tank 4 - Pump 2 Tank 4 - Pump 3 Tank 4 - Pump 4 Tank 4 - Pump 5 Tank 5 - Pump 1 Tank 5 - Pump 2
8 1 -44 73 -42 85-99 58.79 5 1 -45 60 -66 54.02 64-5 1 53 -68 5 1-64
~ a n k 5 - p i m i P 3 I
51.21
4,090,859 3,998,460 . 3,947,456 4,292,3 9 1 4,676,8 1 7 4.80 1 .O68
58-65 53 -68 5 1 -64 51.21 42.39 58.65 53 -68 5 1 -64
7,247,3 3 9
4,979,526 5,649,377 5,977,8 19 5,848,657 5,789,294 6,156,276 7,252,250 7.3 76.50 1
Tank5-himp4 Tank 5 - Pump 5
42.39 I
7,187,976 58.65 7,554,959
Table A.5-2: Cost properties for five Storage tanks of varying sizes
I I
1 Tank 2 1 4000 1 860000 I 6.9 1
Designation Tank I
, 1
1 Tank 5 1 18000 1 2820000 I 6.6 1
Stonge ste [mT 2000
Z
Tank 3 Tank 4
Table AS-3: Cost properties for five dinerent pumps
Principal Cost [S ] 580000
7000 12000
M & O Cost 1% ] 7-0
h
Designition
P U ~ P 1 Pump 2 Pump 3 Pump 4 P=P 5
1280000 1980000
6.8 1
6.7
PrincipaI Cost PI
1,116,090 1,023,706 1,178,509 1,23 1,594 1,193,829
M & O Cost rw 10 13 9 8 11
Flow [m3/sl 0-191 O- 180 0.203 0.23 1 0.196
Head tml 60.3 53 -9 62. t 55.3 68.2
Efficiency [XI 78 , 81 77 76 79
Appendix 6 - Average day water demand rates (AVRDAY 1)
Time Period (hr) 1 Water Demand [ms/s] 1 0.080
Appendix 7 - Description of various functioos useà in GAHOS
disisrate A float representing the discount rate of money. It is in fkactional forxn not in the form of a percentage. It is rbilized in the P-en-A equation.
innation A float represting the anaod rate of inflation. It is in fiactional fom not in the fom of a percentage. It is II-d in the Pmen-A equation.
length A float representing the length of the project in years. It is utilized in the P-nA equation,
ngen An integer represting the number of generatiom GAHOS must simulate. There is no restriction on the magnitude of ngen.
num-ofjumps An integer represnting the nurnber of pumps in the Înventory (Le. that couid possibley be selected. This number must be kept below 100 (see pumps).
numnum_of_t.nks~ff tanks An integer represnting the nimiber of tanks in the inventory (Le. that could possibley be selected This number must be kept below 100 (see tanks).
P_given_A A float represeting the present woah factor ai l the anoual cost over the lenght of a project. Their are three input valrables inflation, length and dis-rate.
price A 96 long anay of floats. It respresents the electricity cost DkW-hr] for a 24
hour period in 15 min. intervis. The data is collected in the openingfile sunroutine and it maniIy used in the
P-'PS A 100x5 may of floats. It is used to contain ai I pump parameters and cm easily be increased in size. It is initiaiy used in the openingfile subroutine. The nrst parameter is capital cost [$], second is O&M cost as a fraction of the capital cost and the third forth and nfth parameters are discharge [m3/s], head [ml and effeincy respectivly.
sue An integer representing the number of chromosome in a population. It is restricted to 100 chromosomes or Iess- This may be increased by redefïning the magnitude of the fixed arrays involved.
tanks A 100x3 array of fioats It is used to contaui ail r e s o ~ o u r parameters and can d y be increased in size. It is initidy used in the openinhfiie subrouthe. The first parameter is capital cost [a], second is O&M cost as a fiaction of the capital cost and the third parameter is capacity cm3].
Appendir 8 - GAaOSlB Computer Code
char inle[10]; Pglobaf variables*/ int ansr; int size; /*global variables*/ int ngen; /*global variablesff int time-minutes; int tirne-mm; float prob; int changes; float abs-best; float demand[9q Fglobal variables*/ float price[96];/*global variables*/ int orig-chromo [ 1 001 [9q; int testchromo [96J; float evaluate[100 1; float storageeremaining[97J; int list[lOO]; int new~chromo_iis [lOO] 1901; int order-of-evaluationp 001; float storageespecs[l 001 [2]; float new_storageC~cs[l 0oJC2]; float running-totaI[lOO 1; float gen-best[lOOO]; float gen-averageC1000J;
void opening-file(void); /*hction prototype*/ void outputtfile(void); void screen-datdvoid); /*function prototype*/ void title(void); /*hction prototype*/ void nin.time(void); void rand-list(void); void printtlist(void); void crossover(int a); void show~crossover~title(void); void show~crossover(void);
void showqair(void); void showvoidshow_mutationo;~utation(void); void show~evaIuafion(void); void show-done(voiâ); void show_genemtion((int a); void rouietteewheei(void); void mutation(fl0at x); void qsort(fbat vfl,.int left, int right);
void swap(fioat vuy int i, int j); void swap2(int vu, int i int j);
void expand~rice(void); void expand.demand{void); float niiaI.aorage(mt i); int u-rand(int a); float unit(void); int random(ïnt nu); void eval(void); void children(void); float storage-max; float storage-mut; float Q; float Hg7 fIoat n; float Po; // magnification exponent// fïoat gen-total; int b e H 9 ; float high=999;
cloclc-t start, end;
void main(void) /* main program*/
int i j,p,ans,some-number ; randomizeo; start = clocko; titleo; screen-data0 ; titleo; opening-file(); expand-O; expand_dernando; evalo;
for (i=O;j<=sïze-1 ;i+) ( gen.totd=gen-total+ evaiuate b] ;
gen-average[O J = gen-totaVsize; qsorf(evaluate,O,99); genJest[O]=evaluate [O];
for @=l ~p<--ilgen;pH){ show_generation(p); rand-listo; showjair(); if (p<ngen){
for (i=û;i<=sizee2;i=i+2) (
if (abs-bes~evaluate [O]) { abs-best=-evaluate [O]; somesome_number-7andomo;numbe1-random(size); for (i=O;ic=tirne-max- 1 ;i+) {
ong~chromo[some_number] [i]=origg~hromo[order~of~evaiuation[O] [il; 1 for (i=O;ic=S;i++) {
if -gen) € show-doneo; gotoxy(lO,l2); prinql'time elapsed(sec): "); nm-the(); evdo; qsort(evaiuate,O,99); gotoxy(l0,l O);
}
void titIe(void) {
clrscro; gotoxy( 1 591); pnxitf("GAHOS- 1 By: Tobias A. Bloch (With absolute-best fûnction)");
1
void output-fïle(void) {
int i j; FILE Icstream2; Stream2 = fopen("wbest,txt"w); for (i=O;i<=tirne-max- 1 ; it+)I
@rintf(streamî."Ùi%d %f %f ',i,price[i],demandCiI); 1 .
@rintf(streamî,"\nThe best solution\nWt);
for (i=û;i<qgen-1 ;icc)( fprintf(stream2, l'\n%d\t%f" &en - best [i 1);
1
void opening-file(void)
int i j,temp-a,temp-b; FILE * s t m m L ; Stream1 = f~pen(ine,~~rl'); gotoxy(l095); printf("0pening me: %sl1,ifile); gotoxy(lû,6); /*start location of iine beio w */ printf("Reading me: ");
for (i=O;i<23;i++) { fscanf(stream1, "%fW1,&price[i]); gotoxy(24,Q; Ppretend info*/ printf("%dW ,dem+i]);
}
for (j=û;j<=size-l;j+t){ fscanf(strem 1, "\II"); gotoxy(23 96); for (i=O;i<=time-max-1 ;i*) { temp-'=ow(-l,i*j); orig-.chromo b] Ci]=-max(temp_;stemp_b); //random(2); storage-specsb] [l]=pow((j/(size-
1 ))~O.2);//random(storageernax+l)/storage~m~;
if (tirne-minutee 1 5 ) {
gotoxy(~0,6); prhtf()1chromosomes initiation: done g0t0xy(10,10); prîntf(IIgeneration #: "); goto~y(3 5,l O); pnntg.status: II);
void men-data(void)
gotoxy(lY4); printf("Enter input file name: "); gets(ifi1e); gotoxyC1 Y 5); printfcEnter the time steps (minutes): "); //time_minutes=15; sd("%d",&time - minutes); gotoxy( 1 56); print5rEnter the population size: "); //size=lOO; scanf('%dt ' ,&size); gotoxy(l97); printfctEnter the number of genratiom: "); scanf~O/dt ,ange@; gotolsrC1 Y 8); printf("Enter the probability of mutation: "); //prob=O -09; scanf("%f',&prob); gotoxyu 39); printf(((Enter the mutation per chromosome: "); //changes=2; ~cad("%d"~&changes); gotov(l,l O); printfiEnter the storage capacity: "); //storageemax=12000; scanf("%f ly&storageemax); gotoxy(l, 1 1);
prÏntf("Euter the storage mutation: "); //storageemuHl0.O9; scanqlr%f ',&storageernut); gotoxy( 1912); printf("Enter the pump flow: "); //Q=û.191; sd("%f',&q); gotov(lYl3); printfrEnter the pump head: "); //H=6O -3 ; suiI@"%f",&H); gotoxy( 1 Y 14); printfrEnter the pump efficency: "); //n=O-78; scanf(R%f ',&xl); gotoxy(l,l5); printfrEnter the magnincation Exponent: "); scanf("%f ',&Po); timeem~~60//timeminutes)*24; 1
void run-time(void)
end = cIock0; printf("%. I f ', (end - start) / CLK-TCK);
1
void rand-Iist(void)
int i, 10.1y10ca_2, ternp-of-Ioca-1;
for (i=O;i<=size-l;i*) ( list [il?;
1
for (i= 1 ;i<*size;i++) (
void crossover(int a)
int temp; float temp2; int pos,i; float average-ratio; po-dorn(time-max-2);
//the everaging of the ratios average-ratio=(storage-specs Pst[a]] [l ] o c a 11 J [l])/2; st0rage~specs~st[aJ1El ]=average-ratio; storage-specs @st[a+L]] [l ]=average-ratio;
for (i=pos;i<=time-max- l ;i+t)( temp=ong-chomo@st[a]~; o~gchromo~st[a]]~~=0na,chromo~st[a+1] ] [il; orig - chromo Est[a+l]] [i]=temp;
1 1
void show-done(void)
gotoxy(45,10); printf(" done
1
void showjair(void) {
gotoxy(45,lO); printf("pairing ");
1
void show~m~tation(void) C
gotoxy(45,l O); printf("mutating ") ;
1
void s ho wvoidshow_evaluationoevaluation(void)
void show~crossover(void) C
gotoxy(45, 10); printfc'crossover ");
l
void show~eneration(int a) C
gotoxy(25,10); printfii%d ",a);
}
void expandjrice(void) {
int i j,c; c=24; if (timeemax>24))(
for (i-time - max- 1 ;i>cO;i=i-(60/timeeminutes)) ( Fc-l; for(j=Oa <(6O/time-minutes);*j) {
prke [i-j]=price [cl; }
1 1
1 void expand_demand(void) C
int i j,c; c=24;
if (timeemax>24))( for (i=tïme-max- 1 ;i>=û;i=i-(60/timeeminutes)) {
float finai-storage(iit i)
int j; storageeremaining[O J=fiorageespecs[i] [l ] +s; for ü=l à<=time-max j*) (
storagee~rnaining[i]=storageeremaining~-I] + (Q*orig - chmmo[i ] lj- 1 ] - demand [i- 1])*(3 600/(60/timeemlnutes));
void xjrint(void) {
int j; for (j=û;j<--tirne - max-la*) {
priotfi%d" ,test-chromo Dl); 1
void eval(void)
int i j; float x; for (i=û;i<=size- 1 ;i*) (
~rder_of~evduation[i]=i; evaiuate [il=(); rc=O; storage rernaining[~=storageespecs[i] [1 ] *fiorage-max; x=orig>hrorno [il [O] *price[O]* (H*Q* 9- 8fn)f(60ltimeeminutes);
for (i=l j<=tirne-max-;j++)C storage-remaining ü]=storage-remaining fi-+
(Q*orig-chromo[i] Ci-i ] - demando- 1 J) *60f tirne-minutes;
void print-iist(void) C int i;
for (i=l ;i<=size;i*) ( printf("\n%d %dm ,i,list[i]); 1
1 float unit(void)
float i; float x;
void mutation(f1oat x) {
int ÿ~umberberchrorno,o,;sbscstemps~umber~~omge - mut; numberberchrorno=(size~)/ 1 ; numberber~orageernu~(sizr:*storageemut)/l ;
for (i=û;i~=numberumchromo;itt)(
for (j=l $=changes j*){ a=random(sk);
temp=ong-chromo[a] p]; orig-chromo [a] [b]=onggchromo [a] Cc]; orig-chromo(a] [c]=temp;
1 1 for (i=O;i<=number-chomo;i*) (
a=random(size);
1 for (i=O;ic=number-storage-mut $*) {
c=random(size) ; storage-specs [c ] [ l ]=random(storage-max+ 1)Istorage-max;
1 1
void rouletteewheel(void) {
float random-number;
for (i=O;iC=size-l;i*) { running-total [il+; //initate
for (i=l;ic=size-1 ;i*) { mg-totd[ i ]dggtota l [ i - i3 + iOOO/pw(evaiuate[i],Po);
for (i=O;ic=size- 1 ;i*) ( counter-nside wMe=size- 1 ; random-numb; = unitO*cunaUlggtotai[size-11;
if (random-numbeflrunning-total [O]) { counter~insidecounter_inside_while=O;~hile=û;
}
for {i=û;i<=size-i ;i*) { for (j=O;i<=time max-L ri*) (
~ r i ~ c h r ~ r n o ci] ~]=ne~~chrorno-~ist[i] 1
void qsort(float vojnt left, Ïnt right) {
int i, last,lasîî;
return ; swap(v,left,(left + right)/2); swap2(orda_of-evaIuation,le~(lefi + right)/2); last=le@ last2=1ee for(i=left+ i ;i<=right;itt)(
if (v[i]< v[le£t]) { swap(v, +tlast,i); swap2(order-of-evaluation, *last2,i);
1 1 swap(v, lefi, last); swap2(order~of~evaiuation, leRlast2); qsort(v, left, last-1); qsort(v, last+l , right);
1
void swap(float vu, int i, int j)
float temp; temp = v[i]; vm = vb]; v[i] = temp;
1
void swap2(int va, int i, int j) {
int temp; temp = v[i]; VM = vol; vD] = temp;
1
void children(v0id)
int i j;
f/&ïs is new for (i=O;i<=9;i+) (
for (j=ûj<=time-max-1 ri*) {
storage~specs[order~of~evaluation[i+90]] 11 ]=storage-specs [order-of-evddon[ oJ1 Cil;
1 1
//new ends here
Appendix 9 - GAHOS-2 Cornputer Code
char inleCl O]; /*global variables*/ int ans; int some number; int size; -/*global variables*/ int ngen; PgIobiil variables*/ int tirne-minutes; int tirne-max; float prob; int changes; int numumof'umps; float Po; int n~of-tiuiks; float leneth; float dis rate; aoat sition; float Pdven-A; float absai-best; float demand[96];/*global variablesL/ £bat pnce[9q;/*globaI variables*/ int best-origgchromo[9q; int best-second-chrom0[3]; int orig~chromo[100][96]; int second~chromo[lOO] Pl; int test-chromo [99]; float evaluate[lOO]; float storage_remaining[97]; int Iist[lOO]; int new~chromo~iist[lOO~ [9q; int second~chromo~List[100] [3] ; int order-of- evaluation[lOO]; //float storage-specs 11 O0 ] [2] ; float ne~~storage_spcs[lOO] 121; float running-totai[lOO]; fioat tanks[100][3];
float pumps[100][!5J;
void opening-file(void); I*function prototype*/ void ouîpututfile(void); void screen data(void); /*fimction prototype*/ void title(vsd); /*hction prototypcf/ void nm-time(void); void rand-fist(void); void p~t.list(void); void crossover(int a); void show_crossoverertitle(void); void show-~r~ssover(void); void show-pair(void); void showvoidshow_mutationo;mutation(void); void show-evaluafion(void); void show-done(void); void show_generation(int a); void rouletteettewheel(void); void muîation(ff oat x); void qsort(float vO,int le& int right); void qsort2(fioat v0,int left, int right); void swap(float vu, int i, int j); void swap2(int vu, int i, int j); void expandjrice(v0id); void expand-demand(v0id); //float final-storage(int i); int u-rand(int a); float unit(void); int random(int num); void eval(void); void chüdren(void); int x-addition(v0id); //float x-evai(void); //vo id x-test(void); void x-initiai(void); void xgrint(void); float storage-max; float storage-mut; fioat Q; float H; float n; int best=99; float hi&=-999;
dock-t sbrt, end;
void main(void) /* main program*!
int i j,pJunk; randomizeo; absa@est=lûûûOOOO; start = clocko; titleo; screenndata(); titleo; opehg-fileo; f/printfC"\n probabilty O/of',prob); // getch0; expand-ce(); //printf("\n probabiity %f',prob); // getch0; expand-demando; //printf("\n probabilty %r',prob); // @Cho;
for (p=û;p<=ngen;p*) ( show_gneration(p); randd.stO; showqairo; if (pcngen) (
for (i=O;i<=size-2;i=i+2) { crossover(i); show~crossover~;
1
some_number-?andom(size); for (i=O;i<=time-max- l ;i*) (
ong-chromo [some-number] (iI=bestbestori~chrorno [il; 1 for (i=û;i<=2;ite) (
s~cond~chromo[some~nmber] [q=best-second-chmmoF]; 1
//chilcireno; roulette-wheef O; mutation@rob); evalo; //qsort(evaiuatey0,99);
1 qsort(evaluate,O,size-1); gotoxy(1 O, 14); printf("Cuaent best: %.Of %.Of ",evaluate[O],absalsalkst); gotoxy(l0,15); printf("0/od %ci
%d'l,second-chromo[order-of evaluation[O]] [O],second - chromo[order~of~evaiuation[O]] [il ,second~c~orno[order~o~~vd~ittion[0]] [2]);
if (absalifo(best>evaiuate[O]) ( absaiJest=evaiuate[O]; for (i=O;ic-time - mma 1 ;i*) {
best~~rig~chrorno[i]=ong~chromo [order-of-evaiuation[O]] [i 1; 1 for (i=û;ic=2;i++) {
j-dom(size); for (i=û;i~=timeemax- 1 ;ict)(
ong-chromo Cid] [i]=best-orig-chromo [il ; 1 for (i=O;i<=2;i+) (
second~chromo~unk] M=best-~econd~chrorno [il; 1
//printf("Cwrent best : %. 1 f " ,evaluate[O]);
/*gotoxy(2,18); for (i=û;i<=num ofqumps- 1;itt) {
pintf("%f %f %f %f %fWpumps Cil [OI9pumps[il El I,pumps[il PI,pumps[il Pl,pumps[iI il411 ;
> */
//printf("why\n"); //printf(" %fw ,tanks[O] [O]); //printf(" %W ,tanks [O] Cl]);
//printfi %f %fW,ta.ks[O] [O],tanks [O] [1 J); for (i=O;ic=11um~of~tanks- 1 ;i*) {
printfr here is ittl); for (i=û;i<=2;i*) {
printf("\n0/od~',be~second~chromo [i 1); 1
/*goloxy(l O, 19); printfr WouId you like to nin X-test? (0-yes, 1 -no): "); scanf('IY& ,&ans); */ /*gotoxy(i 0,2020); for (i=l ; id OO;i*) (
printf("\n%f ',unit()); 1 */ /* w==o) l
x-test(); 1 */ /*~~initia.iO; gotoxy(10,24); for (i=û;i<=23;i+t) (
printf("%d1' ,test-chromo [il); 1
void title(void)
clrscro; gotoxy(l5,1); printf("0NE PUMP ONE RESERVOIR: VERSION 1.0");
void output.fïle(void)
int iJ; FILE *stream2; Stream2 = fopen("'outbct", "w"); for (i4;i~=timeemax-l ;i++)(
fP~tf (s treani2 ,"h %f %f',iyp~ce[i],demand[iJ);
voici opening_nle(void)
int U,a,b; FILE * m l ; strearn 1 = fopen(inle,"r"); gotovu 075); printf("0pening nle: %s",inle); gotoxy(10,6); /*start location of line below */ printfC'Reading file: "); for (i=O;i<=23;i+k) (
fscanf(stream 1 y" %f\n",&price[i]); gotoxy(24,6); /*pretend info*/ printf+%d" ".demam&i]);
1 for (i=O;i<=23;i++) {
fscaaf(stream1 ,"%An" ,&demand[i]) ; gotoxy(24,6); printfr%fl ,price[i]) ;
1
for (j=O;i<=sk-1 ;i*) ( fd(stream1,"W); gotov(23 96); for (i=O;i<4meemax-1 ;i*) { // fsd(strearn1 ,"Ydl,&ong- chromo^); orig-chromo Ci] [i]=random(2); //storage-specsu] [l]=random(storageecmax+l)~st~rageemax;
if (tirne-minute9 15) ( printf~'Yd",o~g-ckomo 3 Cg);
l 1 second-chromo Dl [O]=random(100 1); f/a=UILitO*num_ofO~;
second-cbromo~] [1]=random(numumoff tanks); second~cbromo [i3 [2 ]-random(num_ofqumps);
1 gotoxy(1 O,@; printf('lchromosornes initiation: done gotoxyC1 O, 10); printf("generation #: "); gotoxy(3 5,1 O); printfc'status: ");
gotoxy(2918); for (i=U;i<=25;it+) (
f/printf('l%d %d % d i . ' ,second-chromo [il [O J,secondd~hr~mo[i J [ 1 J ,second~chromo[i] 12 1);
1
void screen.data(void)
gotoxy(l74); printfYEnter input file name: "); gets(5le); gotoxy(l Y 5); printf("Enîer the time steps (minutes): "); ~ d ( ' ~ % d " ~ ~ e ~ m i n u t e s ) ; gotoxyu 20); p ~ t f r k t e r the popdation s h : '3; SCaflf("%d"7&size); gotov(l77); printfc'Enter the number of genrations: "); scanf((l%dN,&ngen); gotoxy(l,8); p~tf(((Enter the probability of mutation: "); scanf("%f ',&prob); gotoxy( 199); printfrEnter the mutation per chromosome: "); ~canf("%d'~~&changes); //gotoxy(l, 1 O); //printfCIEnter the çtorage capacity: "); //scanfiit %f ',&storage-max); gotoxy(l,ll); printf("Enter the storage mutation: "); scd("%f ',&storage-mut); gotoxy(l7 12); printf("Enter the number of pumps: "); scanfC9%d" y&num_ofsumps); gotovC1J3); printf('IEnter the number of tanks: "); scad("%d",&numumofftanks); goto.v(l7 14); printf("Enter the inflation rate: "); ~canf(~%%f',&inflation); gotoxy( 1 Y 15); printfi9Enter the discount rate: "); scanf("%f ',&dis-rate); gotoxy( 1 7 16); printfiEnter the similation length: "); scanf("%f ',&length); gotoxy(1 Y 17); prinû("Enter the Magnincation exponent: "); scaaf~%f9,&P0);
void x-Uiitiai(v0id) C
int i; for (+O$<--time-max-I ;i*)
teststchromo [il+; 1
}
int x-addition(v0id) t
int i; test~c~omo[timeemax-1]=teststchromo[timeemax-l]+l;//adds a one to the end of
the chromosome for (i=time - max-1 ;i>=l ;i=i-1)
if (test-chromo [i ]>=2) C
test.chromo[i]=û; test-cbromo[i-1]=teststchromo[i- 1 ]+l ; //getchO; //gotoxy(l O, 19); //xsriotO;
1 1 if (test-chromo [O], 1)
retum 1; else
retum O;
float best,current,add; int i; x-initial 0 ; hem-evdo; gotoxy(1 O, 18); printfi X-Test Best: "); while ((x-additionO)=O) (
currenL'X.eval0; gotoxy(l0,2 1); prhtf("cunent is below %f ",current); gotoxy(l0Z); x-O; if @est > current) {
best = current; //getchO; gotoxy(lo,19); xqrinto;
1 //for(i=O;i<=timeemax-1 ;i*) { // printf("%d" ,test-chromo[i]);
got02cy(26,18); printfr%$. 1 f ',best); I
) */
void run-time(void)
end = clocko; printf("%. lf ', (end - start) / CLK-TCK);
1
void rand-iist(void) C int i. loca-1,loca-2, temp-of-ka-1;
for (i=O;i<=size-l ;i*) ( lisî[i]=i;
for (i= 1 ;i<=t*size;i+t) ( loca-1 u-rand(size); 10ca~2=u~rand(size);
void crossover(int a) {
int temp; float temp2; ht pos,i; int average-tank, averageqimp;
int average-ratio;
//the everaging of the ratios average~ratio=(seconddchromo pst[aJ] [O]+secondcomo a 1 ] [0B/2; second-chromo p s t [a]] [O]=average-ratio; second~cbromo mst[a+ 111 [O]=average-ratio;
averageetanb(second~chromo mst[a] J [I ] + s e c o d c o O a 113 [ 1 ])D; second-chromo bst[a]3[1]=average-tank; second-chromo [iist [a+l]] [l]=average-tank;
a.erage~~mp=(second~c~omo~st[aJ] [2]+secondcomoi[a+l]] [2])/2; second-chromo pst [a]] [2]=averageqump; second~chromo m[a+l]] [2I=average~ump;
for (i=pos;i<=timeemax-1 ;i*) { temp=orig-chromo [iisqa] J [il; ong-chromo @st[a]] [i]=origgchromo [Iist[a+ 1 ]] D] ; ong-chromo P s t [a+ l]] [i]=temp;
void show-done(void) {
gotoxy(45,l O); prinwdone "1;
1
void show-pair(void) {
gotoxy(45,l O); printfclpairing ");
}
void showvoidshow_mutationomutation(void) {
gotoXy(45,l O); printf("mutating ");
1 void show-evaluation(void) 1
gotoxy(45,l O); printf(11evaluating ");
1 void show-crossover(void) {
gotolry(45,l O);
void show__generation(it a)
gotoxy(25,l O); printfC%d n,a);
l
void expandHe(void) C
int i j,c; ~ 2 4 ; if (the-max>24) {
for (i-tuneemax-1 ;i>=O;i=i-(60/timeeminutes)) { c=c-1; for(j=O~~(60ftimeeminutes);~j) (
price[i-j]=price[d; l
1 1
1 void expand_demand(void)
Uit i&c; c=24;
if (time-max>24) { for (i=time-ma-1 ;i>+;i=i-(60/timeeminutes)) {
//printf("h probabilty %f Yod" ,prob,c); Ugetcho; CF--1; fo~=O;i<(60/timeeminutes);++j) {
demand[i-j]=demandM; l
1 1
1
I*float final~torage(int i) {
int j; storape-remaining[0]=storageespecs Ci] [Il %orage-max; for (i=l j<=time-maxgct)(
storage remainllig~]=storage-remainingb-1]+ (Q*orig-chromo[i][j-1] - demandu- 11) '(3 600/(60/timeeminutes));
if (storage-remaining[i] > storage - max) { storage-remainingb] = storage-max;
1
void xqrint(void)
int j; for (i=Oa<=time - max- 1 $+)
printf(" % d ,teststchromo Dl);
l
void eval(void)
int ij; float x; for (i=û;i<=size-1 ;i*) (
order-of-evdiruaon[i]=i; evaiuate[i 1 4 ; d;
storagee~maining[O]=second~c~omo [i ] [O J * î d c s [second-chromo[iJ [l]] [2]/1 ûûû 9
-ring chromo[i][O]*price[O] *@umps[second~chromoiJ [2 J] [3] *pumps[second-c hromo ci] [2]] 127
* 9.8/(pumps [second-chromo [il [2 J] [4]))/(6O/tïme-minutes);
for (j=l ;jc=time-max~*){ storape-rernaining~]=storage-remaining[i-] +
@umps[sewnd-chromo [il [2]] 121 *orig-chromo [Ï J h 4 J - demandu- 11) *60*timeeminutes;
orig chromo [il Cj] *pnce[i J * (pumps[second~chromo [il [2 J] [3] *pumps [second~chromo[i J [2 11~21
if (storage-remaining > tanks [second-chromo[i ] [l ]] [2 1) ( storage-remaining lj J = tanks[secondecbmmo[i] [l]] [2 J ;
}
if (0-*-mm) && (storage-remainingm < second-chromo [il [O J *tanks [secondIchromo[i] [l] 112 ]/1000)) (
x = x + 2*(secod-chromoCi] [O] *tanks[second~chromo[i] 1 O 0 - storage-remaining[i]);
1
evduate[i]=tanks[second~chromo [il [1] J [O J + pumps[second~chromo [il [2 J J [O]
+ P_given_A*(36S4x + îanks[second~~hmmo [il [Ill [O]Ianks[second~cbro~~o [il [I ]] [l J
+ pumps[second~chromo [il [2]] [O ] %umps [secondcoo [ 2 J I ) ;
/*Boat x-eval(void) {
int j; float x; for (j=O;j<=time-max;j++)) {
storape-remaining [O]=storage-specs [O] 0 changùig ~-fest.cbromo [O] *price [O] *(H4Q49 - 8 f n ) / ( 6 0 - minutes);
for (i=l dc=time-maxj++) { storage-remaining[j]=st~rage~remaining~-1 ] + (Q*test-chromolj-
11 - demandu- i])*60*timeeminutes;
void print-list(void) {
for (i=l;i<=size;$+) ( prllitf("\n%d %d",i,iistb]); )
1 float unit(void)
float i; float x;
void mutation(float x)
int iJ,number-chromoYa, b,c,~e,~gytempy~umber-fiorage-mut; number~chromo=(size*x)/1; number-storage-mut=(size* storage-mut):l; //printf("\n size %du .size); //printf("\n probabilty %f 'J); //printf("\n probabilty %f ',prob); //printf("\n mutation %d",number-chromo);
for (i=O;i<=flumber-chr0mo;ift) {
for (j=l j<=changes;i*) { a=random(size);
b = dom(timeenax); //(heemax); c-landom(time-nax) );l/(time-ma), /*printfCt\nbefore number Yd Yd %d %d %d
\n" ,a,b,c,orig~chromo[a] plf ~rig~chrorno [a] [c 1); for (W;tc=time-max-1 ;ttt)(
printf~?40d",origgchromo [axt]) ; 1 */ temp=origgcfuomo[a] p l ; orig-chromo [a] B]=orig-chromo [a] [c 1; orig-chromo [a] [c]=temp; /*pri.ntqw\nafter number Yd location1 %ci location2 %d vl Yd v2
%d \n" ,a,b,c,orîg~~hn>mo[a] [b ]yorïgg~hromo[a] [cl); for (t=O;t<=time-max- 1 ;t*) {
printf(t'O/od",orig_chromo [a] [t]); ) */ /* */
1 1 for (i=O;i<=number-chromo;i++)(
a=random(size); b-=dom(time-ma); //(the-ma);
if (origchrorno[a] b]=1) ong-chromo[a]b ]=O;
else orig-chromo [a] [b 14;
for (i=O;i<=number-,orage-mut$+) { c=random(size) ; second-chromo [cl [O]=random(lOO 1);
1
for (i=0~~?iumber-storagerarnut;i*) ( d=random(size) ; //e==dom(numumofumtanks+ 1 ); second-chromo [dl [i]=random(num_~f~tanks);
1 for (i=O;icaimiber-aorage-mut;i*) {
~ d o m ( s i z e ) ; //g=randorn(num_ofjumpst 1); second-chromo [f] [2]=random(num_ofsumps);
1
void roulettevoidroulette_wheelo~heel(void)
int ij,k,counterernside - whiie;
float rand~rn~numbe~
for (i=O;i<=size-1 ;i*) ( running - total[i]=O; /hitate
1
for (i=l ;i<=size-1 ;i+t) ( nuininggtotaI[~=]Nnninggtotal~-l] + 1 OOOOOOfpow(evaiuate[i],Po);
1
for (i=O;i<=size- 1 ;i*) ( counter~inside~whiIe=size-1; random-number = unitQ*Nnning-total[size-11;
for (j=û;j<--time-max- 1 ;i*) ( new-chromo-Est ~]~]=~~g~chrorno[counter - inside-whileJm;
l for ÿ=û $=2 j++)(
for (i=O;i<=sh- 1 ;i++) ( for (j=û jc=time-max-l $+) (
o~chromo[i]~~-newongchromoCilCil-new_chromo_iistCiLIi1;~htomohtolist[i] fi]; 1 for (j=0$=2 ;j+t)(
second-chromo ~[i]=se~ond~chromo~list[i] 1; 1 //storageespecs~] [l ]=newpestorageespecs~1] ;
void qsort(float vu,& left, int right)
int i, last,last2;
1 swap(v, le& Iast); swap2(ordererof evaiuation, Ieft,lastî); qsoryir, Ieft, Iast-1); qsort(v, 1-1 , right) ;
1
void swap(float vu, int i, int j)
float temp; temp = vb] ; v[il = vb]; vb] = temp;
l void qsort2(float v0,int le& int right)
int i, Iast,last2;
if (Ieft >+ght) retum;
swap(v,left,(lefk + right)/2); swap2(order~of~evduation,left,(Ieft + nght)/2); IasHeft; last2=left; for(i=Ieft+ i ;i<=right;itt)(
if @[il< v[left])( swap(v, -mi); swap2(order_of-evduation, *last2,i);
1 1 swap(v, le& Iast); swap2(order_of_evaluation, le&last2); qsoa(v, le& last-1); qsort(v, last+l , nght);
1
void swap2(int vu, int i, int j)
int temp; temp = v[i]; v[iJ = vD];
void children(void) (
int i j;
//this is new for (i=û;M;i*) {
for (j=O J<=time-max-l a*) {
//every thing below is the way it use to be /*for (i=l;i<+;itt)C
for Cji)~<=time-max-1 ;jte)(
orig~chromo[order~of~evaIuation[i+67 ] J [j] J Dl;
1 1 for (i=O;i<=g;i+) {
for (j=O;j<=thne-max-l $+) {
1 1 for (i=O;ic=l2;i*) (
for (j=O;j<=timeemax-1 ;jt+)(
Appendix 10 - The Roulette Wheel Subrouthe
The purpose of this appendix is to provide the reader with a comprehensive
review of the development of the roulette wheel subroutine as used in GAHOS-1 and
GAHOS-2. This appendix is divided into three parts. 1) A discussion of how the
Roulette WheeI Methd (RWM) is used in systems that require a mruamization of their
measured characteristics (the definition of rneasufed characteristics wiIl foilow in the
next paragraph). An example of a xmwhîzation problem would one where the measured
characteristic is Iife expectancy or net profit. 2) A discussion of the RWM when used in
systems that require a mbïmization of their measured c h t e r i s t i c (like total pmject
cost as dehed in GAHOS-2). 3) A review of magnincation methods (within the roulette
wheel subroutine) used in GAHOS-1 and GAHOS-2.
In section 3.6, the roulette wheel method of selecting children chromosomes for
the roll of parent chromosomes was introduced. The main rival of the roulette wheel
method is the chromosome ranking method. The ranking method's decision structure is
based upon the relevant ranking of a particular chromosome with respect to the rest of the
population. The process is quite simple, al i the chromosomes in a population are
evaluated and ranked according to their fitness value. Afterwards duplicates of the top
rankuig chromosomes are made (Le., stored in the computer's memory) and in the
process erase the lower ranking chromosomes. The number of duplicates made is
specified by the user. For example, in a population of 100 chromosomes, one possible
dupIication mandate may be:
30 duplicates of la mnk
20 duplicates of 20d rank
15 duplicates of 3d rank
12 duplicates of 4& rank
10 duplicates of 5" rank
7 duplicates of 6'h rank
This is a total of 94 duplicates plus the original 6 chromosomes produces a total of 100
chromosomes. The ranking method neglects (by dennition) to take into account the
degree of ciifference between the values being ranked. The ody thing that is important is
that there is a différence.
In the above mentioned example, ali chromosomes ranked 7n or Lower were
discarded and thus were never able to pass on theu genes. This wouid be tnie even if the
ciifference behNeen the 1" ranked chromosome and the 7m ranked chromosome was oniy
a fiaction of a percent. There is thus the possibility that poteatially useful chromosomes
are discarded, simp1y because of their ranking and not as a result of their a d fitness
value.
It is the above mentioned drawback that made the tanking method undesirable to
use in GAHOS. The roulette wheel method was chosen for the roll of parent selection
since this method is completely based on the fitness values relative to the rest of the
population. This property of the roulette wheel method makes it an ideal candidate for
the parent selection purposes.
AlO.1 MaximiPng Measured Charneteristic
The term '%tnessY' is used to descn'be the abiiity of a chromosome to cope with its
environment The hi@ the h e s s value, the superior the chromosome (Le., solution)
and vise versa In nature the fitness of a chromosome, whether it may be a lion or a
wonn is the product of multiple characteristics. One cm reasonability speculate that a
Iion' s fitness is composed of its
ability to hunt,
0 abiiity to defend its prïde fiom other fions,
a ability to fend off other predators (Le., hyenas),
0 ability to reproduce, and its
a abi1ity to wake up when laying in the path of an elephant.
One can see how diffTcult it is to assign a fitness value to a chromosome when the
number of interactions betweea the chromosome and its environment are so vast-
T y p i d y Genetic Algorithms avoid this complexity by dehing the fitness as
being related to only one measured characteristic. In GAHOS-1 thh measured
characteristic is daily electricity cost, while the measured characteristic in GAHOS-2 is
total project cost Other systems may define the measured characteristic as cost,
reliability, efficiency, profit, capacity, etc. M e n the characteristic is directiody related
to the fitness, than the problem is one of maximiPng this characteristic. The phrase
"directionally related" is used to describe a characteristic that is related in direction to the
fitness (both the fitness and characteristic belong to the same chromosome). A simple
way to identify a directionaliy related characteristic is to ask whether the fitness should
increase as the values of the characteristic increases. Propertïes such as r~liability,
efficiency, capacity, survïvability, M e expectaacy are directionaiiy related since they
move in the same direction as their fitness value.
As mentioned above, an increase in a directionally related characteristics wouid
cause the fitness value to increase &o. Some examples of this are shown below, with the
measwed characteristic king storage tank capacity:
Fitness = Capacity (dïrectionaliy related and directly proportionai)
Fitness = 0.7S.Capacity (dïrectionally related and daeetly proportional)
Fitness = ( ~ a ~ a c i t y ) ~ (directionaiiy celateci but not dircctly proporti'onal)
Whether to make the characteristic directly proportional or not is left to the discretion of
the application user, dthough some fonn of sensitivity analysis may aid this
investigation.
Lets investigate how the roulette whee1 method hct ions for a problem where the
measured characteristic is both directiondy related and directly pr~portional to the
fitness value (it might be usefid to the reader to review section 3.6.1 first).
Fitness = Characteristic (direcrionaiiy related and directly proportional)
We assume there are n chromosomes in the population, and assemble the following table
to be used for the rouiette wheel method. The roulette wheel method requires the
i=n
creation of a d o d y distributed random number between zero and Ce. Therefore i= 1
using the same technique that was used in Fig. 3.10, one cm create the table shown on
the top of the next page.
Characteristic Cl, C2 CLCCLCC... Cj .......... Cn
Thus the probability of the chromosome being chosen is:
Rob. (k) = "' i=I i=n
E& i=l
q + ~ , - - x E :. Prob. (k) = "' i = ~
bk Prob. (k) = - 1-rr
Suice ze is a constant for any given generation. It can therefore be said that the i=I
probability of a P chromosome king chosen in any generation is directly proportional to
its fitness. In other words:
EFitness (k) = Characteristic (k)
then Prob. (k) a Characteristic (k)
Using the same technique used to denve the above relationship, a few other examples
these relationships are provided below:
If Fitness (k) = 0.75*Characteristic (k)
then Prob. (k) Characteristic (k)
If Fitness (k) = [Characeristic (k)12
then Prob. (k) a [Characteristic (k)12
IfFitness (k) = 0.75.[Characteristic (k)12 + eUS
then Prob. (k) = [Characteristic (k)j2
The examples provided above were not selected for any specific reason, simply because
they encompass the more common types of fitness-characteristic relationships (Le.,
exponents, addition of constants, multiplication)
A102 Minimidng Measured Chmracteristic
Appendix 10.1 discussed scenarios in which the fitness value was directiondy
related to the property (i.e., characteristic) measured. These types of s c e d o s are
maximization focused, since they try to find chromosomes that maximize the desimi
characteristic.
When the property rneasured is couater-related to the fitness, than the roulette
wheel method is used to rninimize that property. The measured characteristics in
GAHOS is daily electricity cost or total project cost which are both counter related
characteristics.
The simplest relationship that can be drawn fiom the fitness value and cost is
stated below:
Fitness (k) = [cost (k)]-' = I
cost(k)
This type of formulation results in the following probability:
Beckwith and Wong (1995) as well as Wong and Wong (1994) recommend using a
different relationship between fitness and cost when anaiyzing water di~en'bution systems.
They suggest mdtip1ying the inverse of the cost value by a Largest possible constaut
Their fonnula is show0 beiow as:
where M = the maximum floating point number that can be represented by
the cornputer
The constant M does not alter any of the probabilities, and is used for the soie purpose of
magniSing the fitness values of the entire population. The proof of this is shown in the
If Fitness (k) = M
cos*)
.: Prob. (k) = cos@) i= M
As caa be seen, M does not effect the probability d i s i r i i on since it is present in both
the nominator and denominator and therefore cancels out,
A rnagdhtion factor such as M can be usem. However, declaring M to be the
maximum floating point number (Beckwith and Wong (1995) as weil as Wong and Wong
(1994) did) is dangerous with respect to the operation of the computer. To see this,
consider that at Iow cost(k) values and high population sizes (Le.. large n), the possi'bfity
exists that the running total may exceed the value of M. Since M is the largest possible
number the computer can manipulate, there exits a possibitity of an overflow or
erroneous calctdation (the computer couid store larger numbers i f they were defïned as
double floating points). This maüimction can take one of two fomis. The first would be
that the computer sixnpiy staiis without waming and with no suggestions of cause other
than the possibility of an error message describing a floating point error. Second, the
computer may simply stop counting at M and jwt assign the value of M to any fimction
that attempts to surpass i t This would be troublesome since it would not be readily
evident that a malfiinction has taken place. Indirect evidence may be found nom the
distribution of chromosomes chosen by the roulette wheel method. The method would be
biased towards the Iower chromosome numbers, specificaliy the chromosomes which
have numbers between 1 and T. Where T is defked as:
The above discussion has focused on the dangers of valuhg M as the Largest
floating point integer the computer aiiows. However, these same dangers can also occur
when M is less than the maximum floating point Ïnteger. Low cost values and large
population sizes c m also led to the same types of computer errors discussed previously.
It is thus up to the user to easure that the magnincation factor (i-e, M) is customized with
respect to the popdation size and the system (the system which is being optimized).
A103 Magnincation Methods Useà in GAEOS
Questions arises about when a magnification factor (Le., M) should be used and
what value of M should be assigned. Theoreticaily the magnincation factor should be
used when the original range of fitness values lies outside the possible storage or
fimctiod domain of the computer. For example, the Borland C* compiler ailows the
storage of floatuig point numbers in the range of 3.4 x 10+~* to 3.4 x 1 0 ~ ~ ~ 6ernighan and
Ritchie, 1988). The function domain is the range in which the computer can
mathematicdy manipulate the number. For example, ifthe original fitness values ranged
fiom 5 x 1 0 ~ ~ ' to 3 x 1 0 ~ ' , the lower part of the fitness value distribution will be
adversely effected by the cornputer's capability. Thus we can conclude that a
magnincation factor (i.e., M) should be used. The value of M should be such that it
draws the range of fitness values into the cornputers floatuig point domain.
Both venions of GAHOS when utiliMg input parameters (Le., water demand,
electricity cost, P value, population size, pump cost, storage tank COS) which are similar
to those available in the appendices do not require a magnification factor- However, if
the input parameters or the system as defined were to change drasticdy, a magnincation
factor might be necessary. Under such circumstances the equation presented beIow may
be used to chose an adequate M value:
3 -4 Average(fÏtness)
This equation wiU detennine the best M value in a compter with a fiinctional domain
range of 3.4 x 1 0 ~ ~ ~ to 3-4 x lW3*- The user should note that the center value of the
fünctional domain range is not 1.7 x 10-38 (The average between the two extremes), but
3.4 x 10' or simply 3.4.
A second magnification factor was developed for use in GAHOS, it is called the
magnification exponent P (not the same as P the mutation probability per chromosome as
used in the ICMM). The magnincation exponent is used in the fitness value expressions
as shown below:
Fiîness (k) = M
cos@)
Prob. (k) = , I -
When P is less than unity, the rouiette wheel method reduces the ability of low cost
chromosomes to outperform high cost chromosomes. In other words the sensitivity of the
metbod is decreased (the roulette wheel is less biased than when P=l) . When P is
greater than unity than the ability of low cost chromosomes to outperform high cost
chromosomes is încreased, In other words the rodette wheel becomes more and more
biased towards low cost chromosomes as the value off increases,
Fig. A10.1 presented below demonstrates how varying the magnification
exponent alters the probability distribution of population of chromosomes. For example
chromosome No. 3 has a greater probability of passing on its genes as the value of P
decreases. This is because chromosome No. 3 is a low performing chromosome, and
smalIer P values decrease the biased property of the roulette wheel.
Table A1O.l: The effect of the Magnifïcation exponent
1 Chromosome No, 1 Cost 1 Probabiüty when 1 Probability when 1 Probability when (
Chromosome No. 1 is the best perfonning individual in the entire population. Thus it
will always have the highest probability of passing on its genes. However, the lower the
P value, the less of an advantage it has over the rest of the chromosome in its population.
Nahval evolution and GA both share the property of replicating high performance
chromosomes in subsequent generations. The magnincation exponent simply allows the
GA user to increase or decrease the effectiveness of that property-
It is important to remember that the mutation probability (P), magnincation factor
(M), magnifïcation exponent (E') value and other GA parameters are set at levels that
decrease the length of the simulation and increase its confidence limits (increase the
certahty that the program found the best solution once the simulation has ended).
One way of evaluation the effectivenes of the genetic aigorithrns paramete= is to
look at its Gp value. The Gp value is equal to the number of generations the program had
to run before it found the absolute optimal solution. %y running the program over a long
period of time (between 5000 and 15000 generation) one can h d the optimal solution.
The next step is to alter the GA parameters so as to decrease the Gp value. Fig. A10.1
shown below illustrates the relationship between the Gp value and cost (which in this case
is actually daily electricity cost)
Fîg. A10.1: Daily electricity cost vs. Number ofgenerations
O 50 IO0 150 200 250
Number of Gemmtions
The GP value of the above figure is equd to 173. In other words this particuiar
simulation reached the optimal solution (Le., $53 -7 1/day) at the 1 73ed generation.
One point the reader should note is that a good set of GA parameters is fond by
striving for a low Gp average (take the average Gp value of at least 30-50 runs) and low
standard deviation. Finding a good set of GA parameters this way requires a sizable
investment of t h e (30 to 50 nuis per set of parameters). However, once this set is found
it is suitable for all simulations tbat utillle sunilar input (similar: population site, pumps,
storage tanks, electricity rate structure, water demand profile).
Appendix 11 - Star t i~~g Storage to Capacity Ratio
All.1 Strtting Storige Values
The amount of water present in the water reservoir at the staa of a simulation can
have a profound effect on the daily electricity cost (i-e., the solution recommended by
GAHOS changes depending on the starting volume). The starting storage to maximum
capacity is referred to as the SCR (Starting to Capacity Rztio). The SCR was found to be
a critical parameter in both GAHOS-1 and GAHOS-2.
The importance of the SCR in the course of fkding the optimal solution was a
complete surprise. Origindy GAHOS-I was designed to nui using a constant SCR
This constant would be used for ail storage tank sizes and for ai i pumps (an SCR of
between 0.4 to 0.6 was contemplated). However, it was soon evident that this
simplification (using a constant SCR for al1 simuIations) would not be possible. As wiiI
be descrïbed in the corning pages the SCR was made a variable that is optimized by
GAHOS, much like the way the pumping schedule to optimized.
It is f b t important to study how the SCR effects the operation of the water
distribution system. Every combination of storage rank size and pumping system (as weU
as water demand profile and electricity cost rate structure) has an optimal SCR. There
are two principles that govem what the optimal SCR is.
A) The ability of the rese~oi r to supply water to the network during the peak energy
charge hours (i.e., minimizing peak-period pumping).
B) The abiIity of the reservoir to take advantage of the off-peak period (i.e., mammiPng
off peak-period pumping).
An effective way of demonstrating these two principles is to imagine a water distributÏon
system with a fixed storage size and pumping station. What is the optimal SCR for this
system? The answer depends on where time zero is defked in energy charge cycle. The
energy charge cycle Ïs defined as the cycle consisting of the peak period and off-peak
period. It is quite reasonable to assume that these two period are 12 hours in Iength (i-e.,
a total of 24 hours). If time zero is located near the end of the off-peak period or the
beginning of the peak-period, then the SCR wouid be high. This is because principe A is
the prevailing influence. However if tune zero is located near the end of the peak-pend
or the beginning of the off-peak period thenprinciple B would prevail and the S/C ratio
would be low.
As can be seen nom the energy charge cycle depicted in Fig. A1 1 .l, the optimal
SCR is strongiy dependent on where thne zero is defined. However, the optimal SCR is
not exclusively dependent on the current position in the energy charge cycle. Other
factors such as water demand profle, storage capacity and pump characteristics can ais0
affect the optimal SCR (Chase and Ormsbee, 1993). In other words, for every
combination of demand profile, storage capacity, pumping system and schedule there
exists a SCR that mùiimizes the operational costs. Since the cornputer program is
designed to optimize the water distribution system, than it make sense to allow the
program to optimize the SCR also.
Fig. All.1: Energy charge cycle
Off-peak period ' Peakpenod _ / -- i - - - 1 -- - i
I -- i
I
Max SCR I i L 1
O 14 20 30 40 50 60 70 80 90 100
Tîme (hr]
As stated previously the original design of GAHOS-1 specined that the SCR was
not an optimizable variable but rather a user specined property (like the water demand
profile or electricity prices). By ninning a prelimllrary version of GAHOS- 1 (one in
which the SCR is user defïned) many times using a broad range of SCRs, Fig. Al 1.2 was
created (Appendix 1 describes the expeximent in detail). The experhent produced some
interesting redts. As can be seen fiom Fig. Al 1.2, there exists a range of SCRs that
produce the lowest daily pumping costs. The reader should keep in mind that every data
point in Fig. A1 1.2 is a combination of an SCR value and pumping schedde with an
associated daily electxicity cost. The pumping schedule does change as the SCR varies.
This even occurs in the optimal range of SCRs (ie., between 0.005 and 0.68).
The existence of a valley or range of optimal SCRs rnakes intrinsic sense,
especialiy when analyzed using the two goveming principals rnentioned previously. At
very low
Fig. A112 Daily Pumping Costs vs. S/C ratio
Optimal S/C ratio is between 0.5% and 68%
I 40 50 60
S/C ratio [%]
SC&, the reservoir may not be able to supply water to the network during the pedc
energy charge hours without the use of the pumps. At very high SCRs, the reservoir
capacity remaining may not be d c i e n t to take advantage of the off-peak period.
Fig. Al 1.2 Uustrates the complex nature of the SCR and how diEcuit it would be
for the user to estimate what the SCR value shodd be. Similar experiments (similar to
that belonging to Fig. A1 1.2) were conducted using several diEerent storage tank sizes.
Table All.1: Optimal range of SIC ratios for different reservoir sizes
MaxÏmum. Storage Capacity Da* Pumping Cost Optimal SCR mage rm3i
By Iooking at the optïmai range of SCRs for the various tank sùes it is evident how
wrong it was to iaitially assume tbat the range would be between 0.4 and 0.6 (as
previously mentioned).
The relationship between the optimal SCR range, daily pumping cost and storage
size is not readily evident at iïrst glance. There appears to be no correlation between the
t h e , however relationship does exists. When the storage tank sïzes are greater than
8,000 m3 the daily pumping cost is the smallest. Ali tanks greater than 8,000 m3 produce
the same minimum M y pumping costs of $53.7/day. In fact, an innnitely large storage
tank could not better that pumping c o h It is for this ceason that the term "needlessly
hugeyy can be used to describe ali storage tanks greater than 8,000m3. "LNeedlessly huge"
because a smaller tank c m equal the pumping cost and at the same tune require less
initial capital for its construction.
Let us imagine the smaliest storage tank that can maintain a $53.7/day electricity
charge. We will refer to the size of this storage tank as X. By viewing Table Al 1.1, we
can conclude that X is between 4,000 m3 and 8,000 m3. Ail storage tanks greater that X
have a broader SCR range than X itself. The bigger the tank. the broader the optimal
SCR range becomes. This can be seen by comparing the optimal SCR range for storage
sUe of the 8,000m3 and the 12,000m3 storage tank (see Table Al 1.1). The 8,000m3 tank
has an optimal range between 0.1 and 0.5, while the 12,000m3 tank has an optimal range
between 0.005 and 0.68. In fact an innnitely large storage tank has a SCR range between
1/00 and 1.
For tank sïzes Iess than X, the relationship between the SCR and storage tank size
becomes very complicaîed. Tank sizes below X must îïnd an equilibrium point that
satie both PrincIpaI A and Principal B. The term "equilibrium point" is used to
describe the set of conditions (Le., SCR, pumping schedule etc.) that achieve the lowest
possible cost. The equilibrium point between Principal A and Principal B is very
sensitive to demand rates, electricity cost rates and differing pumping systems. Thus it is
futile to expIicitly state an SCR even if the storage tank capacity is fked The only
logical conclusion is to make the SCR a decision variable that is optïmized by the GA.
Thus GAHOS-1 was designed to encode the SCR and pumping schedule in its
chromosomes and optimize them simdtaneously. W e GAHOS-2 was designed to
encode the SCR, pumping schedule, storage tank size and pump type in its chromosomes
and solve these variables simdtaneously also.
Appendir 12 - ENUMERO cornputer code
#inchde <conio.h> #inchde <stdio.h> #inchde <iostream.h> #inchde <fstream.h> #inchde <time.h> #include Vlos.h> #inchde <math& #inchde -%h> char inle[lO]; /*global variables*/ int size; Pglobai variables*/ int ngen; /*global variables*/ int time-minutes; int timeinttime_max;max; float prob; int changes; float demand[96];/*gIobal variables*/ float price[96];/*global variables*/ int orig-chromo [I O0 J [9q; int test-chromo [9q; float evaluate[100]; fioat storageeremaining[97I ; int list[lOO]; int new~chromo_list[l O0 11963; int order-of-evaluation[I 001;
void open.ng~fïle(void); / *hction prototype*/ void outpututfile(void); void screen data(void); /*fiinction prototype*/ void title(vGd); /*fiindon prototype*/ void nin.time(void); void rand-iisî(void); void print-Iist(void); void crossover(int a); void show~crossover~titie(void); void show~crossover(void); void showjair(void); void show mutation(void); void show>aluation(void); void show-done(void); void show_generation(inta); void roulette wheel(void); void mutation(float x);
void qsort(float v0,int le& int right); void qsort2(fI oat vojnt le& int right); void swap(float vu, int i, int j); void swap2(int vu, int i, int j); void expandMce(void); void expand4demand(void); float find-storage(int i); int u - r~~ ld~n t a); fl oat unit(void); int random(int num); void evd(void); void children(void); int x-addition(v0id); float x-evaI(void); void x-test(void); void x-initial(void); void xqrint(void); float storage-nax; float storage - staa; float Q; float H; float n; int best-99; float hi&=-999;
dock-t start, end;
void main(void) /* main program*/
int i jp ; randomizeo; start = clocko; titleo; s~reen~dataQ; titleo; opening-file(); / /p~tf("\n probabilty %f ',prob); // getcho; expandqriceo; //printf(tr\n probabilty %f ',prob); // getcho; expand-demando; //printfc'\n probabilty %P,prob); // getcho ;
/*for @=û;p<=ngen;p++) ( show_generation@); rand-IIstO; showqaair(); if(p<ngen) {
for (i=û;ic=size-2;i==i+2) { crossover(i) ; show~crossover0;
}
show-mutationo; mutation@ro b); ~how~evaluation0;
} e v w ; qsort(evaluate,0,99);
if @<ngen) ( c hildreno ; mutation(prob); evaio; qsort(evaluate,0,99);
gotoxy(lO,l4); printf("Current best: %. 1 f " ,evaluate[O]); if ( p a g e @ (
show-doneo; gotoxy(1 O, 12); printf(ir time elapsed(sec): "); run-timeo ; /*for (i=O;ic=timeemax- 1 ;i*) {
printf("b%d %f %f',i,price[i],demand[i]); ) */ //getchO; /*for (i=O;i<=time-max- 1 ;itt)(
printf('\n%.4ft ,orig-chromo [order-O ff evaluation~]] b] *price[i1* I 40 -27); 1 //getchO ; gotoxy(1 O, 16); //printfct Reservoir stageW ); for (j=O;j<=O$+) (
p~tf("The best solution:"); gotoxy(l0,l;l); for (i=O;i<=time max- l ;i*) (
printf("%% ,origgchromo [order-O f-evaluat ion[0] ] [il); 1
1 1 1 */
/*whiie gotoxy(1 O,24); for (i=O;i<=î3 ;i*) {
p ~ t f ( " %dl',teststchromo [il); 1
void titie(void)
clrscro; gotoxy(l5,1); printfC'0NE PUMP ONE RESERVOIR: VERSION 1 .On);
1
void output-6le(void)
int i j; FILE *s tream2; Stream2 = fopen("out.txt","w"); for (i=O;i<=time-max- l ;i*) (
fprintfistream2.''h%d %f %f ',i,pnce~,demand[i]); 1 Qrintf(stream2,"\nThe best solution\nWt);
for (i=O;i<=timeemax-1 ;i*) { @rintf((stream2.'t%d\tt'7~rigg~hromo [order-of-evdution[O]] [i 1);
1
void opening-fïIe(void) C
int i j; FILE *streaml; stream i = f~pen(ifile~~'r'~); gotoxy(l~95); printf("0pening me: %sw,ïfiie); gotoxy(l0,6); /*start location of line beIow * / printfrReading file: "); for (i=O;i<=23 ;i*) {
fscanfstreeam 1 ," %£in" ,&price~); goto~y(24~6); /*pretend info*/ printf~'%d" ,demand DI);
1 for (i=û;i<=23;i+t){
fscanfstream 1 ,"%fin" &demand[i 1); gotoxy(249 6); printf("%f1,price [il);
1 w t o v u O,@; pri.tf("chromosomes: ");
for (j=O;j<=size- 1 $+) { fscd(stream1 ,"W); gotoxy(23 76) ; for (i=O;i<=time-max-l;i*) { fscanf((stream 1 ,"%d",&orig-chromo b]D]);
if (time - minutesH 5) { printf("%d'I ,orig-chromo [il);
1
1 w t o v ( 10,d); printf("chromosomes initiation: done gotoxy(1 O, 10); p~tf("generation #: "); gotoxy(3 5,l O); pnntf("status: ");
void screen-data(void)
void x-initial(void)
int i; for (i=O;i<=tirne-max- 1 ;i+t) 1
test-chromo @]=O;
test~chomo[tirneemax-l]~est~~hr~m~[timeemax-l]+l Y/adds a one to the end of the chromosome
for (i=time - max-l;i>=l ;i=i-1)
if (test.chromo [g>=2) C
test-chromo [il*; testtest_chromo[i-i]=test_chromoCi-l]tl;~hromo[i-l]=test~chomo[i-l]+l; //getchO; gotoxy(1 O, 19); xqrinto;
void x-test(void)
float best,current,add; int i; ~~initialo; hem-evaio; gotoxy(1 0, 18); printfrX-Test B est: "); while ((x-additionO)=O) (
curren--evalo; gotoxy(lO,2 1); printf("current is below: %f ",curent); gotoxy(l0,22); xqrinto; if @est > current) {
best = current; Ugetcho; gotoxy(lO,l6);
void ru.-tixne(void)
end = clocko; printfr%. If", (end - stan
1
void rand-list(void)
for (i=l ;i<=4*size;i*) ( lofa- 1 -71-md(size); lo~a~2=u-rand(size); temp-of-loca-1 =list[loca-11; list[ioca_i]=iist[ioca-21; iist[ioca_2]=temp-of-loca-1; 1
1
void crossover(int a)
int temp; int pos,i; //randomizeO; pos=random(22);
for (i=pos;i<=time max- 1 ;i*) ( temp=orig-chromo-pas] ] [ïj ;
void show-done(void)
gotoxy(45,l O); printfidone "1;
1
void showjair(void) {
gotoxy(4S,I O); printf("pairing ");
1
void sho w-mutation(void)
gotoxy(4S,lo);
void show-evaluation(void)
gotoxy(45,l O); printf("eva1uating ");
1 void show crossover(void) -
gotoxy(45,l O); printf("crossover ");
1
void show_generation(int a)
gotoxy(25,l O); p~tf("%d ",a);
void expandgrice(void)
int ij,c; c=24; if (tirne-max>24) (
for (i--max- l ;i>=O;i=i-(60hime - minutes)) {
l l
1 void expandddemand(void) {
int i j,c; c=24;
if (tî.rne-max>X))( for (i=time-ma- 1 ;i>=û;i=i-(6O/time minutes)) (
//printf(Yn probabilty %f ~/od<~rob,~); //getchO; r = 4 ; for(j=û;j<(60/timeeminutes);*j) (
demand[i-j]=demandCc1; 1
1 }
1
float final-storage(int i)
int j; storage-rernaining[O]=eorage-start; for (j=l $=tirne-maxü*) (
storage-remaining[i]=storage-remainingb-] + (Q*orig-chromoCi][i-l] - demandb- il)* (3 600/(60/timeeminutes));
void x-t(void)
int j; for (j=O;i<=time - max-l g++)
void eval(void) {
int i j; float x; for (i=û;i<=size-1 ;iU) {
~ r d e r ~ o f ~ evaluationli ]=i; evaluate[i]=O; A; storagestorage_remaining[o]=storape_start;remaining[O]=storageestart; reg-chromo [il [O] *price[O] *(H*Q*9.8fn)/(60/time-~utes);
for (i=1 j<=timeemax.J*) { storageeremaining[i]=storageerernaining~- +
(Q*orig-chromo[i]b-11- demandci-1])*60*timeeminutes;
if (0-e max) && (storageeremainuig[jl < storage-start)) ( x = :+ 2* (storage-start - storage_rernaining[j3);
1
1 float x-eval(void)
{ int j; float x; for (j=û j<=time max$+k){
storage-rimaining ) //gotoxy( 1022); //x-(); //gotoxy (1 0,271; r=; storageeremaining[0]=storagerastart; -es t.chromo[O] *price [O] *(H*Q*9.8/n)/(60/;
for (i=lj<-+me max$+) { storage-r<rnaining[i]=storageeremaining~- 1 + (Q *test-chromoCi-
11 - demandb-lni60*time - minutes;
if (storage-remainingb ]<=O) { F x + 2*(0 - storage-remaining fi]);
}
void print - list(void)
int i;
for (i=l ;i<=size;i*) ( printfpl%d %d",i&st[ïJ); 1
1 float unit(void)
float i; float x; i=randO; - - - MAX;
return x; 1
void mutation(f1oat x)
int iJpumber~chromo,a,b,c,temp,t; numberberchromo=(size*x)/1 ; //printfc\n size %d" ,size); //prhtf("\n probabilty %f ',x); //printf("\n probabilty %f ',prob); //printf("b mutation %dl',number~chromo); for (i=O;i<=number-chromo;i*) (
for (j=l a<=changes je) ( a=random(size);
b-ranandom(time-ma); //(tirne-ma); c=random(timeemax);//(time ma); Itprintf("\nbefore number %@hd %d %d %d
\n." ,a,b,c,onggchromo [a] ~],onggchromo [a] [cl); for (t=û;tc--tirne-max- 1 p) {
printf("%dW ,orig-chromo [a] [t]); 1 */ temprig-chromo [a] M ;
orig-chromo [a] ~]=origgchromo [a] [cl; ong chromo[a] [cl-temp; PP&tfc"\nafter nurnber Yid location1 %d location2 %d vl Yi v2
%d \n",a,b,c,onggchromo [a] @ ],origgchromo [a] [cl); for (M;t<=time max-l ;t*) {
printfcl~Z ,ong-chromo [a] [tl); 1 */ /* */
1 1 for (i=O;i<=nwnber-chromo;i*) {
a=random(size) ; b==dorn(time-mm); /@me-max); if (ong-chromo [a] @ ]=i
ong-chromo [a] P]=O; else
orig-chromo[a] ]=O; 1
1
void roulette - wheel(void)
int i j,counter-inside-while; int runninggtOtal[lOO]; int random-number;
for (i=O;i<=size- 1 ;i+) ( ninning-total[i]=O;
1
for (i=1 ;i<=size-1 ;i*) ( running-total [i]=Tunning-total[i- 1 ] + evaluate [il;
1
for (i=û;i<=size-1 ;i*) {
1 for (i=û;i<=size-1 ;i*) {
for (i=ûj<=timeeminutes;i*) { orig-chromo Ci] ~]=newWchrornoe1ist[i] 1 ;
1 1
void qsort(float v0,int Ieft, int right) {
int i, lastJast2;
if oeft >=right) retuni ;
swap(v,left,(left + right)/2); swap2(order-of-eval~ation,le y(left + right)/2); lasHefi; lastî=Ieft; for(i=Ieft+l ;i<=right;i-i+) {
if (v[i]< v Defi]) ( swap(v, ++last,i); swap2(order-of_evaluation, *last2,i);
l 1 swap(v, left, lad); swap2(order-of-evalusttion, leftJast2); qsort(v, lefi, last-1); qsort(v, iasttl, right);
1
void swap(float vn, int i, int j)
float ternp; temp = v[i]; v[i] = vu]: vu] = temp;
1 void qsort2(float vn,int Le& int right) {
int i, last,last2;
if(ieft >=rîght) retum ;
swap(v,left,(left + right)/2); swap2(0rder-o~evaluation,left,(Iefi + rïght)/2); last=Iek last2=1eft; for(i=Ieft+ i ;i<=right;it+)(
if (v[i]c v[Ieft]) { swap(v, ++lad$); swap2(order-of-eval~ation~ Mast2,i);
1 1 swap(v, le& Iast); swap2(order-o~evduation, le&last2); qsoqv, Ieft, Iast-1); qsort(v, last+l, right);
void swap2(int vu, int i int j)
int temp; temp = v[i]; v[i] = vu]: v[i] = temp;
1
void children(void)
int i j; for (i=l;i<=9;i-i+)(
for (j=O;j<=time - max-1 ;j++)(
> 1 for (i=O;ic=L2;itt){
for (j=4l;j<=time - max-1 ;j*) (
Appendk 12 - Toronto Eydm EIecnici@ Rates - -
- 6.93 cents per kwhr.
Foc l a s wi t h an average billing c l a n a d for tlic nor\ths of lipr i l to Teptaaber inclusive trtvcen 258 anil 500 S M - 5%
Foc loacls w i t h an ctvccage billirq clmaid foc thc montlis of ~ p r i l to Scptcmbcr inclusivc cxccdinq 509 KW - 10%
The tates arc gcoss rates and suhjcct ta a prompt payment discount of 10%. r-lhere the custnirpc is supplied at 4.16 kV or 13.8 kV, the appropriate transfomatf on aïlowance shaU also ~ P P ~ Y +
The Wïntec -tes s h a l l k appLicahle to cwrsunptim âucing the months of January, Febtuaty, tlùrch, Qctokr, Novanber and kcembcr. me S u m e t Rates shall amly to mnsunption ducinq the months of ApriL, m y , Jme, Juïy, A i q u s t and Scpt-c.
1. Ebr consmptiar in the P ~ û k Fccial, whicli s l m L 1 inducle the houcs fran 9:W am. to 8:08 p.m,, E M a y to Ftfday, except public Ciolidays :
Deniand charge* per kilowatt of ~ x i m u n clemanl p c -th accurrirq cluriq--the Peak Period:
*
Energy Charge : Wintec- $ O . B G c ) l p e r kWhc S u m e t - $ 0.0596 p r ktIhc
2. Ebr consunption in 'the Shoulder PCC id, d~ icli sIiall includc the houcs Eran 7:00 a-m. to 3:W a.m. a d 8:00 p.m. ta l l : W &m., ttmday to Fr iday, except public holidays:
3. Ebr consunption in the Off-~cak houcs, which ehalL incluile al1 other b u t s not included in the Peak Period and the Shoulder Fer iod :
The rates are gross rates and subject to a prompt payment discount of 10%. Where the customer is supplied at 4 - 1 6 kV or 13.8 kV, the appropriate transformation allowance shall also ~ P P ~ Y
The Wintcr R a t e s shall be applicable to consuniption during the months of January, February, Narch, October, November and December. The Sumer R a t e s shall apply to consumption during the months of April, May, June, July, August and Septernber-
For consumption i n the Peak P c r i o d , w h i c h s h a U include the hours from gr00 a.m. to 8:00 p.m.-, Monday to Friday, except - public holidays :
Demand Charge par kilowatt o f maximum demand per month occurring during-*the Peak Period :
NEW RATES
~ i n t e . r - $ 9.86 per KW Swnmet- $ 8 - 2 S p e r k W -
Energy Charge : Winter - $ 0.0621 per kWht Summer - $ 0 .0533 per kWhr
For consumption in the Shoulder Period, which shall include the hours f r o m 7 : 0 0 a.m. t o 9:00 a.m. and 8 : 0 0 p . m . to 11:OO p. m. , Monday to Frida-y , except public holidays :
NEW RATES EFFECTIVE JAN, 1/90
Ener gy Charge : Winter- $ 0 ,0621perkWhr Sumer- $ 0 ,0533perkWhr
0
F o r conswnption in the O f f - P e a k hours, whfch shall include 111 other hours not included in the Peak Period and the Shoulder Period:
NEW =TES EFFECTIVE JM. 1/90
u Energy Charge : Winter- $ 0 . 0 2 9 3 p c r k W h r Summer - $ O . C219 per kWhr
Appendix 13 - Input fiïe bit-l5.txt
Input nle used for GAHOS-1 A and GAHûS-IB
electndity cost for hour O [$/kWh]
electricity cost for hour 24 [$/kW-hr] water demand rate for hour O [m3fs]
O. 14 0-16 O. 162 0.161 0.15 0.135 c water dernand rate for hour 24 [m3/s]
Appendix 14 - Input fiïe test-15.-
Input file used for GAHOS-2
0.0219 c electrîdity wst for hour O [$/kW-h] 0.02 19 0.0219 0.0219 0.0219 0.0219 0.0219 0.02 f 9 0.021 9 0.069 0.069 0.069 0.069 0.069 0.069 0.069 0.069 0.069 0.069 0.069 0.0219 0.0219 0.0219 0.0219 <--.-- - 2 4 electricity cost for hour [S/kW*hr] 0.08 < --- water dernand rate for hour O [m3/s] 0.075 0.065 0.062 0.065 0.065 0.066 0.09 1 o. 102 0.101 0.1 15 0.12 0.13 0.14 0.135 0.13 0.128 0.132 .
O. 14 O. 16 0.162 0.161 O- 15 0.135 c water dernand rate for hou 24 [m3fs]
580000 0.070 2000cStorage tank #1 (principal cost ($)@&O cost (%),Capacity (m3)) 860000 0-069 4000 1280000 0.068 7000 1980000 0.067 12000 2820000 0.066 18000 K - Storage tank #5
1 1 16090 O. 10 O. 1% 60.3 0.78 < -Pump type #1 @rincipd cost (S), Ma0 cost (%), 1023706 0.13 0.180 53.9 0.81 flow (m3/s), head (m), 1178509 0.09 0.203 62-1 0.77 efficiency (%)) 123 1594 0.08 0.231 55.3 0.76 1193829 0.1 1 0.196 68.2 0.79 c -Pmp type #5
Appendix 15 - Output mes showing the effet of the absoiufe-kt hct ion .
Output file of GAHOS-2 with the absolute-best function
Note: first column is the generation number, the second column is the cunent best solution,
Output file of GAHOS-2 without the absolute-best fiinction
Note: Grst column is the generation number, the second c o l m is the current best solution,