# Genetic Programming and Standardization in Water Temperature Modelling

Authors: Maritza Arganis; Rafael Val; Jordi Prats; Katya Rodríguez; Ramón Domínguez; Josep Dolz
Journal: Advances in Civil Engineering
 (2009)

---

## Abstract

An application of Genetic Programming (an evolutionary computational tool) without and with standardization data is presented with the aim of modeling the behavior of the water temperature in a river in terms of meteorological variables that are easily measured, to explore their explanatory power and to emphasize the utility of the standardization of variables in order to reduce the effect of those with large variance. Recorded data corresponding to the water temperature behavior at the Ebro River, Spain, are used as analysis case, showing a performance improvement on the developed model when data are standardized. This improvement is reflected in a reduction of the mean square error. Finally, the models obtained in this document were applied to estimate the water temperature in 2004, in order to provide evidence about their applicability to forecasting purposes.


---

## Body

## 1. Introduction

Evolutionary computing has been widely used in hydraulics and hydrology, for example, the studies ofSavic et al. [1], Madsen et al. [2], and Dorado et al.[3], related to rainfall-runoff processes, modeling of an urban aquifer as was discussed by Hong and Rosen [4], or the modifications of genetic programming algorithms attempting to get an agreement with the problem dimension in natural and compounded channels as applied by Keijzer and Babovic [5], Harris et al. [6], and Keijzer et al. [7]. On the other hand, water temperature is an important parameter to consider because of the changesit can experience due to human activities. In the last three decades diverse studies about weather changes have been made, related to the increase of extreme events such as floods and droughts (e.g., Lehner et al. [8]) the increasing air and water temperatures (e.g., Seguí [9]; Webb and Nobilis [10]), ice melting, and greenhouse effect (e.g., Greve [11]), with all their consequences in the surrounding ecosystems (e.g., Schindler [12], Álvarez Cobelas et al. [13]).The motivation to work with models that allow the representation of water temperature behavior year after year is because each time a possible abnormal increase in this parameter occurs, the consequences and implications for the physical and chemical properties of water with their corresponding effects in aquatic life are numerous. Some models have been applied to maximum water temperatures by means of nonlinear relationships between air temperature and water temperature (Caissie et al. [14]), but there are other important variables involved in water temperature variation during a given period of time. In order to preserve the ecological balance it is very important to have a continuous inspection of water quality in that portion of the river. Freshwater organisms are mostly ectotherms and are therefore largely influenced by water temperature. Some of the expected consequences of a water temperature increase are life-cycle changes (Hellawell [15]; Winfield and Nelson [16]), shifts in the distribution of species with the arrival of allochthonous species (Walther et al. [17]), and the expansion of epidemic diseases (Harvell et al. [18]) as a possible result. Also, aquatic flora and fauna depend on dissolved oxygen to survive, and this water quality parameter is a function of water temperature as well.


## 2. Study Site

The field data used in this study were taken from the lower Ebro River, Spain. This river has a basin of 85 000 km2 and an average year inflow of 17 000 hm3 in natural regime. Three dams are located along the river (Figure 1) which change the water temperature regime (Val [19]): Mequinenza (1534 hm3), Ribarroja (210 hm3), and Flix (11 hm3). Five kilometers downstream the Flix dam, the water is taken from the river with cooling purposes in the Nuclear Central Ascó. Water is returned to the river with a higher temperature and flows downstream to Miravet. In this zone several meteorological gauge stations were installed, including some measuring water temperature (Figure 1). These data were applied in studies made by Val [19] and Prats et al. [20]. Besides, an important effort has been recently made to obtain equations to predict water temperature associated to meteorological variables that are easily measured, centered at the Ribarroja station (Arganis et al. [21, 22]).Figure 1
Station locations at the Ebro River, Spain.


## 3. Methodology

### 3.1. Evolutionary Algorithms

Evolutionary algorithms, also known as Evolutionary Computation (EC), the optimization tool used in this work, use computational models of evolutionary processes in the design and implementation of computer-based problem solving. A general definition and classification of these evolutionary techniques is given in Bäck [23]. He defines an EA as a search and optimization algorithm, inspired by the process of natural evolution, which maintains a population of structures that evolve according to the rules of selection and other operators such as recombination and mutation. Here, the structure of all evolution-based algorithms is shown in Algorithm 1.Algorithm 1:Evolution-based algorithm.
Program
t
=
0
Create Initial Population   P(t)
Evaluate Initial Population  P(t)
While (not termination_criterion) do
t=t+1
Select Individuals for Reproduction  P(t)  from  P(t-1)
Alter   P(t)
Evaluate New Population  P(t)
endIn a similar way to that of natural evolution and heredity, these algorithms work on a population ofN individuals P(t)={x1t,…,xNt}, representing search points in the space of potential solutions of a given problem. How well each individual xit adapts each generation t to the problem under investigation is provided by a quality measure called the “fitness”. The population evolves, generation by generation, towards better regions of the search space by means of genetic processes, such as selection, recombination, and mutation. The selection process uses the fitness measure to choose individuals of the previous generation (P(t-1)) to be reproduced, favoring those of higher quality. The recombination operation promotes the exchange of genetic information between parent individuals, thereby producing descendants. The mutation operation alters the genetic information by introducing some changes into the population. The evaluation process is repeated until a predefined termination criterion is met, or alternatively, until a maximum number of generation (iterations) is reached. This artificial evolution process is the foundation of the evolution-based algorithms used in this work, genetic programming.


### 3.2. Genetic Programming Algorithm

A typical genetic programming algorithm consists of a set of functions, which can involve arithmetic operators(+,-,*,/,…), transcendental functions (sin, cos, tan,…, ln, exp,…), even relational operators (>,<,=) or conditional operators (IF), and a terminal set with variables and constants (x1,x2,x3,…xn). An initial population is randomly created with a number of parse-tree individuals composed of nodes (operators plus variables, and constants) previously defined according to the problem domain (an example of GP individual is given in Figure 2). An objective function must be defined to evaluate the fitness of each individual (in this case each individual will be a resultant model or program of the random combination of nodes). Selection, crossover, and mutation operators are then applied to the best individuals, and a new population is created. The whole process is repeated until the given generation number is reached (Cramer [24], Koza [25]).Figure 2
A mathematical expression represented hierarchically by its parse tree.


### 3.3. Brief Description of the Physical Phenomena and Their Related Variables

The water from a river is in a constant heat exchange with its surroundings: the atmosphere and the river bed. This process may reach equilibrium so that the heat lost by the water equals that which is absorbed. Normally, the water temperature increases throughout the river in a natural state as the altitude decreases. To this spatial variation a double temporal variation is superimposed. In a river reach temperature varies following both a daily and an annual cycle.In the study performed by Val [19], an analysis of five kilometers of the Ebro River was performed, in a section downstream of the Flix hydroelectric center; in this reach, hourly temperature measurement data are available for different sections. It was observed that during the summer a 9°C difference may exist between the Flix Central site and the temperature before the dams. Additionally, downstream of Flix Central, the water temperature recovers, trying to reach thermal equilibrium with its surroundings. To estimate the heat that is absorbed by the river water as it progresses naturally through a certain reach, and its corresponding temperature variation, an energy balance is established between the caloric energy received and the caloric energy emitted by the water along that reach. This can be done based on the thermic balance presented by Edinger et al. [26]. This balance can be expressed as
(1)A=Hsn+Han-Hb-He-Hc+S,
where A is the total caloric power absorbed by water as it moves along a river reach, by square meter of free surface, measured in W/m2. This is the result of the balance of the different heat inputs and outputs for water as it moves along the reach. Hsn is the net (incident minus reflected) total shortwave solar radiation (direct plus diffused) that is absorbed by the water by square meter of free surface, measured in W/m2. This is a function of the incident solar radiation rs and the reflected rr, which is proportional to rs, and this proportionality is given by the constant α which is also  known as the albedo. Han is the net longwave atmospheric radiation (incident minus reflected) absorbed by water by free surface square meter, measured in W/m2. Hb is the longwave radiation emitted by water by free surface square meter, measured in W/m2, determined as a function of average surface water temperature, Tw. He is the heat lost through evaporation by free surface square meter, measured in W/m2, determined as a function of the wind velocity, vv, the vapor pressure of saturation, and the air’s vapor pressure. Relative humidity hr is also a variable that affects the water-atmosphere heat exchange. Hc is the sensitive heat interchanged by conduction between the atmosphere and water by free surface square meter, measured in W/m2, dependent upon the air temperature Ta and that of the water Tw. S is the heat exchanged with the substrate (river bed) by square meter of river reach.The heat stored by a water mass as it moves along a river stretch of longitudeL is estimated by A=4187(ΔTQCeρ/LB), where A is the caloric power absorbed by water, in (W/m2), ΔT is the water temperature increment, in (°C), Q is the circulating flow, in (m3/s), Ce is the specific heat of water in (Kcal/°CKg), ρ is the density of water, in (Kg/m3), L is the longitude of the studied reach, in (m), and Bw is the effective width of the river, in (m).On the other hand, through an analysis of the historical behavior of the time variation of water temperature during consecutive years, similar results were observed, both in the cyclical variation and in the tendency to increase or decrease. This leads to an expectation of a correlation between the temperature variation in yeari and the temperature of previous years.This background described led to the choice of the measured variables which were used in the prediction model.Additionally, when physical variables are used to be fitted by means of genetic programming, several questions about the dimensionality of the problem could be made. But this problem can be solved considering the possible existence of dimension in the obtained constants of the calculated model. New physical interpretations of the related variables can be done by analyzing the model terms.In this document, for simplicity, only four arithmetic operators were considered:FS={+,-,*,/}.Twelve independent variables, one dependent variable, and a vector of real constants were selected. Thus, in the nonstandardized case the terminal set is(2)
T
S
=
{
h
r
98
,
T
a
98
,
v
v
98
,
r
s
98
,
h
r
99
,
T
a
99
,
v
v
99
,
r
s
99
,
h
r
2000
,
T
a
2000
,
v
v
2000
,
r
s
2000
,
T
w
2000
,
b
}
,
where hr98,hr99, and hr2000 are the hourly average relative humidity values recorded in the years 1998 to 2000, in decimals, Ta98,Ta99, and Ta2000 are average air temperature values from years 1998, 1999, and 2000, in °C, vv98,vv99, and vv2000 are the average wind speeds from years 1998, 1999, and 2000, in m/s, rs98,rs99, and rs2000 are average solar radiations from years 1998, 1999, and 2000, in W/m2, Tw2000 is the hourly average water temperature measured from year 2000, in °C, and b is a real constant vector.Tests were made with one hour, daily and weekly averaged water temperatures.In the standardized case all the last variables are dimensionless.


### 3.4. Objective Function

The objective function considered in this problem was defined as the minimization of the mean square error between calculated and measured data:(3)
F
O
=
Min
[
∑
i
=
1
n
(
T
w
i
-
T
w
1
i
)
2
n
]
,
where Tw measured data, Tw1i calculated data, and i counter from 1 to data number n.The genetic programming algorithm was implemented in MATLAB (The MathWorks [27]).


### 3.5. Standardization

The variables were standardized by subtracting the mean and dividing by the standard deviation:(4)
Z
=
T
w
-
T
̅
w
σ
T
w
,
where Z is the standardized variable, dimensionless; Tw is the variable before standardization; T̅w is the mean value of Tw, with the same units as Tw (the arithmetic average was used); σTw is the standard deviation of Tw, with the same units as Tw.Variables with large variances tend to have a larger effect on the resulting model than those with small variances that can be also relevant. Standardized variables can then be advantageous in that their means are zero and their second moments (variances) are one.


### 3.6. Input Data

Meteorological and water temperature data were taken in gauging stations installed in the Ebro River. Data consist of 10-minute averages of measurements taken every minute. Water temperatures were measured just downstream of the hydroelectric power plant of Flix. The meteorological variables were measured at the measuring station located on the Ribarroja Dam. The hourly average was calculated for all the variables and taken as input data: relative humidity (hr), air temperature (Ta), wind speed (vv), and solar radiation (rs) as independent variables and water temperature (Tw) as the dependent variable.The first experiment was carried out with the original data, and the second one with the standardized ones. GP parameter settings for both experiments are shown in Table1Table 1
GP parameter settings.
Parameter
Value
Number of individuals
250
Maximum number of nodes
30
Maximum number of generations
3000
Cross probability
0.9
Mutation probability
0.09
Node mutation probability
0.03


### 3.7. Model Linearity

In order to validate the applicability of the method, the correlation coefficient between measured and calculated data was obtained:(5)
r
T
w
T
w
1
=
Cov
(
T
w
,
T
w
1
)
σ
T
w
σ
T
w
1
,
Cov
(
T
w
,
T
w
1
)
=
1
n
∑
i
=
1
n
(
T
w
i
-
T
̅
w
)
(
T
w
1
i
-
T
̅
w
1
)
,
where Cov(Tw,Tw1) is the covariance between the variables Tw and Tw1;σTw,σTw1 are the standard deviation of Tw and Tw1, respectively.


## 3.1. Evolutionary Algorithms

Evolutionary algorithms, also known as Evolutionary Computation (EC), the optimization tool used in this work, use computational models of evolutionary processes in the design and implementation of computer-based problem solving. A general definition and classification of these evolutionary techniques is given in Bäck [23]. He defines an EA as a search and optimization algorithm, inspired by the process of natural evolution, which maintains a population of structures that evolve according to the rules of selection and other operators such as recombination and mutation. Here, the structure of all evolution-based algorithms is shown in Algorithm 1.Algorithm 1:Evolution-based algorithm.
Program
t
=
0
Create Initial Population   P(t)
Evaluate Initial Population  P(t)
While (not termination_criterion) do
t=t+1
Select Individuals for Reproduction  P(t)  from  P(t-1)
Alter   P(t)
Evaluate New Population  P(t)
endIn a similar way to that of natural evolution and heredity, these algorithms work on a population ofN individuals P(t)={x1t,…,xNt}, representing search points in the space of potential solutions of a given problem. How well each individual xit adapts each generation t to the problem under investigation is provided by a quality measure called the “fitness”. The population evolves, generation by generation, towards better regions of the search space by means of genetic processes, such as selection, recombination, and mutation. The selection process uses the fitness measure to choose individuals of the previous generation (P(t-1)) to be reproduced, favoring those of higher quality. The recombination operation promotes the exchange of genetic information between parent individuals, thereby producing descendants. The mutation operation alters the genetic information by introducing some changes into the population. The evaluation process is repeated until a predefined termination criterion is met, or alternatively, until a maximum number of generation (iterations) is reached. This artificial evolution process is the foundation of the evolution-based algorithms used in this work, genetic programming.


## 3.2. Genetic Programming Algorithm

A typical genetic programming algorithm consists of a set of functions, which can involve arithmetic operators(+,-,*,/,…), transcendental functions (sin, cos, tan,…, ln, exp,…), even relational operators (>,<,=) or conditional operators (IF), and a terminal set with variables and constants (x1,x2,x3,…xn). An initial population is randomly created with a number of parse-tree individuals composed of nodes (operators plus variables, and constants) previously defined according to the problem domain (an example of GP individual is given in Figure 2). An objective function must be defined to evaluate the fitness of each individual (in this case each individual will be a resultant model or program of the random combination of nodes). Selection, crossover, and mutation operators are then applied to the best individuals, and a new population is created. The whole process is repeated until the given generation number is reached (Cramer [24], Koza [25]).Figure 2
A mathematical expression represented hierarchically by its parse tree.


## 3.3. Brief Description of the Physical Phenomena and Their Related Variables

The water from a river is in a constant heat exchange with its surroundings: the atmosphere and the river bed. This process may reach equilibrium so that the heat lost by the water equals that which is absorbed. Normally, the water temperature increases throughout the river in a natural state as the altitude decreases. To this spatial variation a double temporal variation is superimposed. In a river reach temperature varies following both a daily and an annual cycle.In the study performed by Val [19], an analysis of five kilometers of the Ebro River was performed, in a section downstream of the Flix hydroelectric center; in this reach, hourly temperature measurement data are available for different sections. It was observed that during the summer a 9°C difference may exist between the Flix Central site and the temperature before the dams. Additionally, downstream of Flix Central, the water temperature recovers, trying to reach thermal equilibrium with its surroundings. To estimate the heat that is absorbed by the river water as it progresses naturally through a certain reach, and its corresponding temperature variation, an energy balance is established between the caloric energy received and the caloric energy emitted by the water along that reach. This can be done based on the thermic balance presented by Edinger et al. [26]. This balance can be expressed as
(1)A=Hsn+Han-Hb-He-Hc+S,
where A is the total caloric power absorbed by water as it moves along a river reach, by square meter of free surface, measured in W/m2. This is the result of the balance of the different heat inputs and outputs for water as it moves along the reach. Hsn is the net (incident minus reflected) total shortwave solar radiation (direct plus diffused) that is absorbed by the water by square meter of free surface, measured in W/m2. This is a function of the incident solar radiation rs and the reflected rr, which is proportional to rs, and this proportionality is given by the constant α which is also  known as the albedo. Han is the net longwave atmospheric radiation (incident minus reflected) absorbed by water by free surface square meter, measured in W/m2. Hb is the longwave radiation emitted by water by free surface square meter, measured in W/m2, determined as a function of average surface water temperature, Tw. He is the heat lost through evaporation by free surface square meter, measured in W/m2, determined as a function of the wind velocity, vv, the vapor pressure of saturation, and the air’s vapor pressure. Relative humidity hr is also a variable that affects the water-atmosphere heat exchange. Hc is the sensitive heat interchanged by conduction between the atmosphere and water by free surface square meter, measured in W/m2, dependent upon the air temperature Ta and that of the water Tw. S is the heat exchanged with the substrate (river bed) by square meter of river reach.The heat stored by a water mass as it moves along a river stretch of longitudeL is estimated by A=4187(ΔTQCeρ/LB), where A is the caloric power absorbed by water, in (W/m2), ΔT is the water temperature increment, in (°C), Q is the circulating flow, in (m3/s), Ce is the specific heat of water in (Kcal/°CKg), ρ is the density of water, in (Kg/m3), L is the longitude of the studied reach, in (m), and Bw is the effective width of the river, in (m).On the other hand, through an analysis of the historical behavior of the time variation of water temperature during consecutive years, similar results were observed, both in the cyclical variation and in the tendency to increase or decrease. This leads to an expectation of a correlation between the temperature variation in yeari and the temperature of previous years.This background described led to the choice of the measured variables which were used in the prediction model.Additionally, when physical variables are used to be fitted by means of genetic programming, several questions about the dimensionality of the problem could be made. But this problem can be solved considering the possible existence of dimension in the obtained constants of the calculated model. New physical interpretations of the related variables can be done by analyzing the model terms.In this document, for simplicity, only four arithmetic operators were considered:FS={+,-,*,/}.Twelve independent variables, one dependent variable, and a vector of real constants were selected. Thus, in the nonstandardized case the terminal set is(2)
T
S
=
{
h
r
98
,
T
a
98
,
v
v
98
,
r
s
98
,
h
r
99
,
T
a
99
,
v
v
99
,
r
s
99
,
h
r
2000
,
T
a
2000
,
v
v
2000
,
r
s
2000
,
T
w
2000
,
b
}
,
where hr98,hr99, and hr2000 are the hourly average relative humidity values recorded in the years 1998 to 2000, in decimals, Ta98,Ta99, and Ta2000 are average air temperature values from years 1998, 1999, and 2000, in °C, vv98,vv99, and vv2000 are the average wind speeds from years 1998, 1999, and 2000, in m/s, rs98,rs99, and rs2000 are average solar radiations from years 1998, 1999, and 2000, in W/m2, Tw2000 is the hourly average water temperature measured from year 2000, in °C, and b is a real constant vector.Tests were made with one hour, daily and weekly averaged water temperatures.In the standardized case all the last variables are dimensionless.


## 3.4. Objective Function

The objective function considered in this problem was defined as the minimization of the mean square error between calculated and measured data:(3)
F
O
=
Min
[
∑
i
=
1
n
(
T
w
i
-
T
w
1
i
)
2
n
]
,
where Tw measured data, Tw1i calculated data, and i counter from 1 to data number n.The genetic programming algorithm was implemented in MATLAB (The MathWorks [27]).


## 3.5. Standardization

The variables were standardized by subtracting the mean and dividing by the standard deviation:(4)
Z
=
T
w
-
T
̅
w
σ
T
w
,
where Z is the standardized variable, dimensionless; Tw is the variable before standardization; T̅w is the mean value of Tw, with the same units as Tw (the arithmetic average was used); σTw is the standard deviation of Tw, with the same units as Tw.Variables with large variances tend to have a larger effect on the resulting model than those with small variances that can be also relevant. Standardized variables can then be advantageous in that their means are zero and their second moments (variances) are one.


## 3.6. Input Data

Meteorological and water temperature data were taken in gauging stations installed in the Ebro River. Data consist of 10-minute averages of measurements taken every minute. Water temperatures were measured just downstream of the hydroelectric power plant of Flix. The meteorological variables were measured at the measuring station located on the Ribarroja Dam. The hourly average was calculated for all the variables and taken as input data: relative humidity (hr), air temperature (Ta), wind speed (vv), and solar radiation (rs) as independent variables and water temperature (Tw) as the dependent variable.The first experiment was carried out with the original data, and the second one with the standardized ones. GP parameter settings for both experiments are shown in Table1Table 1
GP parameter settings.
Parameter
Value
Number of individuals
250
Maximum number of nodes
30
Maximum number of generations
3000
Cross probability
0.9
Mutation probability
0.09
Node mutation probability
0.03


## 3.7. Model Linearity

In order to validate the applicability of the method, the correlation coefficient between measured and calculated data was obtained:(5)
r
T
w
T
w
1
=
Cov
(
T
w
,
T
w
1
)
σ
T
w
σ
T
w
1
,
Cov
(
T
w
,
T
w
1
)
=
1
n
∑
i
=
1
n
(
T
w
i
-
T
̅
w
)
(
T
w
1
i
-
T
̅
w
1
)
,
where Cov(Tw,Tw1) is the covariance between the variables Tw and Tw1;σTw,σTw1 are the standard deviation of Tw and Tw1, respectively.


## 4. Results and Discussion

### 4.1. One-Hour Average Data

The genetic programming algorithm tendency is to produce relatively simple models. The equations produced in both experiments were(6)
T
w
1
2000
=
T
a
99
h
r
99
+
2
h
r
99
+
v
v
98
+
v
v
2000
T
a
99
+
h
r
2000
+
0.6776
+
1.3445
,
(7)
T
w
1
200
0
z
=
0.4732
T
a
98
+
0.6409
T
a
99
+
0.0321
h
r
98
+
0.2316
h
r
99
-
0.2366
r
s
98
,
respectively, where Tw12000 is the hourly average water temperature value estimated in 2000, in °C, and the prefix z indicates a standardized variable.In order to getTw2000 values, an inverse standardization process should be performed:(8)
T
w
1
200
0
z
=
σ
̃
w
2000
(
0.4732
T
a
98
+
0.6409
T
a
99
+
0.0321
h
r
98
+
0.2316
h
r
99
-
0.2366
r
s
98
)
+
T
̃
w
2000
.For forecasting purposes, mean and standard deviations were estimated as follows:(9)
T
̃
w
2000
=
(
T
̅
w
98
+
T
̅
w
99
2
)
,
(10)
σ
̅
̃
w
2000
=
(
σ
w
98
+
σ
w
99
2
)
,
where T̃w2000 is the estimator of mean water temperature in 2000, in °C; T̅w98 is the water temperature in 1998, in °C; T̅w99 is the water temperature in 1999, in °C; σ̅̃w2000 is the estimator of standard deviation of water temperature in 2000, in °C; σw98 is the standard deviation of water temperature in 1998, in °C; σw99 represents the standard deviation of water temperature in 1999, in °C. Table 2 shows the mean square error (MSE) obtained with both models.Table 2
Mean square error values.
Equation
MSE, °C
(6)
9.4336
(8)
6.4763The mean (μr) and the standard deviation (σr) of the residuals, calculated as the difference between measured and calculated water temperatures, appear in Table 3. The measured and calculated data, including their differences for both experiments, are shown in Figures 3 and 4.Table 3
Statistics of residuals.
Equation
μ
r (°C)
σ
r (°C)
(6)
-
0.0004
3.0716
(8)
0.0230
2.5449Figure 3
Water temperature values and residuals, experiment without standardization (hourly average values).Figure 4
Water temperature values and residuals, experiment with standardization (hourly average values).In Figures5 and 6, the measured and calculated data with (6) and (8) are plotted against the identity function to obtain the correlation coefficient (rTw,Tw1), checking the linearity in the fitting. Results given by Figures 3–6 show an improvement in calculated data when standardization is applied; residuals are slightly reduced, fluctuations become softer, and this is verified by the correlation coefficient. The mean square error is reduced in about 30%, and there is less data dispersion (standard deviation of residuals decreases 17%).Figure 5
Comparison between measured and estimated data (6), correlation coefficient rTw,Tw1=0.82.Figure 6
Comparison between measured and estimated data (8), correlation coefficient rTw,Tw1=0.88.


### 4.2. Daily Average Data

In this case, the equations obtained without and with standardization were as follows:(11)
T
w
12000
=
T
a
98
+
T
a
2000
T
a
98
+
r
s
98
(
T
a
2000
-
2
r
s
98
)
h
r
98
T
a
2000
/
v
v
2000
2
T
a
98
,
(12)
T
w
1
200
0
z
=
0.5018
T
a
98
z
+
0.4982
T
a
99
z
-
0.2108
r
s
98
z
-
0.1195
v
v
99
z
+
0.1195
v
v
200
0
z
-
0.1195
h
r
200
0
z
,
where Tw12000 is the daily average water temperature value estimated in 2000, in °C; hr98, is the daily average relative humidity values recorded in 1998, in decimals; Ta98andTa99 are the daily average air temperatures of 1998 and 1999 in °C; rs98 is the daily average solar radiation of 1998, in °C; the prefix z indicates a standardized variable.By applying an inverse standardization process,(13)
T
w
1
2000
=
σ
T
w
2000
T
w
1
2000
z
+
μ
T
w
2000
.In (13), data from 2000 are estimated according to (9) and (10), but considering daily measurements. The mean square errors (MSEs) obtained by using (11) and (13) are detailed on Table 4. The mean (μr) and the standard deviation of residuals (σr) of this experiment appear in Table 5.Table 4
Mean square error values. Daily average data.
Equation
MSE, °C
(11)
8.279
(13)
4.978Table 5
Statistics of residuals. Daily average data.
Equation
μ
r (°C)
σ
r (°C)
(11)
0.0762
2.8802
(13)
0.0213
2.2342Water temperature variations against time and the obtained differences are plotted on Figures7 and 8. Figures 9 and 10 show a comparison between measured and calculated daily average water temperatures with respect to the identity function. Results for daily analyses report a reduction of nearly 40% in mean square error with the equation obtained using standardized data. In this case the standard deviation of residuals is also smaller (12% lower than using nonstandardization). Figure 11 shows an example of the performance of the best individual in each generation when the genetic programming algorithm was applied.Figure 7
Water temperature values and residuals, experiment without standardization (daily average values).Figure 8
Water temperature values and residuals, experiment with standardization (daily average values).Figure 9
Comparison between measured and estimated data (11), correlation coefficient rTw,Tw1=0.8939.Figure 10
Comparison between measured and estimated data (13), correlation coefficient rTw,Tw1=0.9091.Figure 11
Convergence of a genetic programming run.


### 4.3. Weekly Average Data

In this last experiment, the equations obtained without and with standardization were(14)
T
w
1
2000
=
2
h
r
98
-
v
v
99
-
1.4558
v
v
2000
+
T
a
98
+
(
T
a
2000
/
(
T
a
99
-
v
v
98
-
v
v
99
-
v
v
2000
+
h
r
2000
)
)
+
v
v
98
v
v
2000
,
(15)
T
w
12000
z
=
0.2962
T
a
98
+
0.6819
T
a
99
+
0.6397
T
a
2000
-
0.2668
r
s
98
-
0.3215
r
s
99
-
0.3852
r
s
98
T
a
2000
+
0.3852
r
s
98
r
s
99
-
0.0928
,
respectively, where Tw12000 is the weekly average water temperature value estimated in 2000, in °C; hr98 and hr2000 are the weekly average relative humidity values recorded in 1998 and 2000, in decimals; Ta98,Ta99, and Ta2000 are the weekly average air temperatures of 1998, 1999, and 2000, in °C; vv98,vv99, and vv2000 are the weekly average wind speeds from years 1998, 1999, and 2000, in m/s; rs98 and rs99, are the weekly average solar radiation values of 1998 and 1999, in W/m2; the prefix z indicates standardized variable.Equation (15) must be nonstandardized to get the average weekly temperature approach:(16)
T
w
1
2000
=
σ
T
w
2000
T
w
1
2000
z
+
μ
T
w
2000
.Mean square errors and statistics of residuals appear in Tables6 and 7. Figures 12, 13, 14 and 15 show the behavior of water temperature in this weekly analysis.Table 6
Mean square error values. Weekly average data.
Equation
MSE, °C
(14)
4.538
(16)
2.176Table 7
Statistics of the residuals. Weekly average data.
Equation
μ
r (°C)
σ
r (°C)
(14)
0.0186
2.1509
(16)
0.0239
1.4892Figure 12
Water temperature values and residuals, experiment without standardization (weekly average values).Figure 13
Water temperature values and residuals, experiment with standardization (weekly average values).Figure 14
Comparison between measured and estimated data (14), correlation coefficient rTw,Tw1=0.9241.Figure 15
Comparison between measured and estimated data (16), correlation coefficient rTw,Tw1=0.9612.The results obtained for the weekly analysis show a reduction of 52% in the mean square error when data are previously standardized, and of about 31% reduction in the standard deviation of residuals. The correlation coefficient is also close to one.


## 4.1. One-Hour Average Data

The genetic programming algorithm tendency is to produce relatively simple models. The equations produced in both experiments were(6)
T
w
1
2000
=
T
a
99
h
r
99
+
2
h
r
99
+
v
v
98
+
v
v
2000
T
a
99
+
h
r
2000
+
0.6776
+
1.3445
,
(7)
T
w
1
200
0
z
=
0.4732
T
a
98
+
0.6409
T
a
99
+
0.0321
h
r
98
+
0.2316
h
r
99
-
0.2366
r
s
98
,
respectively, where Tw12000 is the hourly average water temperature value estimated in 2000, in °C, and the prefix z indicates a standardized variable.In order to getTw2000 values, an inverse standardization process should be performed:(8)
T
w
1
200
0
z
=
σ
̃
w
2000
(
0.4732
T
a
98
+
0.6409
T
a
99
+
0.0321
h
r
98
+
0.2316
h
r
99
-
0.2366
r
s
98
)
+
T
̃
w
2000
.For forecasting purposes, mean and standard deviations were estimated as follows:(9)
T
̃
w
2000
=
(
T
̅
w
98
+
T
̅
w
99
2
)
,
(10)
σ
̅
̃
w
2000
=
(
σ
w
98
+
σ
w
99
2
)
,
where T̃w2000 is the estimator of mean water temperature in 2000, in °C; T̅w98 is the water temperature in 1998, in °C; T̅w99 is the water temperature in 1999, in °C; σ̅̃w2000 is the estimator of standard deviation of water temperature in 2000, in °C; σw98 is the standard deviation of water temperature in 1998, in °C; σw99 represents the standard deviation of water temperature in 1999, in °C. Table 2 shows the mean square error (MSE) obtained with both models.Table 2
Mean square error values.
Equation
MSE, °C
(6)
9.4336
(8)
6.4763The mean (μr) and the standard deviation (σr) of the residuals, calculated as the difference between measured and calculated water temperatures, appear in Table 3. The measured and calculated data, including their differences for both experiments, are shown in Figures 3 and 4.Table 3
Statistics of residuals.
Equation
μ
r (°C)
σ
r (°C)
(6)
-
0.0004
3.0716
(8)
0.0230
2.5449Figure 3
Water temperature values and residuals, experiment without standardization (hourly average values).Figure 4
Water temperature values and residuals, experiment with standardization (hourly average values).In Figures5 and 6, the measured and calculated data with (6) and (8) are plotted against the identity function to obtain the correlation coefficient (rTw,Tw1), checking the linearity in the fitting. Results given by Figures 3–6 show an improvement in calculated data when standardization is applied; residuals are slightly reduced, fluctuations become softer, and this is verified by the correlation coefficient. The mean square error is reduced in about 30%, and there is less data dispersion (standard deviation of residuals decreases 17%).Figure 5
Comparison between measured and estimated data (6), correlation coefficient rTw,Tw1=0.82.Figure 6
Comparison between measured and estimated data (8), correlation coefficient rTw,Tw1=0.88.


## 4.2. Daily Average Data

In this case, the equations obtained without and with standardization were as follows:(11)
T
w
12000
=
T
a
98
+
T
a
2000
T
a
98
+
r
s
98
(
T
a
2000
-
2
r
s
98
)
h
r
98
T
a
2000
/
v
v
2000
2
T
a
98
,
(12)
T
w
1
200
0
z
=
0.5018
T
a
98
z
+
0.4982
T
a
99
z
-
0.2108
r
s
98
z
-
0.1195
v
v
99
z
+
0.1195
v
v
200
0
z
-
0.1195
h
r
200
0
z
,
where Tw12000 is the daily average water temperature value estimated in 2000, in °C; hr98, is the daily average relative humidity values recorded in 1998, in decimals; Ta98andTa99 are the daily average air temperatures of 1998 and 1999 in °C; rs98 is the daily average solar radiation of 1998, in °C; the prefix z indicates a standardized variable.By applying an inverse standardization process,(13)
T
w
1
2000
=
σ
T
w
2000
T
w
1
2000
z
+
μ
T
w
2000
.In (13), data from 2000 are estimated according to (9) and (10), but considering daily measurements. The mean square errors (MSEs) obtained by using (11) and (13) are detailed on Table 4. The mean (μr) and the standard deviation of residuals (σr) of this experiment appear in Table 5.Table 4
Mean square error values. Daily average data.
Equation
MSE, °C
(11)
8.279
(13)
4.978Table 5
Statistics of residuals. Daily average data.
Equation
μ
r (°C)
σ
r (°C)
(11)
0.0762
2.8802
(13)
0.0213
2.2342Water temperature variations against time and the obtained differences are plotted on Figures7 and 8. Figures 9 and 10 show a comparison between measured and calculated daily average water temperatures with respect to the identity function. Results for daily analyses report a reduction of nearly 40% in mean square error with the equation obtained using standardized data. In this case the standard deviation of residuals is also smaller (12% lower than using nonstandardization). Figure 11 shows an example of the performance of the best individual in each generation when the genetic programming algorithm was applied.Figure 7
Water temperature values and residuals, experiment without standardization (daily average values).Figure 8
Water temperature values and residuals, experiment with standardization (daily average values).Figure 9
Comparison between measured and estimated data (11), correlation coefficient rTw,Tw1=0.8939.Figure 10
Comparison between measured and estimated data (13), correlation coefficient rTw,Tw1=0.9091.Figure 11
Convergence of a genetic programming run.


## 4.3. Weekly Average Data

In this last experiment, the equations obtained without and with standardization were(14)
T
w
1
2000
=
2
h
r
98
-
v
v
99
-
1.4558
v
v
2000
+
T
a
98
+
(
T
a
2000
/
(
T
a
99
-
v
v
98
-
v
v
99
-
v
v
2000
+
h
r
2000
)
)
+
v
v
98
v
v
2000
,
(15)
T
w
12000
z
=
0.2962
T
a
98
+
0.6819
T
a
99
+
0.6397
T
a
2000
-
0.2668
r
s
98
-
0.3215
r
s
99
-
0.3852
r
s
98
T
a
2000
+
0.3852
r
s
98
r
s
99
-
0.0928
,
respectively, where Tw12000 is the weekly average water temperature value estimated in 2000, in °C; hr98 and hr2000 are the weekly average relative humidity values recorded in 1998 and 2000, in decimals; Ta98,Ta99, and Ta2000 are the weekly average air temperatures of 1998, 1999, and 2000, in °C; vv98,vv99, and vv2000 are the weekly average wind speeds from years 1998, 1999, and 2000, in m/s; rs98 and rs99, are the weekly average solar radiation values of 1998 and 1999, in W/m2; the prefix z indicates standardized variable.Equation (15) must be nonstandardized to get the average weekly temperature approach:(16)
T
w
1
2000
=
σ
T
w
2000
T
w
1
2000
z
+
μ
T
w
2000
.Mean square errors and statistics of residuals appear in Tables6 and 7. Figures 12, 13, 14 and 15 show the behavior of water temperature in this weekly analysis.Table 6
Mean square error values. Weekly average data.
Equation
MSE, °C
(14)
4.538
(16)
2.176Table 7
Statistics of the residuals. Weekly average data.
Equation
μ
r (°C)
σ
r (°C)
(14)
0.0186
2.1509
(16)
0.0239
1.4892Figure 12
Water temperature values and residuals, experiment without standardization (weekly average values).Figure 13
Water temperature values and residuals, experiment with standardization (weekly average values).Figure 14
Comparison between measured and estimated data (14), correlation coefficient rTw,Tw1=0.9241.Figure 15
Comparison between measured and estimated data (16), correlation coefficient rTw,Tw1=0.9612.The results obtained for the weekly analysis show a reduction of 52% in the mean square error when data are previously standardized, and of about 31% reduction in the standard deviation of residuals. The correlation coefficient is also close to one.


## 5. Getting the Daily Water Temperature for the Year 2004

The climatic daily data measured from 2002 to 2003 in Flix and Miravet stations were taken to estimate water temperature in the year 2004, in order to check the accuracy of models given by (11), (12), and (13). The climatic data for 2004 needed by the models were assumed as the average of the years 2002 and 2003. The average water temperature for 2004 was assumed 15°C with a standard deviation of 5°C.A mean square error of 49.549 and a correlation coefficient of 0.6744 were obtained by applying (11) as it is shown in Figures 16 and 17, with an important variation in the residuals; by contrast, with (13) that demands standardized data, a mean square error of 13.027 and a correlation coefficient of 0.7445 were obtained; the residuals took values between -7°C and almost 8°C (Figures 18 and 19). Therefore, this last model had a better performance in daily data, in this year.Figure 16
Measured and predicted water temperature for 2004, model without standardization (daily average values).Figure 17
Comparison between measured and estimated data (11), correlation coefficient rTw,Tw1=0.6744.Figure 18
Measured and predicted water temperature for 2004, model with standardization (daily average values).Figure 19
Comparison between measured and estimated data (13), correlation coefficient rTw,Tw1=0.7445.With both equations very big residuals for water temperature were obtained for some days of the estimated year.


## 6. Conclusions

Different models which allow the estimation of water temperature in the Ebro River in a given year were obtained, taking into account climatic variables measured in the same year, but also considering their variability in two previous years, in an attempt to explain the possible evolution of the water temperature behavior.The GP algorithm considered as input hourly, daily, and weekly average measured data without and with standardization, in order to analyze the resulting equations when the shape of the input data varies from one form to another.Intrinsically, measured data of water temperature and climatic variables have more oscillations in hourly average data than in daily or weekly average data. Particularly, in the experiment using hourly data, the GP algorithm amplifies the water temperature oscillations, probably because in the actual physical process, the oscillations of the climatic variables are filtered. Nevertheless, by using standardized data, mean square errors were lower than those without standardization, and a lower dispersion in data could be obtained. Similar situations occurred in the case of daily data.According to the mean square errors, the standard deviation of residuals, and the correlation coefficient, when weekly data were considered, GP algorithms produced models more capable to follow the behavior of water temperature. This was particularly true for those models obtained with standardized data.Therefore equations such as those obtained herein can be used as a first approximation to predict changes in water temperature when changes occur in climatic variables such as air temperature, wind speed, relative humidity, and solar radiation, all of which affect the water temperature as well as the physical and chemical water conditions, including the flora and fauna of a river.When the models for daily data were applied in another year, lower correlations between measured and predicted data were obtained, particularly with the model that does not take into account standardized variables.According to these results, it is feasible to obtain some improvements in generating water temperature models by means of genetic programming, when the standardization process is incorporated.Results also show limits on the models developed herein; the models produced oscillations in the water temperatures that do not correspond to the measured data; the results of forecasting from 2004 are only fair. That is probably due to the fact that some variables included in the physical phenomena are eliminated, and the filtering that occurs in nature is not reproduced; nevertheless, these results are considered useful as a first-order explanation of a complex process. However future work is suggested to compare the proposed method with physically based ones.



---

*Source: 353960-2009-09-10.xml*