หลักการทำงานของโปรแกรม qual2kw new
TRANSCRIPT
-
8/19/2019 Qual2kw New
1/15
1
QUAL2Kw
Worksheet “Headwater” 1. (Discharge Q) 2. Parameter
2.1 (Temperature),2.2 (Conductivity),
2.3 (Dissolved Oxygen),2.4 (CBODfast),2.5 - (NH4-Nitrogen),
2.6 - ( NO3-Nitrogen),
2.7 Total phosphorus (TP),
2.8 (Pathogen)
2.9 - ( pH) Worksheet “ Reach ”
1. (Cross section) 2. (channel slope)3. (side slope) ( - ) 4. (bottom width) 5. , Reach ( )6. Reach ( )
Worksheet “Air Temperature”
1. Reach ( )
Worksheet “ Dew Point Temperature ”
1. Reach ( )
Worksheet “Wind speed ”
Input Data
-
8/19/2019 Qual2kw New
2/15
2
1.
Worksheet “Cloud cover”
1.
Worksheet “Shade”
1.
Worksheet “ Point Source ”
1.
- ,- / / - - (5, 10 )
2. - ,- BOD / ,
- . ./ -
Worksheet “Diffuse Sources”
1. 1.5 . Reach2. ( )
3. ( . / ) ( )
4.
Worksheet 1. Hydraulics Data, 2. Temperature Data, 3. WQ Data,4. WQ Data Min, 5. WQ Data Max (Tab worksheet
)
Input Data ( )
-
8/19/2019 Qual2kw New
3/15
3
1. Input Data QUAL2Kw Run 2 Run VBA Run Fortran ( Run Fortran ) 1 2
Fitness cell G3 worksheet “Rates”
2. QUAL2Kw Output Data 2(Tab Worksheet ) (Tab Worksheet )Parameter QUAL2Kw ( )
3. Root Mean Square Error
(Print out) 4. Worksheet
“Rate” 4.1 Output parameter
1 2 ( Worksheet “Rates”)code parameter cell
1. Fast CBOD: 2. Organic N: 3. Ammonium:
4. Nitrate: 5. Organic P: 6. Pathogen
Process
Run Auto-cal
(Goldberg & Michalewicz)Run
Auto-cal
Cell G3
-
8/19/2019 Qual2kw New
4/15
4
4.2 Parameter Column “E” Dropdown list Yes Max Min Column “F”
Column “G”
Max
Min GA search
Yes GA search
No
Run Auto-cal
-
8/19/2019 Qual2kw New
5/15
-
8/19/2019 Qual2kw New
6/15
6
QUAL2Kw GA
QUAL2Kw ( Genetic Algorithm ) 8
1 (Initial population )
2 (Fitness value )
3 (Selection )
4 (Crossover ) (Mutation )
5 (Number of offspring)
6 (Replacement)
7 (Numberof generation)
8 End the Optimization
Yes
Yes
No
No
-
8/19/2019 Qual2kw New
7/15
7
1 (Initial population )
2 (Fitness value )
(Fitness value ) (Root mean squared error )
3 (Selection ) 2
4 (Crossover ) (Mutation ) 3
( gene) (offspring)
2
(Mutation)
5 (Number of offspring) 6 3
6 (Replacement)
7 (Number of generation)
Generations termination criteria 8 2
100
300
-
8/19/2019 Qual2kw New
8/15
8
8 End the Optimization
Optimized
4.4 Run Auto-cal (Goldberg & Michalewicz) 1 GA Charbonneau & Knapp
Goldberg & Michalewicz
(GA Operators )
GA Operator *
(Charbonneau & Knapp)
GA Operator**
(Goldberg & Michalewicz )
1. (selection operator)1.1 full generational replacement
1.2 steady-state-replace-random
1.3 steady-state-replace-worst
1. (selection operator)1.1 Proportional Selection 1.2 Rank Selection
1.3 Tournament Selection
2. (crossover operator) 2.1 one-point crossover
2.2 two-point crossover
2.3 equal probability of either one-point or two-point
crossover
2.4 uniform crossover
2.5 equal probability of either one-point, two-point, or
uniform2.6 arithmetic crossover
2.7 equal probability of either one-point, two-point,
uniform, or arithmetic
2. (crossover operator)
2.1 one-point crossover 2.2 two-point crossover 2.3 uniform crossover
-
8/19/2019 Qual2kw New
9/15
9
(GA Operators ) ( )
GA Operator *
(Charbonneau & Knapp)
GA Operator**
(Goldberg & Michalewicz )
3. (Mutation Operator) 3.1 one-point mutation, fixed rate
3.2 one-point, adjustable rate based on fitness
3.3 one-point, adjustable rate based on distance
3.4 one-point or creep, fixed rate
3.5 one-point or creep, adjustable rate based on fitness
3.6 one-point or creep, adjustable rate based on distance
3. (MutationOperator)
3.1 conventional mutation
3.2 uniform mutation
3.3 modified uniform mutation 3.4 non-uniform mutation
User Interface
GA Operator
Charbonneau & Knapp GA Operator Goldberg & Michalewicz
code 3 Operator Run Auto – cal GA
operator Module Autocal_algorithm
-
8/19/2019 Qual2kw New
10/15
10
(GA)
(Genetic Algorithm)
(The Survival of The Fittest) (Charles Darwin, 1809-1882) ( J o h n H o l l a n d ) . .1960-1980
GA Operator Goldberg & Michalewicz
3
1. (Selection) (Parent)
(Population)
(Reproduction)
(Fitness) 3
1.1 Proportional selection probabilities of
selection (Pi) Pi - 1.2 Rank selection
1.3 Tournament selection 2. (Crossover) gene (offspring )) 3
2.1 one-point Crossover
2.2 two-point Crossover
2.3 uniform Crossover
3. (Mutation) 2 chromosome gene
gene 0 1 1 0 4 3.1 conventional Mutation 0 1 1 03.2 Uniform Mutation [0.1, 0.1,
0.12,…] Mutate gene
3.3 Modified uniform Mutation Mutate gene
-
8/19/2019 Qual2kw New
11/15
11
3.4 Non- uniform Mutation Mutate Generation ( fitness Optimize )
(Selection operator) Charbonneau and Knapp 1.1 full generational replacement
1.2 steady-state-replace-random
1.3 steady-state-replace-worst
(** crossover mutation Goldberg and Michalewicz)
Output 2 1. Run VBA Run Fortran (Output)
worksheet 1.1 Source Summary
1.2 Temperature Output
1.3 WQ Output
1.4 WQ Min
1.5 WQ Max
( Parameter 1. Fast CBOD, 2. Organic N, 3. Ammonium, 4. Nitrate:5. Organic P, 6.Pathogen)
Output
Worksheet
-
8/19/2019 Qual2kw New
12/15
12
2. Run VBA Run Fortran (Output) worksheet (Worksheet output )
2.1 CBOD fast 2.2 Organic N
2.3 NH3 2.4 NO3
2.5 Organic P 2.6 Pathogen
2.7 pH
Worksheet
-
8/19/2019 Qual2kw New
13/15
13
Module ( )
1. Module Autocal_rates Column B (B9:B130)
worksheet “Rates” Call PIKAIA_Rates Module Autocal_driver
2. Module Autocal_algorithm ( G A o p e r a t o r ) c o n v e r t
F O RT R A N 7 7 VBA ( c o m m e n t FORTRAN 77)
3. Module Autocal_runq2k Output worksheet ( Source Summary ,
Hydraulics Summary , Temperature Output , WQ Output , WQ Min , WQ Max , Sediment Fluxes ,
Diel Water Column , Diel Hyporheic Diel Fluxes ) RUN Auto-cal callModule Autocal_runq2k ( Module Autocal_runq2k path “qual2kw5.exe” compile FORTRAN Path Qual2kw5.exe RUN FORTRAN )
RUN FORTRAN = Module Autocal_runq2k RUN Auto-cal = Module Autocal_driver RUN VBA = Sub calc Module AMainProgram
Qual2kw
Worksheet “Rates”
np = ctrl (1) = Population number [default np = 100]ngen = ctrl (2) = Number of Generation [default ngen = 500]
nd = ctrl (3) = Encoding accuracy [default nd = 5] pcross = ctrl (4) = Crossover rate [default pcross = 0.85]imut = ctrl (5) = Mutation mode [default imut = 2]
pmut = ctrl (6) = Initial mutation rate [default pmut = 0.005] pmutmn = ctrl (7) = Minimum mutation rate [default pmutmn = 0.0001] pmutmx = ctrl (8) = Maximum mutation rate [default pmutmx = 0.01]fdit = ctrl (9) = Fitness differential [default fdit = 1.0]irep = ctrl (10) = Reproduction plans [default irep = 1]ielite = ctrl (11) = Elitism [default ielite = 1]ivrb = ctrl (12) = Verbose mode [default ivrb = 0]
GA search fitness value (cell “G3”)
-
8/19/2019 Qual2kw New
14/15
14
ph = phenotype ( term )gn = genotype ( term GA) ( Encoding)np = Population size (number of populations = search
)ngen = number of generations (1 Generation 3 (selection, crossover,mutation ) GA)rnkpop = Rank population
Element InternalVariable TypeLegal
ValuesDefaultValues
1 np Integer ≤ 128 1002 ngen Integer < ∞ 5003 nd Integer ≤ 6 5
4 pcross Real 0.0 ≤ pcross ≤ 1.0 0.855 imut Integer 1,2 26 pmut Real 0.0 ≤ pmut ≤ 1.0 0.0057 pmutmn Real 0.0 ≤ pmutmn ≤ 1.0 0.00058 pmutmx Real 0.0 ≤ pmutmx ≤ 1.0 0.259 fdit Real 0.0 ≤ fdit ≤ 1.0 1.0
10 irep Integer 1,2,3 111 ielite Integer 0,1 112 ivrb Integer 0,1,2 0
Internal arrays
Array Type True size Active size DescriptionOldph Real (32,128) (n,np) Main population
Newph Real (32,128) (n,np) New populationFitns Real (128) (np) Fitness valuesJfit Integer (128) (np) Fitness-based rankifit Integer (128) (np) Rank key index
ff = fitness function (G3 )
pikaia = GA Fortran Charbonneau& Knapp
Module Autocal_Algorithm convert FORTRAN VBA comment FORTRAN
FORTRAN
.gt. =
.lt. =
.ne. =
-
8/19/2019 Qual2kw New
15/15
15
GAParent = Breed = Offspring = Generation = 1 3 1.selection
2. Crossover 3.mutationPopulation = search
Ka =
(Objective Function)
q
im
j
m
jq
i
m jOi j Pi
m
jOi
WiWi x f
1
1
2
1
12
1
,,
,
1)(
Oi, j = observed valuePi, j = predicted valuem = number of pairs of predicted and observed valuesWi = weighting factor
q = number of different state variables (e.g. dissolvedoxygen, pH, nutrient concentrations,etc.) included in thereciprocal of the weighted normalized RMSE.
i = number of reach j = number of point and non-point source