Chapter 1: INTRODUCTION - Department of Electrical...
Transcript of Chapter 1: INTRODUCTION - Department of Electrical...
1
Chapter 1: INTRODUCTION
1.1: Overview
A reliable and continuous supply of electrical energy is necessary for the functioning of
today’s complex society. Because of the combination of increasing consumption and
obstruction of various kinds, and the extension of existing electrical transmission
networks and these power systems are operated closer and closer to their limits. It is
known for all that electrical energy cannot be stored efficiently, due to this factor that the
electrical load could be controlled by utilities only to a very small extend. The electric
load forecast is an important topic for power generation and transmission. This project is
based on the long term electric load forecasting using artificial intelligent techniques-
NEURAL NETWORKS. For comparison and performance evaluation forecasted electric
load based on econometric model from the Kenya Power And lighting company was
used.
Long term load forecasting is the prediction of future electric load demand for the
next 20 years. Because of the long duration of this forecast, it is much more difficult to
forecast off-peak load demand and so the main emphasis is on the annual peak system
load. Long term electric load forecasting is essential in determining the load growth in a
particular country. The peak load forecasted helps the power utilities in establishing
whether upgrades of a particular network need to be performed. The capacity in terms of
electrical power in that area may be exceeded thus making long term electric load
forecasting a key factor in planning of a utility. The key contribution of forecasters is
their knowledge of electricity consumers and understanding of the way they use
electricity and other competing energy forms. This problem gains special aspect in
developing countries such as Kenya, because of the high demand growth rate as well as
the wide differences in the modes and levels of consumption in the various regions in the
country.
2
Recently (June 6th 2008) the Kenyan Government launched an economic
blueprint dubbed “Kenya vision 2030” whose key aim is to put in place measures to
accelerate economic growth in the country.
1.2 Objectives of the project
In order to plan efficient operation and economical capital expansion of deregulated
electrical markets, the market owners should be able to anticipate the need of power
delivery, how much power must be delivered and where and when it will be needed. The
main objective of this project is to perform electric load forecast up to 2030.
The specific objectives of this project are:
• Capture data on various input variables
• Pre-process the data
• Create the Neural Network
• Train the Neural Network
• Test the Neural Network.
• Perform electric load forecast for each particular year from 2009
up to 2030
This project makes an estimate of the electric needs of Kenya by the year 2030.
The data generated as a result will be useful in future generation planning for the
country either from hydroelectricity or alternative sources of power. Therefore, load
forecast applications are of great importance. This information can be provided only by
electric load forecasting. Nowadays the load forecasting is done using ARTIFICIAL
NEURAL NETWORKS.
3
1.3: Plan of development
The following describes the layout of the thesis:
Chapter 2: This chapter contains a general discussion of load forecasting as well as
discussion of the factors that affect load demand. Artificial intelligent techniques-Neural
networks used for the load forecasting procedure are also discussed.
Chapter 3: The proposed AI technique (i.e. Artificial Neural Networks) is discussed in
detail. This chapter describes the components of an artificial neural network and explains
how they function.
Chapter 4: A long term electric load forecasting model based on ANN is developed and
for comparative purposes, K.P.L.Cs Econometric forecasted data is used. The simulation
results from these two models are analyzed and compared.
Chapter 5: Conclusions and recommendations based on the results obtained in chapter
four are made. An opportunity for further work is also proposed in this chapter.
4
Chapter 2: LITERATURE REVIEW
2.1 LOAD FORECASTING
Load forecasting is the prediction of future electrical demand. It is important since
electrical power generation requires efficient management. This is because the power
generated needs to be equal to that consumed. For the Kenyan power generating
companies to meet the requirements, it is necessary to predict or forecast the future
Electrical load requirements. The term load forecasting refers to the projected load
requirement determined using past knowledge to define future load in sufficient
quantitative detail [1]. Demand electric load prediction is an important aspect in
electricity planning [2] of electric utilities. It is a means of knowing how much power to
schedule for the future demand, useful in drawing up a feasibility report for power plants
and is also useful in determining whether the current capacity of the power stations or
sub-stations of a service area will be exceeded. The latter is usually determined when
the load demand is forecasted for a period longer than a year.
Load forecasting can be categorized into three important parts namely:
I. Short-term load forecasting.
II. Medium-term load forecasting.
III. Long-term load forecasting
In short-term load forecasting refers to a few minutes to a week forecast of electrical
demand. Medium-term load forecasting is usually from a week to a year ahead whilst
long-term load forecasting is for a longer duration which is from a year up to 20 years.
The forecast period mentioned above is not a definite period, some literature mention
that medium term is the period from six months to a year, and some say it is from a year
to five years into the future. The period varies from utility to utility and so for the
purpose of this project, a period from a week to less than a year will be referred to as
medium-term electric load forecasting.
5
The following section discuses the three types of forecasting:
2.1.1 SHORT TERM LOAD FORECASTING
The term short implies that forecast can be done for every hour, day, and week.
The forecast value is usually the total system load demand as well as the values of the
system load at different times of the day. Short-term load forecasting (STLF) is essential
for the economic generation dispatch of power systems. This means that power
generation can be planned according to the forecasted value decreasing the risk of
equipment failures such as transformer and transmission lines. The possibility of
blackouts occurring is also reduced as well as losses in revenue of power utilities.
The key objectives of this forecast are as follows:
• Provide load prediction for the basic generation scheduling.
• Supply timely dispatcher information based on the load predictions.
• Assist with the assessment of the security of the system at any particular time,
thereby improving the network reliability.
Short-term load forecasting helps to improve system reliability in that the system load
forecast that can be generated using short-term load forecasting is essential for the off-
line network analysis function, and for the detection of future conditions under which the
power system may be vulnerable. This helps the dispatcher to make informed decisions
and take the necessary actions. These actions may compromise of bringing peaking units
online load forecasting scheduling, switching operations so that the reliability of the
system is no hindered.
2.1.2: MEDIUM TERM LOAD FORECASTING
Medium –term load forecasting is predictions of demand for a week to a year in
the future. It is necessary for the maintenance and network development work performed
by power utilities. It involves the forecasting of systems load and sometimes bulk power
interchange levels. Peak load demand is the main focus in this forecast but off-peak
demand is also forecasted.
6
2.1.3: LONG TERM LOAD FORECASTING
This type of forecast is for much longer duration into the future. The forecast
period may last up to twenty years. Because of long duration of this forecast, it is much
more difficult to forecast off-peak load demand and so the main emphasis is on the
annual peak system load.
Long-term load forecasting is essential in determining the load growth of a particular
area. The peak load forecasted helps the power utilities in establishing whether upgrades
of particular networks need to be performed. The capacity in terms of electrical power in
that area may be exceeded thus making long term forecast, a key factor in planning
operations of a utility.
2.2 DISCUSSION OF LOAD FORECASTING
Load forecasting as a whole is a technique necessary for the reliability and adequate
functioning of the power system network. Each type of load forecast is essential. The
objective is to obtain an accurate load forecast but sometimes this is not always the case.
The subject of electric load forecasting accuracy will be discussed further at a later stage.
There are a number of factors affecting electric load demand that need to be considered
when trying to formulate a model for any of the three types of load forecasting. The
factors affecting each type of load forecast are different and they vary from utility to
utility as it is the utility that decides on the importance or the relevance of that particular
factor.
This leads to a discussion on the types of factors affecting electric load demand and the
types of load forecasts.
7
2.3 FACTORS AFFECTING ELECTRIC LOAD
Before a load forecast model can be developed, the forecaster needs to determine the
factors that affect the electric load demand in the particular areas that need to be
forecasted.
The factors that need to be considered are:
• Time of the day
• Day of the week
• Time of the year (including seasons, holidays, etc)
• Weather
• Customer class
• Demographic factors (Population, housing)
• Macroeconomic factors (GDP, CPI, HSI)
Customer classing is the division of load demand into groups that utilize power in the
same manner. This means that the load demand can be broken down into classes namely;
residential (domestic), commercial (banks, hotels, schools, etc), Industrial (sugar milling
companies, paper mills), mining (e.g. cement manufacturing plants), agricultural and
transport. The customer class defines the load profile, for example the power demand for
a residential class is not the same as that of an industrial class. Industries may require
more power because of equipment such as heavy duty motors that they use whereas the
appliances used by those of residential class do not draw as much power.
Other factors that affect electric load forecast are as follows
• Historical electric load
• Appliance sales
• Price of electricity
• Number of customers in the class
• The economic as well as demographic data.
These usually affect the medium and long-term forecasts.
8
The following are regarded as the most important factors.
1. WEATHER
Weather factors are as follows: Wind speed (this defines how cold people feel),
temperature, humidity, cloud cover and rainfall. There is a varying of load demand from
season to season influenced by the change in weather temperature; for example in Kenya
the load demand in summer is not as high as in winter because of increase in
temperature. In winter, people start using heating appliances in order to keep warm.
Lights come on earlier for a much longer period than in summer as the sun sets at an
earlier time.
There is a shift in the load peak-time as a result. It is difficult to incorporate weather
factors in the long-term forecasts because it is continually changing and there are no
long-term weather forecasts available. Short term forecasts take weather forecasts into
great considerations because they affect the daily load profile and this is necessary for
accurate forecasting. Medium-term electric load forecasting take weather into
consideration and the seasonal effects are accounted for in the model.
We can find that not all weather factors are important. Some are typically random during
a period of time, such as wind speed and thunderstorms. Also some factors are
interrelated. Among all those factors, temperature is the most important because it has
direct influence on many kind of electrical consumption, such as air conditioner, heater
and refrigerator. However, the leading weather influential factor for specific consumer
may be different.
2. ELECTRICITY PRICING
In general, this is a factor that has not been greatly used in the forecasting of load. Very
few models include this factor; because electricity prices vary depending on place and
time and consumers can adjust their consumption behavior according to the price of the
electricity.
9
3. ECONOMICAL OR ENVIROMENTAL
The economy has an effect on the electric demand patterns. The general trend has an
effect on the increase or decline of electricity consumed. This includes levels of
industrial growth activities, changes of farming sector, emergency of new industry,
service area demographics (rural, residential), Economic trends (recession or expansion),
demand side load management.
4. UNFORSEEABLE RANDOM EVENTS
In Kenya random events are inevitable. This includes recurrent post elections violence,
widespread of strikes, start or stop of large loads (steel mill, factory reviving and
furnaces), sporting events and popular televisions shows and recording and also shut-
down of industrial facility.
2.4: DISCUSSION OF ARTIFICIAL INTELLIGENCE TECHNIQUES
The electric load forecasting is a problem that is difficult to deal with because of the
nonlinear and random behavior of system loads as well as other factors that may
influence the demand. The artificial intelligent techniques are effective to a certain
extend. The main disadvantage of these techniques is their inability to incorporate and
handle this random-like behavior of system loads. Moreover, because of the
developments in technology, economic growth, past trends, causes the classical methods
to produce incorrect predictions which may have a negative effect on the power utilities.
A need that requires models to be able to adapt quickly to the changing environment and
be able to learn on their own without human assistance arises. Methods with improved
accuracies that can be updated without interfering with the rest of the system, and can
incorporate as many input parameters as possible without failing to converge become a
necessity. Various research programs have been undertaken in order to find solutions to
these problems and one of the result was Artificial Intelligent techniques (NEURAL
NETWORKS)
10
AITs are unconventional ways of solving classes of problems. A number of artificial
intelligent techniques have been developed over the past century and their applications
are global. They are able to use human knowledge to create solutions to problems. This
type of knowledge is stored in knowledge basis such as the expert systems. They are able
to gain experience over time and are able to handle uncertainty in information very well
like the fuzzy logic system.
2.4.1: ARTIFICIAL NEURAL NETWORKS
ANNs have been used since 1990 and have been studied intensively as a tool to be used
for electric load forecasting. Essentially, a neural network is a non-linear circuit that is
capable of doing non-linear curve fitting. It is an information processing paradigm that
was inspired by the way the biological systems of humans such as the brain processes
information.
The human brain is made up of neurons, which are interconnected by dendrites and
collect information via the connection. All the neurons in the brain work in unison to
make sure that all the information that is received is processed as efficiently and as
accurately as possible. Therefore, the artificial neurons try to simulate this kind of
behavior displayed by the real neurons in the brain.
ANNs learn by example much like the human brain. They are configured for particular
classes of problems or applications through a learning process.
11
2.4.2: SYSTEM STRUCTURE
AANs are made up of simple and highly interconnected processing elements (PE) called
neurons. An illustration of a neuron and its mathematical model is shown bellow:
-
Figure 2.1: Structure of a neuron [10]
The mathematical model is of the form:
Oj = fi∑ (wjk*xk) (2.1)
Where
Oj: output of the neuron
fi : transfer function called a sigmoid that is differential and non-decreasing; it is in the
form of an “S” shape
wjk : weighting functions that are adjustable and represent the strength of the connection
between the input data and output.
xk : input to the neuron.
Figure 2.2 below shows the interconnectivity of a neural network. The network is made
up of interconnected neurons in a layer configuration.
12
The first two layers are known as the hidden layers and the last layer is the output.
Figure 2.2: artificial neural network structure [4]
The figure above uses a topology called feed-forward. Feed-forward is basically the
structure where the input signals is propagated in one way from input neuron via a
hidden layer to the output. These are straight forward artificial neural networks as they
associate the input to the output very easily.
Another type of ANN is the feedback ANN. These networks can have signals travelling
in both directions within the network. Feedback networks are dynamic and their status is
always changing until an equilibrium point is reached. They can become very
complicated but are regarded as very powerful networks. They are also regarded as
recurrent networks.
2.4.3: THE LEARNING REGIME
There are two types of training or learning regimes used for ANNs; namely supervised
and unsupervised learning. Supervised learning is the process where each output unit is
told what desired response to the input signal is should be. An important issue with
regards to supervised learning is the problem of error convergence. The objective is to
13
minimize the error between the desired and computed values. Therefore weighting
functions which minimize these errors need to be developed.
A training system called back propagation falls under the supervised learning section. It
is most commonly used for the training period of the ANN. Its basic procedure is as
follows [7]: a training sample is provided to the network, the outputs are calculated for
given inputs in the forward direction, thereafter in the backward motion, the errors at the
output layer are propagated backwards to the input layer. The weights are adjusted for
each neuron and an algorithm is implemented that finds the weighting functions that
minimize the error.
The next is the unsupervised learning system. Unsupervised learning is based upon the
local information that is provided and there are no actual target outputs. The weights are
changed in response to the network inputs. A set of data inputs are taken and the neural
network treats this data as a random variables. The network then uses this information to
determine the properties and then produce a solution.
2.4.4: APPLICATION TO LOAD FORECASTING
In applying the ANN to load forecasting, the forecaster needs to choose one of the
architectures such as back propagation as well as the number and connectivity of the
layers. He/she needs to be able to decide whether to use feed-forward, recurrent
networks; and the training period and the data required for the learning regime. This kind
of structure has been used by a number of forecasters. The ANN model has received
much recognition with respect to the problem of long-term electric load forecasting. The
success of an ANN method lies in its ability to learn and adapt to the changing
environment.
The following lists the advantages and disadvantages associated with this technique.
Advantages
• ANN systems are fast and robust.
• Possesses a good learning ability.
14
• Capable of adapting to the data.
• Appropriate for non-linear modeling.
• Does not require a mathematical model of the load
Disadvantages
• The forecaster needs to be able to select the optimum configuration from many
options available.
• Results are always generated even though the input data may be unreasonable.
• Needs to choose a training methodology
• ANNs are not able to explain the decisions that are made within the neural
networks
2.4.5: ACCURACY OF LOAD FORECASTS
The most important aspect of electric load forecasting method is its accuracy. The model
needs to be able to project the future demand as accurately as possible so that the risk of
losing revenue for electric utilities is minimized as well as the cost of generating
electricity; there is no standard set for forecasts because of the uncertainties that come
with predicting future load.
Forecasting accuracy depends on the quality and quantity of the historical data used the
validity of the forecaster’s assumptions, and the accuracy of the demand-influencing
factors such as weather, income, prices etc [9]. It is common to measure the model
accuracy statistically in terms of the standard deviation of the forecast error [5].
The accuracy may then be measured by this formula:
error = (2.2)
Where
a(t): actual (measured) demand at time t
f(t) : forecasted demand at time t
15
The assumption made is that the mean e=0. The variance is calculated by taking the
mean of e. the standard deviation is the square root of this variance. If the error analysis
does not provide a convincing situation, the model has to be re-evaluated.
The foundations of load forecasting have been established. This thesis focuses on the
problem of long-term load forecasting with the use of neural networks. The knowledge
obtained in this section will be used to create a model that will be able to perform as
required.
For comparison purposes electric load forecasted data using econometric model was
obtained. Here is brief discussion on how the Kenya power and lighting company
performed the Econometric electric load forecast.
2.5: ECONOMETRIC MODEL
This method incorporates statistics, economics and mathematical theory in order to
forecast the electricity demand. The approach estimates the relationships between
energy consumption and factors influencing consumption [3]. It is a combination of the
end-use and trend analysis methods but it does not take on the assumption used in
trending that future demand can be predicted based on past demand. Unlike the end-use
model, it allows the variation of the relationships between the end-use and the amount of
electrical power received by consumers.
Complex mathematical equations are used to show past relationships between demand
and the demand-affecting factors [9]. The equation can show whether these factors
decrease or increase the demand as well as the percentage increase or decrease.
The equation is then tested for its reliability and accurate representation of past data.
Thereafter, projected values of the factors (price, population etc) are put into the
equation and a forecast is made. In this method past electricity consumption data was
used and GDP growth was established and regression method was used to obtain the
electricity demand for the consecutive years.
16
Advantages
• Shows how and why electricity increases or decreases.
• Provides detailed information about the future levels of electricity demand.
• Provides separate forecasts for residential, commercial and industrial demand.
• Flexible and useful for analyzing load growth under different scenarios [9]
Disadvantages
• Large changes in demand affecting factors are not accounted for.
• In order for the forecast to be accurate, the factors influencing the electricity
demand need to be in the same forecast period as in the past.
• It is only as accurate as the forecasts of the factors which influence the demand.
• The econometric forecast works better for larger areas than small areas i.e. at
regional (for example in Kenya, the entire Nairobi south is a region) or national
level (entire Kenyan country) because of the extensive data needed to formulate
the model.
17
Chapter 3: ARTIFICIAL NEURAL NETWORKS
This chapter presents a detailed description of the components that make up an Artificial
Neural network and how they function. Before this is explained, a brief history of how
and when these neural networks were developed will be discussed.
3.1 INTRODUCTION TO ARTIFICIAL NEURAL NETWORKS
ANNS are models that were developed based on the structure of the brain. The idea was
that the brain learns by experience and so the scientist at the time wanted to develop
something that will use this ability to learn. The neural cell in the brain was discovered
in 1836 [4]. An organism does not seem to regenerate itself and has the ability to provide
the human with the power to remember and think.
The neuron is a complex organism and biological research is still ongoing in terms of its
functions. It consists of many parts as is illustrated in the figure below.
Figure 3.1: Diagram of neuron in the human brain [6]
18
They are able to convey information amongst themselves through electrochemical
pathways called the synapse. All these neurons have specific tasks to perform and belong
to different classes but they work together to bring about coherent output. In analogy to
the brain, the artificial neuron was developed by McCulloth and Pitts. A simple neuron
structure as shown in the figure below
Figure 3.2: Artificial neuron and its components [6]
It works in a more simplistic way as compared to the real neuron. A real neuron receives
input signals from different types of sources, combines them in a generally non-linear
manner, and then produces the result. The artificial neuron behaves in much the same
way but the difference is that the function is known whereas the biological neuron’s
processing system is known.
3.2 DESCRIPTION OF NEURAL NETWORK COMPONENTS
As mentioned in previous chapters, an ANN is a system made up of a number of
interconnected neurons. They are useful in producing solutions to specific complex
problems. ANNs are based on biology in particular the interactions between the neurons
in the brain and the processing strategy and the results produced. This section describes
the major components of an artificial neuron. The following information as well as the
sections in the rest of this chapter [11]
Weighting functions: A neuron may receive a number of input signals at the same time.
Each input has a weighting of a magnitude that causes the input to have an impact on the
19
summation function of the processing element depending on the strength of the
connection between the input and the neuron. The weights perform the same function as
the synapses that connect the neurons in the brain. In both cases, some inputs are made
more important than others are so that they have a greater effect on the processing
element as they combine to produce a neural response [11]. The weights are adaptive
coefficients that can be increased or decreased where necessary. This occurs during the
training regime as mentioned earlier.
Summation function: This component performs the weighted summation of the various
inputs received by neuron. The inputs are corresponding weights are represented as
vectors and so the dot product of these two vectors result in the total input signal.
Transfer function: The output of the summation function is then taken by the transfer
function. This transfer function transforms the summation output into a working output.
There is a certain threshold set by the transfer function that the summation output can be
compared to determine the neural output. Transfer functions that are used are:
• Hard limiter
• Ramping function
• Sigmoid functions
If the sum is greater than the threshold, the neuron generates a signal. However if the
sum is less then no signal is generated.
Hard limiter: This function as illustrated in the figure above has limits between minus
one and positive one. This means that the output is either a minus one or one for a given
input. The threshold can also be between zero and one.
• Ramping function: The input to the function is mirrored for a certain
range and thereafter a hard limit is enforced.
20
In figure 3.3, the input is the same as the output for the range between
zero and one and thereafter the output is clipped to a maximum value of
one
• Sigmoid function: A sigmoid function is an “S” shaped function that is
continuous, differentiable, and non-decreasing and its derivative has the
same properties. There are two types of sigmoid commonly used in ANN
architecture namely the hyperbolic tangent as well as the logistic function.
The logistic function has outputs ranging from zero to one whereas the
hyperbolic one has outputs from minus one to positive one.
The transfer functions that are usually used are shown in the figure below.
Figure 3.3: Sample transfer functions [11]
3.3: SCALING AND LIMITING:
The result from the transfer function may be passed through further scaling limiting
processes. The output from the transfer function is multiplied by a certain scale factor
21
and then an offset may be added. This decision rests with the designer. Limiting this
output ensures that it does not exceed any specified upper and lower bounds.
Output function: Each neuron produces an output after the scaling and limiting of the
original output from the transfer function. The neuron outputs a signal to many output
neurons. A phenomenon known as competition is sometimes used at this stage (not all
network topologies use this technique). The result of the transfer function is modified to
include an element of competitiveness between the neurons. The neurons are allowed to
compete with each other thereby inhibiting other neurons unless they have the greater
strength. Competition can occur at one or two levels. First, competition determines
which artificial neuron will be active or provide an output. Second, competitive inputs
help to determine which processing element will participate in the learning or
adaptation process [11].
Error function: The difference between the actual output and the desired output is
calculated, the raw error. It is then taken into an error function and then propagated
backwards to a previous layer. The error is usually multiplied against each of the
incoming connection weights to modify them before the learning cycle.
Learning function: This function is used to modify the weights of the inputs of every
neuron according to the errors propagated backwards as well as according to some other
neural based algorithm. This process is done until a desired result is obtained and is
known as the adaptation or the learning mode. There are two types of learning modes as
stated earlier namely supervised an unsupervised learning. These will be discussed in the
next section.
3.4 ANN TRAINING
It was mentioned earlier that weights for the inputs needed to be found so that the
desired outputs can be obtained. In order for this to occur, the ANN needs to undergo
some for of training where it learns and discovers relationships between certain input
parameters. Because of this, the ANN is able to modify the weights so that the expected
result is achieved with a little room for error. It does so by using two learning methods,
22
namely supervised and unsupervised learning. The learning methods try to minimize the
errors of all the neurons by modifying the weights until the level of accuracy in the
network is acceptable.
3.4.1 SUPERVISED LEARNING
This type of learning mode was discussed briefly in section two. With this kind of
learning, the ANN needs to be trained before it can be able to solve any problems. Input
and output data (training data) is given to the network during the training stage. For each
input, there needs to be a corresponding output. A very careful selection of input data is
required as the ANN will discover relationships between input parameters and thus use
this as a standard when actual data is presented during the validation stage. Training sets
need to be fairly large and inclusive of every situation because as mentioned above, the
network needs all this information so that it can be able to learn all features and
relationships that are important.
The output obtained by the neural network is compared to the desired output. The
difference between the two is then propagated backwards into the network. The weights
are initially set to some random numbers and then they are modified iteratively during
the learning process according to the error difference.
When the desired accuracy is reached, the network is presented with data it has not seen
before and the performance level is monitored. If the performance is not satisfactory, the
training session continues. This testing is critical to ensure that the network has not
simply memorized a given set of data but has learning the general patterns involved
within an application [11]
3.4.2 UNSUPERVISED LEARNING
In unsupervised learning, the network is trained without any external help. This means
that the data is presented to the network consists of only the input values. There is no
target vector for the outputs. The weights are adjusted by the network by monitoring its
internal performance. The network looks for trends in the input signals and makes
23
changes according to its function. The ideal behind this kind of learning is that the output
or consequence of doing something is unknown.
An input is presented but the outcome is unknown and so the network needs to train
itself to find any similarities among the inputs so that it can be able to produce a
reasonable result.
This training correlates in a way to human activity. One might be faced with a situation
(for example a mathematical or engineering problem) that one has never encountered
before and an outcome is required. So that person goes out and performs some kind of
research and looks at the information that has been presented (training) and then makes
an informed decision.
However, unsupervised learning is a subject that is still being researched and not been
widely implemented.
3.4.3 LEARNING RATES
A learning rate defines how long it will take to train the network. The slower the ANN
learns the more time spent, the faster the learning rate the more the network will not be
able to make the fine discriminations required to reach the desired accuracy. Factors like
the size of the network, architecture type, type of learning rule and desired accuracy need
to be considered when coming up with a learning rate. The learning rate is usually a
positive number between zero and one.
If it is bigger than one, the learning algorithm may overshoot in correcting the weights
whereas if it is very small, it may not be quick enough to correct the errors and may lead
to convergence problems.
3.4.4 LEARNING RULES
The first learning rule was developed by Donald Hebb in 1949 and it is known as
Hebb’s rule. His rule states that “If a neuron receives an input from another neuron, and
if both are highly active (mathematically have the same sign), the weight between the
neurons should be strengthened.”
24
The next rule to be developed was the Hopfield law, which is similar to Hebb’s rule, but
the difference is that the magnitude of the strengthening is specified.
It says that “If the desired output and the input are both either active or inactive,
increment the connection weight by the learning rate, otherwise decrement the weight by
the learning rate.”
The delta rule is a rule that has been implemented widely in the ANN application to
load forecasting. It is a further variation of Hebb’s rule. The principle behind is that the
strengths of the input connections have to be continuously modified in order to reduce
the difference (delta) between the target output and the actual output value of the neuron.
It changes the weights in a way that minimizes the mean square error of the network. It
works as follows:
1. The delta error in the output layer is transformed by the derivative of the
transfer function.
2. The result is taken by the previous layer to adjust the connection weights.
3. This error is propagated into other previous layers one at a time.
4. The error reaches the input layer and the weights are adjusted.
5. The training procedure is repeated until the accuracy is acceptable.
In mathematical terms, the following equations are used for the delta rule:
(3.1)
represents the error term.
For a neuron j with a transfer (activation) function given by g(x) the delta rule for its ith
weight wji is given by
∆wji =α (tj – yj)g’(h)xj (3.2)
Where
α: learning rate
25
g(x): transfer function
tj : target output
yj : actual output
xj : ith input
hj =∑xjwji (3.3
yj = g(hj) (3.4)
A network type called Feed-forward; back-propagation derives its name from this
method of calculating the error term. This network is most commonly applied to the
problem of load forecasting and is the subject of discussion in the next section.
3.4.5: NETWORK SELECTION
There exists a variety of networks in the ANN architecture. Each network type is specific
to a certain class of problems. The table overleaf illustrates some of the applications or
problem types for which neural networks are used. There are five categories:
1. Prediction
2. Classification
3. Data association
4. Data conceptualization
5. Data filtering
26
Table 3.1: shows applications and problems solved using neural networks
Network type Networks Use for networks
Prediction -Back propagation
-Delta bar delta
-Extended delta bar delta
-Directed random search
-Higher order neural networks
-Self organizing map into
Back-propagation
-Use input to predict some
output (e.g. pick the best
stocks in the stock market,
predict the weather, identify
people with cancer risks)
Classification -Learning vector quantization
-Counter-propagation
_probabilistic neural network
Use input values to determine
the classification (e.g. is the
input the letter A, is the blob
of video data a plane and
what kind of plane it is)
Data Association -Hopfield
-Boltzmann machine
-Hamming network
-Bidirectional associative
memory
-spatial-temporal pattern
recognition
Like classification but it also
recognizes data that contains
errors (e.g. not only identify
the characters that were
scanned but also identify
when the scanner wasn’t
working properly)
Data conceptualization -Adaptive resonance network
-Self organizing map
Analyze the inputs so that
grouping relationships can be
inferred (e.g. extract from a
data base the names of those
most likely to buy a particular
product)
Data Filtering -Recirculation Smooth an input signal (e.g.
take the noise out of a
telephone signal)
27
Since this project is about electric load forecasting, which is a form of predicting
the future, the network that is most commonly used in this problem will be
discussed.
3.4.6: FEEDFORWARD, BACK-PROPAGATION
The feed-forward, back-propagation architecture was developed in the 1970’s by
several people namely Werbor, Parker, Hinton, Rumelhalt and Williams. Their
theories were developed independently from each other. By generalizing the delta
rule to multiply layer networks and non-linear differentiable functions, the back
propagation rule was created [8].
This architecture is the most popular, effective, and easy to learn model for
complex problems such as load forecasting. Its greatest strength is in non-linear
solutions to ill defined problems [6]
A typical network of this nature consists of one hidden layer and an output layer.
This is shown on the figure below.
Figure 3.4: Typical layout of a feed-forward network [12]
Training inputs are applied to the input layer and the target outputs are compared to the
outputs at the final layer. During the learning regime, a forward movement is made
28
though the network with the information moving from input layer through the hidden
layer and finally to the output layer, hence the name feed-forward.
The difference between the target and computed outputs (error term) are then propagated
backwards to the previous layers. This is usually modified by the derivative of the
transfer function and the connection weights are normally adjusted by the Delta rule.
The back-propagation rule is best descried by a worked example. Consider a two-layer
feed- forward network with a set of n inputs as illustrated in figure below.
Figure 3.5: Two layer feed-forward network.
Given a set of input i and j hidden layer neurons as well as k output layer neurons, the
hidden layer receives the following signal input
hj= ∑xiwji (3.5)
and produces an output that has been transformed by the transfer function which in this
case we will take as sigmoid or logistic function of the form
(3.6)
The output of a single hidden layer neuron is the following
29
fj = g(hj) (3.7)
This is then multiplied by the weight connecting the hidden layer to the output neurons.
yk = g(∑ (wjk*fj)) = g(vk) (3.8)
is the final output of a neuron k at the output layer.
For the hidden to output neurons the change in weight is calculated by
∆wjk=α (∑(tk – yk)g’(vk)fj (3.9)
Where α is the learning rate.
For the input to the hidden connections, the task becomes more difficult and partial
derivatives of the error term need to be used. The partial derivative of the error function
(equation 3.1) with respect to the weight connections between the input and the hidden
layer needs to be performed.
∆wji = α (using chain rule) (3.10)
=α∑k(tk – yk)g’(vk)g’(hj)xi (3.11)
The final step is to add the changes to the original weights
Wijnew = wij
old + ∆wij (3.12)
Wjknew =wjk
old + wjk (3.13)
There are many other variations of the back-propagation rule such as the back-
propagation with momentum. This was developed so that the learning of the network
may become faster causing it to converge as it was discovered that the network
sometimes did not converge using the standard algorithm. The error function or delta
weight is modified so that a portion of the previous delta weight is fed through to the
30
current delta weight. Therefore, a momentum coefficient mc that ranges between zero
and one is used in the delta equation.
∆ w = ∆w +mc*∆wprev (3.14)
A different viewpoint concerning the supervised training of a network is taken when the
training is approached as a problem in numerical optimization. The Scaled Conjugate
Gradient (SCG) method, which is a member of the Conjugate Gradient Method CGM)
family, is a training algorithm that is used in conjunction with back-propagation. This is
done in order to increase the computational speed of the training. Despite the standard
back-propagation method being given a momentum factor, convergence for large-scale
networks does not occur optimally.
The CGM is a general-purpose second order technique that helps to minimize the goal
(error) function of certain variables. Second order means that the function uses second
derivatives in the goal functions whereas the back-propagation method uses first
derivatives. CGMs are much like the back-propagation method in that they iterate until
the minimum is reached. The difference is that the back-propagation iterates down a
gradient while the method can be found in the appendix.
3.5 LOAD FORECASTING USING ANN
The following feature of an ANN network are regarded as most important when wanting
to apply this kind of technique for load forecasting
• Network structure
• Learning rule used for training
• Choice of input variables
• Learning rate
Network structure: This is important as the designer needs to decide on the number of
layers he/she is going to use. The most commonly used is the three-layer feed-forward
network because of its great ability to map non-linear functions [6] the three layer
31
network will be divided such that the first, second and third layers constitute the input,
hidden and output layers.
The number of hidden layers is also a critical decision because if the system contains
many hidden layers, there is a high chance that the data will only be memorized and a
pattern will not be found. The models encountered for the short-term load forecasting
problem use one or two hidden layers. The choice of the number of hidden layers
depends on the complexity of the problem at hand. The output layer can have as many
output neurons as the designer wishes.
In the case of hourly load forecasting, there are 24 hours in a day and so the designer
may want an output for each hour of the day or one output stating the total system load
for the next day.
Choice of input variables: load forecasting models are different for each power utility.
This is because there is no standard that dictates which variables to use when developing
a model for load forecasting. The choice of inputs lies with the designer. Input variables
such as weather, the previous year’s load and weather characteristics (this includes the
temperature and precipitation) to name a few may be used. The knowledge about the
kind of stimuli that influence the load needs to be known to make an informed decision
on the type of input variables to choose.
Learning rule: it is important to choose the correct learning rule for a specific
application. In load forecasting, the back-propagation method is widely used and has
been proven to produce effective results. Another aspect of the learning rule is the
accuracy that the network is to reach. This accuracy needs to be predefined by the
designer so that the network can be trained until it reaches that level of performance.
Learning rate: As discussed previously, this factor is important and defines the duration
of the training period. This number should be chosen carefully so that there is no
overshooting in correcting errors and that the network does not overstep the predefined
error goal.
32
When the above decisions are made, what is left is to train the network. Once the desired
error goal has been reached, actual data can be presented to the ANN so that it can
perform a load forecast. The performance of the ANN can be then be monitored by the
following measures [7]:
• Mean absolute percentage error
Є = *100 (3.15)
• Root mean square error (RMSE)
α = (3.16)
• Average (mean) error
e = ( ) (3.16)
Note: Xt and Xf are the target and forecasted outputs respectively.
33
CHAPTER 4: LONG TERM LOAD FORECASTING BASED ON VISION 2030
4.1: FORECAST MODEL
This section presents an ANN-based model that was developed as a solution to
specification, based on the literature that was reviewed. For comparative purposes data
from K.P.L.C (forecasted) data was obtained. The first two sections describe the
procedures used in to develop the models starting with ANN .Results from two models
are then analyzed and compared
The data used in the model to train the Neural Networks are:
1. Historical electric load demand
2. Historical G.D.P
3. Population growth
4. Weather data
4.2 DEVELOPMENT OF THE ANN MODEL
The section describes the procedures and guidelines that were used in formulating this
model. Below is a diagram of the steps that are taken in developing a model for load
forecasting.
Fig 4.1: Stages involved in developing a load forecasting model
According to fig 4.1, the first step in developing a load forecasting model is to decide on
the objectives of the model.
34
The objectives of this forecasting model are:
• Perform a long-term electric load forecast for the next 20 years
• Create an automated forecasting system
• Develop a forecasting tool that considers weather, historical electric load
data, G.D.P and Housing as inputs
From fig 4.1;
Ø Model formulation/selection: This type of model needs to be decided on this
stage i.e. hourly, weekly or yearly forecast. The year type are also developed
according to the information provided and engineer’s discretion. The year
objectives of the forecast need to be clarified in this stage so that the engineer can
proceed to the next.
Ø Identification: The most important parameters of the model are identified. The
parameters include historical electric load, G.D.P, housing, weather data etc
Ø Validation: This is the stage where the model will be tested to see whether it
performed as required. The performance of the model is checked here as well
and if it does not conform, then the model will have to be re-evaluated and
either additional parameters will have to be added so that better accuracy can
be achieved.
Ø Use for forecasting: This is the final stage after the validation procedure has been
performed. The model can be used for the actual forecasting of the load.
4.3 PROPOSED MODEL
It was decided to develop a fully connected 3 layer feed-forward, back
propagation network because of its ability to approximate non-linear functions. A fully
connected network means that each neuron receives information from every input
variable.
35
A simplified structure of the network is shown in figure. 4.2. below.
Figure 4 .2: simplified structure 3-layer feed forward network.
The network has three layers, namely the first hidden layer, the second hidden layer and
the output layer. The input vector contains the variables that are required to perform the
forecast. The identification of these parameters is discussed in the next section.
4.3.1 IDENTIFICATION OF PARAMETERS
Carrying out an analysis of input variables consists in studying the contribution of each
variable to the result of the forecasting model. The input variables were chosen
according to the specification in chapter 2 (section 3). Two three – layer neural network
models were developed. The first model had an input vector that consisted of 56
variables. The second model had 60 variables. ANN inputs and outputs for he two
models are described in table 4.1
36
Table 4.1: ANN inputs and outputs
Model one Model two
1-48 -previous 10 years
half-year load
demand
1-55 -Same as model one
49-50 -Previous years
housing trend
56 -hourly salary index
51-52 -Previous years
GDP
57-59 -same as model one
53-55 -Previous year
minimum and
maximum weather
forecast
60 -Same as model one
56 -Previous year
population
The first hidden layer is the same size as the number of inputs, that is, the number of
neurons corresponds to the number of inputs. Model one has 56 neurons whilst the
second model has 58 neurons in their respective first hidden layer. The number of output
neurons equals to the number of half - months in a year. Both models have 20 neurons in
the second hidden layer. The transfer function chosen for these layers are the tangent
sigmoid functions; fig 4.3. The output layer has neurons with a linear activation function
so that the outputs can take on any value. It is suggested that the number of hidden
neurons was chosen using the guideline and through experimentation with different
number of neurons as will be discussed in the validation phase.
37
Fig. 4.3 Sigmoid activation function [11]
The network structure for model one is shown in fig. 4.4. Model two is an extension of
model one. This model was created in order to see the effect of the inclusion of
population as a parameter in the forecast. Most authors usually include historical electric
load data and G.D.P as their input variables.
38
Figure 4.4: Network structure
4.4 PRE-PROCESSING OF INPUT DATA
The data used in the training and validation phases was obtained from the KENYA
POWER AND LIGHTING COMPANY. Yearly half-load data for the years 1998 to
2008 were obtained. The 1998-2004 data was used to train the neural network system
and the 2005-2008 data was used for testing the network. G.D.P data for the period
1998-2007 was obtained from the Kenya bureau of statistics. The data that was obtained
could not be used in its actual form because the ANN model has activation functions that
work optimally in a small range such as from minus two to two. See fig. 4.3. Therefore
all load and G.D.P had to be pre-processed.
39
Table 4.2: 1nput parameter values
ELECTRIC DEMAND/%GDP GROWTH RATE
YEAR
DEMAND
(GWh)
%GDP
GROWTH POPULATION(10^6)
1998 4050 1.7526 10
1999 4127 1.3716 12
2000 4374 1.0668 15
2001 4637 1.143 20
2002 4915 2.3622 25
2003 5210 3.3528 30
2004 5722 4.191 35
2005 5854 5 37
2006 6504 6.1 39
2007 6600 6.5 42
2008 6604.5 6.5 45
4.4.1: SCALING LOAD DATA
The pre-processing of the yearly half load data was done using
Xni=(XI-X’)/αI (4.1)
Where
Xni : scaled input of year I,
Xi : Half-year load demand,
40
X’i: Average load demand,
αi: Standard deviation
This scaling scheme was used on all data from the year 1998 to 2008
4.4.2: NORMALIZING WEATHER DATA
It was suggested by Dr. WEKESA that the maximum and minimum temperature be
normalized by dividing both by 33o this is the absolute temperature that NAIROBI
receives.
The year type was represented as a number with 2010 being 0.1 and 2030 as 1 as done in
reference [13]
4.5: VALIDATION OF THE MODEL
A Netlab Toolbox, designed by Ian T Nabney [34], containing Matlab files (M-files) on
neural networks was used to build, train, and test the proposed models. However, the
toolbox only contained a two-layer feed-forward network. A MATLAB code was
developed to enhance a three-layer neural network. The proposed model is a three-layer
network. The relevant M-files had to be extended in order to create the three-layer
network structure as required
41
As seen if figure below once the network was created the pre-processed training data
was presented to the network.
Figure 4.5: shows how to creat the resolution level for training the neural netwok
As seen from above you select the resolution level of your choice for testing. For the
training of the neural network, enter the amount of years you are using for the training of
the network. The training data used was from 1998 to the year 2008, as shown in the
figure below.
Figure 4.6: shows number of years selected for neural network training.
42
For the 7 years you select data for a particular year for the testing as shown in the figure
below.
Figure 4.7: shows the year data selection for the testing of the neural network
Once you finish entering scaling the historical load data, normalized G.D.P and the
historical population, you repeat the same for every year from 1998 to 2008. Then now
you can select one of the options:
• Create new neural network
• Perform load forecasting demand.
• Quit session
As shown in the figure below,
Figure 4.8: shows selection of options (create new Neural Networks, perform
forecasting of load demand or Quit session).
43
Now the neural network is already created, trained, tested and ready for electric
load forecasting.
4.5.1: SIMULATION RESULTS
The following presents the forecast that were generated by the neural network and the
econometric results developed by K.P.L.C model. The performance of the neural
network is judged based on the K.P.L.C model. The figure below shows the electric load
forecast for the next 22 years (that is, 2008 to 2030)
Figure 4.9: ANN output results(forecasted load for 2009-2030)
Given the results from the simulation of the neural network and the K.P.LC’s
econometric model results comparison had to be made to establish the best suited model
for long-term electric load forecasting.
44
4.5.2: COMPARISON BETWEEN ANN AND K.P.L.C MODEL
The tool developed by K.P.LC engineers was used to forecast the next 30 years. As
shown in the table 4.2 below K.P.L.C forecast has the same load profile as the ANN load
which is good. In figure 4.3, as the year’s proceeds the difference between the ANN and
K.P.LC econometric model become large. This is because the ANN tool has adjustment
factors which affect the forecast. By adjusting these factors and checking the graph of
the resulting forecast against the K.P.LC load, are obtained
Table 4.3: ANN and K.P.L.C forecasted results
YEAR
ANN
FORECAST
KPLC
FORECAST
2009 7118 7004.9
2010 7626 7461.8
2011 8176 7983.1
2012 8766 8578
2013 9395 9256.7
2014 10070 10031.1
2015 10780 10914.7
2016 11530 11922.9
2017 12320 13073.3
2018 13160 14385.8
2019 14040 15883.4
2020 14960 17592.2
2021 15920 19541.9
2022 16930 21760.5
2023 17980 24304.5
2024 19070 27201
2025 20210 30505.4
2026 21390 34276.1
2027 22610 38578.2
2028 23890 43487
2029 25200 49087.8
2030 26560 55478.4
45
It can be seen that in the figure 4.4, ANN approximates the K.P.L.C forecasted load
better for the next ten years,then K.P.LC forecast shoots up exponentially. The K.P.L.C
this is higher than expected by the ANN. The consequnce of high forecasting is that the
generation that will be scheduled will be low and will not be able to meet the load
demand for that particular year. This can cause the overloading of transmission lines and
transformers in severe cases, cause a blackout.
As shown in the figure below, ANN is more superior tool. Ths is because ANN is a
automated forecasting tool that does not require manual updating of input data. Errors
that may be caused by human interference are minimal in ANN whereas in K.P.L.C
econometric model this may lead to unfavourable results.
Figure 4.10: ANN and K.P.L.C results
46
Chapter 5: CONCLUSION AND RECOMMENDATIONS
This project presents a model that forecast on a long-term basis; for the next 20 years
ahead according to the specification discussed in the project, ANN based long-term load
forecasting method that use a three-layer feed forward neural network and a scaled
conjugate back-propagation training algorithm are presented in this project. The model
considers historical load data, population, G.D.P and weather conditions. For
comparative purposes as well as to deduce whether ANN produces effective results,
K.P.L.C forecasted results were used. The difference in the forecasted results is
accounted for by the fact that K.P.L.C econometric methods are not able to detect and
determine the relationship between load affecting factors and the load demanded. The
ANN model performs much better than the econometric model because it is able to learn
from the training data, the relationship between certain variables and their effects on the
load demand thereby making relatively accurate predictions. In order to get accurate
predictions, the data should be trained. Increasing the number of training cycles has an
improving effect on the forecasting errors. However, if a network is over-trained, the
results may be unfavorable.
When comparing the ANN and K.P.L.C econometric models, it is concluded that
inclusion of more load affecting variables increases the accuracy of the forecasts, hence
proving that ANN is more superior. It can thus be concluded that Artificial Intelligent
Techniques such as Neural Networks in particular, are better suited for long-term electric
load forecasts than classical methods (that is, econometric method used by K.P.L.C). The
approach to long-term electric load forecasting used in this project should therefore be
considered by the Kenya Power and Lighting Company for further development as an
operational tool.
47
Based on these conclusions, the following is recommended:
• Artificial Intelligent-based techniques, ANN in particular, must be implemented
for long-term electric load forecast for the Kenya Power and Lighting
Company.
• More load affecting variables, Hourly salary index and electric pricing in
particular should be investigated and used as input variables to the model to
improve forecasting accuracy. These two are specified because of the current
growth of unemployment in Kenya.
• Investigate ways of normalizing the weather variables as this may affect the
output of the forecast.
• Use a high processing computer for the development of the ANN model.
Further work
Due to the unreliability of the weather forecasts an ANN based weather forecasting
model can be developed for the ANN-based long-term load forecasting model.
Chaos years (as experienced during and after last general elections), holidays their
respective input variables were discarded: in reality it cannot be done. Therefore, an
ANN-based or other AI-based short-term and medium-term for holidays can be
developed so that all years can be covered when forecasting.
48
APPENDICES
%File name: nprogram.m
%Description: This file reads the data from its source into their respective arrays.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Clear command screen and variables
clc;
clear;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%user desired resolution level (Tested: resolution = 2 is best)
level = menu('Enter desired resolution level: ', '1',...
'2 (Select this for testing)', '3', '4');
switch level
case 1, resolution = 1;
case 2, resolution = 2;
case 3, resolution = 3;
case 4, resolution = 4;
end
msg = ['Resolution level to be used is ', num2str(resolution)];
disp(msg);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% user desired amount of data to use
data = menu('Choose amount of data to use: ', '1 year', '2 years', '3 years', '4 years',...
'5 years', '6 years', '7 years (Select this for testing)');
switch data
case 1, dataPoints = 4050; %1 year = 4050 points
case 2, dataPoints = 4127; %2 years = 4127 points
49
case 3, dataPoints = 4374; %3 years = 4374 points
case 4, dataPoints = 4637; %4 years = 4637 points
case 5, dataPoints = 4915; %5 years = 4915 points
case 6, dataPoints = 5210; %6 years = 5210 points
case 7, dataPoints = 5722; %1 years = 5722 points
end
msg = ['No. of data points to be used is ', num2str(dataPoints)];
disp(msg);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Menu for data set selection
select = menu('Use QLD data of: ', '1998',...
'1999', '2000 (Select this for testing)', '2001', '2002');
switch select
case 1, demandFile = 'DATA1998_QLD1';
case 2, demandFile = 'DATA1999_QLD1';
case 3, demandFile = 'DATA2000_QLD1';
case 4, demandFile = 'DATA2001_QLD1';
case 5, demandFile = 'DATA2002_QLD1';
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Plot the original demand data signal
figure (1);
subplot(resolution + 2, 1, 1); plot(1: dataPoints)
legend('Demand Original');
title('QLD Demand Data Signal');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Function here allows repetitive options to,
50
% 1) Create new NNs, 2) Retrain the existing NNs,
% 3) Perform load demand forecasting and 4) Quit session
while (1)
choice = menu('Please select one of the following options: ',...
'CREATE new Neural Networks',...
'Perform FORECASTING of load demand', 'QUIT session...');
switch choice
case 1, scheme = '1';
case 2, scheme = '2';
case 3, scheme = '3';
case 4, scheme = '4';
end
%If scheme is 'c', call <nCreate> to create new NNs, train them then perform forecast
if(scheme == '1')
nCreate;
end
%If scheme is 'r', call <nRetrain> to retrain the existing NNs
if(scheme == '2')
nRetrain;
end
%If scheme is 'f', call <nForecast> to load the existing NN model
if(scheme == '3')
nForecast;
end
%If scheme is 'e', verifies and quit session if ’yes’ is selected else continue
if(scheme == '4')
button = questdlg('Quit session?', 'Exit Dialog','Yes','No','No');
51
switch button
case 'Yes', disp(' ');
disp('Session has ended!!');
disp(' ');
break;
case 'No', quit cancel; e As seen if figure below once the network was created the pre-processed training data was presented to the network.
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%File name : ncreate.m
%Description: This file prepares the input & output data for the NNs. It creates then trains the
NNs to mature them.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Clear command screen and set target demand output to start at point 2
clc;
targetStartAt = 2;
disp('Program will now CREATE a Neural Network for training and forecasting...');
disp(' ');
disp('To capture the pattern of the signal, the model is ')
disp('set to accept dataPoints x 2 sets of training examples; ');
disp('1 set of demand + 1 sets of gdp. ');
disp(' ');
disp('The normalised demand data <point 2>, is to be taken as the ')
disp('output value for the first iteration of training examples. ');
52
disp(' ');
disp('Press ENTER key to continue...');
pause;
%Clear command screen then prompt for no. of training cycles
%For current program, 1 cycle = user set no. of iterations (ie: dataPoints)
clc;
cycle = input('Input the number of training cycles: ');
numOfTimes = resolution + 1;
%Creating and training the NNs for the respective
%demand and gdp coefficient signals
for x = 1: numOfTimes
%Clearing variables
clear targetDemand;
clear inputs;
clear output;
clc;
if(x == 1)
neuralNetwork = ['Neural network settings for approximation level ',
num2str(resolution)];
else
neuralNetwork = ['Neural network settings for detail level ', num2str(x - 1)];
end
disp(neuralNetwork);
disp(' ');
%Set no. of input nodes and hidden neurons for the
%respective demand and price coefficient signal
numOfInputs = 2;
53
inputValue = ['Number of neural network INPUT units is set at ', num2str(numOfInputs)];
disp(inputValue);
disp(' ');
numOfOutput = 1;
outValue = ['Output is set to ', num2str(numOfOutput)];
disp(outValue);
disp(' ');
numOfHiddens = input('Enter the no. of HIDDEN units for the NN hidden : ');
hiddenValue = ['Number of neural network HIDDEN units is set at ',
num2str(numOfHiddens)];
disp(hiddenValue);
disp(' ');
%Setting no. of training examples
trainingLength = dataPoints;
%Set target outputs of the training examples
if(x == 1)
targetDemand = normDemand(targetStartAt: 1 + trainingLength);
else
targetDemand = normDemandDetail(x - 1, targetStartAt: 1 + trainingLength);
end
%Preparing training examples
%Setting training i/ps to be 2 with user defined no. of iterations (dataPoints)
y = 0;
while y < trainingLength
if(x == 1)
inputs(1, y + 1) = normDemand(y + 1);
54
inputs(2, y + 1) = normgdp(y + 1);
else
inputs(1, y + 1) = normDemandDetail(x - 1, y + 1);
inputs(2, y + 1) = normgdpDetail(x - 1, y + 1);
end
output(y + 1, :) = targetDemand(y + 1);
y = y + 1;
end
inputs = (inputs’);
%Setting no. of training cycles
[ni, np] = size(targetDemand);
% <== [ni, np] tells the NN how long is 1 cycle;
size(targetDemand)
clear nn;
%Create new neural network for respective coefficient signal
%NET = MLP(NIN, NHIDDEN, NOUT, FUNC)
nn = mlp(numOfInputs, numOfHiddens, numOfOutput, 'linear');
%NN options
options = zeros(1, 18);
options(1) = 1;
%Provides display of error values
options(14) = cycle * ni * np;
%Training the neural network
%netopt(net, options, x, t, alg);
nn = netopt(nn, options, inputs, output, 'scg');
%Save the neural network
55
filename = ['nn', num2str(x)];
save(filename, 'nn');
disp(' ');
msg = ['Neural network successfully CREATED and saved as => ', filename];
disp(msg);
if(x < 3)
disp(' ');
disp('Press ENTER key to continue training the next NN...');
else
disp(' ');
disp('Model is now ready to forecast!!');
disp(' ');
disp('Press ENTER key to continue...');
end
pause;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%File name : nforecast.m
%Description : This file loads the trained NNs for load forecasting and recombines the predicted
outputs from the NNs to form the final predicted load series.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Clear command screen and variables
clc;
clear forecastResult;
clear actualDemand;
clear predicted;
56
clear actualWithPredicted;
disp('Neural networks loaded, performing electricity demand forecast...');
disp(' ');
pointsAhead = input('Enter no. of points to predict (should be < 5755): ');
numOfTimes = resolution + 1;
%Predict coefficient signals using respective NNs
for x = 1 : numOfTimes
%Loading NN
filename = ['nn', num2str(x)];
clear nn
load(filename);
clear in;
numOfInputs = nn.nin;
y = 0;
%Preparing details to forecast
while y < pointsAhead
if(x == 1)
propData(1, y + 1) = normDemand(y + 1);
propData(2, y + 1) = normgdp(y + 1);
else
propData(1, y + 1) = normDemandDetail(x - 1, y + 1);
propData(2, y + 1) = normgdpDetail(x - 1, y + 1);
end
y = y + 1;
end
if(x == 1)
forecast = mlpfwd(nn, propData') * maxDemand;
57
else
forecast = mlpfwd(nn, propData') * maxDemandDetail(x - 1) - 4000;
end
forecastResult(x, :) = forecast';
end
%For debugging
% forecastResult
actualDemand = tDemandArray(2: 1 + pointsAhead);
predicted = sum(forecastResult, 1)';
%Calculating Mean Absolute Error
AbsError = abs(actualDemand - predicted(1: pointsAhead)) ./ actualDemand;
msg = ['Mean Absolute Error = ', num2str(mean(AbsError(1: pointsAhead))), ' !!'];
disp(' ');
disp(msg);
%Plot actual time series against predicted result
figure(3)
actualWithPredicted(:, 1) = actualDemand;
actualWithPredicted(:, 2) = predicted(1: pointsAhead);
plot(actualWithPredicted);
graph = ['Mean Absolute Error = ', num2str(mean(AbsError))];
title(graph);
legend('Actual', 'Forecasted');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%File name : nretrain.m
%Description : This file loads the existing NNs and trains them again.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
58
%Prompt for the starting point for training
disp('Program will now RETRAIN the Neural Networks ')
disp('with the SAME intial data series again...');
disp(' ');
disp('To capture the pattern of the signal, the model is ')
disp('set to accept dataPoints x 2 sets of training examples; ');
disp('1 set of demand + 1 sets of gdp. ');
disp(' ');
disp('The normalised demand data <point 2>, is to be taken as the ')
disp('output value for the first iteration of training examples. ');
disp(' ');
msg = ['Data points to be used for reTraining the NNs is from 1 to ',...
num2str(dataPoints)];
disp(msg);
disp(' ');
disp('Press ENTER key to continue...');
pause;
%Clear command screen
clc;
%Prompt for no. of training cycles
%For current program, 1 cycle = user set no. of iterations (i.e.: dataPoints)
cycle = input('Input number of cycles to retrain the NNs: ');
numOfTimes = resolution + 1;
%Loading existing NNs for training
for x = 1: numOfTimes
%Re-initialising variables
clear targetDemand;
59
clear inputs;
clear output;
clc;
%Loading NN for the respective demand and temperature coefficient signals
filename = ['nn', num2str(x)];
clear nn
load(filename);
%Getting the size of NN
numOfInputs = nn.nin;
numOfHiddens = nn.nhidden;
numOfOutput = 1;
%Setting length of reTraining examples
targetStartAt = 2;
%Set target outputs of the training examples
if(x == 1)
targetDemand = normDemand(targetStartAt: 1 + targetLength);
else
targetDemand = normDemandDetail(x - 1, targetStartAt: 1 + targetLength);
end
%Preparing training examples
%Setting training i/ps to be 2 with user set no. of iterations (dataPoints)
y = 0;
while y < reTrainLength
if(x == 1)
inputs(1, y + 1) = normDemand(y + 1);
inputs(2, y + 1) = normgdp(y + 1);
else
60
inputs(1, y + 1) = normDemandDetail(x - 1, y + 1);
inputs(2, y + 1) = normgdpDetail(x - 1, y + 1);
end
output(y + 1, :) = targetDemand(y + 1);
y = y + 1;
end
inputs = (inputs');
%Setting no. of training cycles
[ni, np] = size(targetDemand);
% <== [ni, np] tells the NN how long is 1 cycle;
size(targetDemand)
%With reference to line 106
%NN options
options = zeros(1, 18);
options(1) = 1;
%Provides display of error values
options(14) = cycle * ni * np;
%Training the neural network
%netopt(net, options, x, t, alg);
nn = netopt(nn, options, inputs, output, 'scg');
%Save the neural network
filename = ['nn', num2str(x)];
save(filename, 'nn');
disp(' ');
msg = ['Neural network => ', filename, ' <= successfully RETRAINED and saved!!'];
disp(msg);
if(x < 3)
61
disp(' ');
disp('Press ENTER key to continue training the next NN...');
else
disp(' ');
disp('Model is now ready to forecast again!!');
disp(' ');
disp('Press ENTER key to continue...');
end
pause;
end
% Here is the electric load data from 1998 to 2008.
% Time interval
t = (1998:1:2008)';
% electric load
e = [4050 4127 4374 4437 4615 ...
4810 5222 5454 5804 6300 6604.5]';
% Plot
plot(t, e,'bo');
axis([1998 2030 4000 34000]);
title('electric load. 1998-2030');
ylabel('Gwh');
% what is your guess for the electric load in the year 2020?
% Let's fit the data with a polynomial in t and use it to extrapolate to t = 2010. The coefficients in the polynomial are obtained by solving a linear system of equations involving a 11-by-11 Vandermonde matrix, whose elements
62
are powers of scaled time,
A(i,j) = s(i)^(n-j);
n = length(t);
s = (t-2004)/5;
A = zeros(n);
A(:,end) = 1;
for j = n-1:-1:1, A(:,j) = s .* A(:,j+1); end
% The coefficients c for a polynomial of degree d that fits the data e are obtained by solving a linear system of equations involving the last d+1 columns of the Vandermonde matrix:
A(:,n-d:n)*c ~= e
% If d is less than 10, there are more equations than unknowns and a least squares solution is appropriate. If d is equal to 10, the equations can be solved exactly and the polynomial actually interpolates the data. In either case, the system is solved with MATLAB's backslash operator. Here are the coefficients for the cubic fit.
c = A(:,n-3:n)\e
% Now we evaluate the polynomial at every year from 1998 to 2010-2030 and plot the results.
v = (1998:2030)';
x = (v-2004)/5;
w = (2020-2004)/5;
y = polyval(c,x);
z = polyval(c,w);
hold on
plot(v,y,'k-');
plot(2020,z,'ks');
text(2020,z+15,num2str(z));
hold off
v = (1998:2030)';
63
x = (v-2004)/5;
w = (2030-2004)/5;
y = polyval(c,x);
z = polyval(c,w);
hold on
plot(v,y,'k-');
plot(2030,z,'ks');
text(2030,z+15,num2str(z));
hold off
v = (1998:2030)';
x = (v-2004)/5;
w = (2020-2004)/5;
y = polyval(c,x);
z = polyval(c,w);
hold on
plot(v,y,'k-');
plot(2020,z,'ks');
text(2020,z+15,num2str(z));
hold off
v = (1998:2030)';
x = (v-2004)/5;
w = (2028-2004)/5;
y = polyval(c,x);
z = polyval(c,w);
hold on
plot(v,y,'k-');
plot(2028,z,'ks');
64
text(2028,z+15,num2str(z));
hold off
v = (1998:2030)';
x = (v-2004)/5;
w = (2026-2004)/5;
y = polyval(c,x);
z = polyval(c,w);
hold on
plot(v,y,'k-');
plot(2026,z,'ks');
text(2026,z+15,num2str(z));
hold off
v = (1998:2030)';
x = (v-2004)/5;
w = (2024-2004)/5;
y = polyval(c,x);
z = polyval(c,w);
hold on
plot(v,y,'k-');
plot(2024,z,'ks');
text(2024,z+15,num2str(z));
hold off
v = (1998:2030)';
x = (v-2004)/5;
w = (2022-2004)/5;
y = polyval(c,x);
z = polyval(c,w);
65
hold on
plot(v,y,'k-');
plot(2022,z,'ks');
text(2022,z+15,num2str(z));
hold off
v = (1998:2030)';
x = (v-2004)/5;
w = (2015-2004)/5;
y = polyval(c,x);
z = polyval(c,w);
hold on
plot(v,y,'k-');
plot(2015,z,'ks');
text(2015,z+15,num2str(z));
hold off
v = (1998:2030)';
x = (v-2004)/5;
w = (2018-2004)/5;
y = polyval(c,x);
z = polyval(c,w);
hold on
plot(v,y,'k-');
plot(2018,z,'ks');
text(2018,z+15,num2str(z));
hold off
v = (1998:2030)';
x = (v-2004)/5;
66
w = (2013-2004)/5;
y = polyval(c,x);
z = polyval(c,w);
hold on
plot(v,y,'k-');
plot(2013,z,'ks');
text(2013,z+15,num2str(z));
hold off
v = (1998:2030)';
x = (v-2004)/5;
w = (2010-2004)/5;
y = polyval(c,x);
z = polyval(c,w);
hold on
plot(v,y,'k-');
plot(2010,z,'ks');
text(2010,z+15,num2str(z));
hold off
% code is used to give the forecasted electric load based on vision 2030
% years when electric load is forecasted
Yr (1-22) = (2009-2030)
% electric load demand in GWh obtained using M.file.r.m
e0=6644
e1=7118
e2=7677.3939
67
e3=8176
e4=8766
e5=9395
e6=1.007e+004
e7=1.078 e+004
e8=1.153 e+004
e9=1.232 e+004
e10=1.316 e+004
e11=1.404 e+004
e12=1.496 e+004
e13=1.592 e+004
e14=1.693 e+004
e15=1.798 e+004
e16=1.907 e+004
e17=2.2021 e+004
e18=2.139 e+004
e19=2.261 e+004
e20=2.389 e+004
e21=2.52 e+004
e22=2.656 e+004.
68
REFERENCES
[1] Singh A, Kalra P.K, Emmanuel, “Point of view of knowledge based systems for load
forecasting”, Symposium on expert systems application to power systems, 1998, pp 7~1-
7~4.
[2] Taylor W. J, McSharry E.P, de Menezes M.L, “A comparison of univariate methods
used for forecasting electricity demand up to a year ahead”, International Journal of
Forecasting,2006, Vol.22, pp 1-16
[3] Feinberg E.A, Genethliou D, “Chapter 12 Load Forecasting”, Applied mathematics
for power systems, pp 269-282
[4] Galkin I, “Crash introduction to artificial neural networks” found on
http://ulcal.uml.edu/~iag/CS/intro-to-ANN.html
[5] Galiana F.D, Gross G, ”long term load forecasting”, Proceedings of the IEEE, 1987,
Vol. 75 No.12, pp 1558-1573
[6] http://www.cs.nott.ac.uk/~gxk/courses/g5aiai/006neural/networks/neural-
networks.html
[7] Singh A, Chen H, Canizares A.C, “ANN-based short term load forecasting in
electricity markets”, Proceedings of the IEEE power engineering society transmission
and distribution conference, 2001, pp2:411-415
[8] Komane T, “Short term peak load forecasting using neural networks”, Department of
Electrical Engineering, University of Cape Town, 2001
[9] EM 1110-2-1701,”Appendix B load forecasting methods”, 1985, pp B-1-B-5 found
on
http://www.usace.army.mil/publications/eng-manuals/em1110-21701/a-b.pdf
[10] http://www.cee.hw.ac.uk/~alison/ai3notes/subsection 2 5 2 1.htm, Expert system
architecture
69
[11] Anderson D, McNeil G, “Artificial neural networks technology”, A DACS State-of-
the Art Report, Data & Analysis Center for Software, 1990, pp 1-35
[12] stergiou C, Siganos D, “Neural Networks” found on
http://www.doc.ic.ac.uk/~nd/surprise 96/journals /vol4/cs11/report.html
[13] Khothanzad A, Hwang R.C, Abaye A, Maratukulam D, “An adaptive modular
artificial neural network yearly load forecaster and its implementation at electric utilities
”, IEEE transactions on power systems, Vol. 10, NO. 3, 1995, pp1716-1722
[14] Netlab Toolbox, help files, © Ian T Nabney (1996-2001),
www.ncrg.aston.uk/netlab/index.php
70
Bibliography
1 Matlab (7.0) Neural Network Toolbox. © Mark Beale (1992-2004), the
Mathworks Inc.
2 www.planning.go.ke
3 www.hdropower-dams.com