0% found this document useful (0 votes)
83 views15 pages

AI Lab Manual

The document describes a list of experiments involving the application of artificial intelligence and optimization techniques. The experiments include load flow analysis using ANNs, genetic algorithms for optimization problems, load forecasting using ANFIS, and load frequency control using fuzzy logic.

Uploaded by

Mubarek Mohammed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views15 pages

AI Lab Manual

The document describes a list of experiments involving the application of artificial intelligence and optimization techniques. The experiments include load flow analysis using ANNs, genetic algorithms for optimization problems, load forecasting using ANFIS, and load frequency control using fuzzy logic.

Uploaded by

Mubarek Mohammed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

AI LAB MANUAL

List of Experiments

1. ANN based Load Flow Analysis using Back Propagation Algorithm.


1. MATLAB tool box verification of Load Flow solution.
1. Genetic Algorithm Program for maximization of sin(x) function using all
basic operators.
1. Genetic Algorithm for Economic Load Dispatch of Thermal Units including
losses (Use B-coefficients for computation of losses).
1. MATLAB GA toolbox verification of Economic Load Dispatch of Thermal
Units including losses.
1. Single area and Two area Load Frequency Control using Fuzzy Logic
Toolbox.
2. Economic load dispatch using Particle Swarm Optimization.
3. Load forecasting using ANFIS.
Experiment No: 1
ANN BASED BACK PROPAGATION ALGORITHM FOR LOAD FLOWS

Step1: Read network parameters, such as no. of patterns(no.set), input data, no. of input nodes, hidden
nodes, output nodes, learning rate ‘η’ and acceleration factor ‘α’ etc.

Step2: Initialize the weights [V],[W] to small random values

Step3: Read training patterns from input file

Step4: Normalize input vectors and target vectors (expected output) using
Train output=((train output)-min)/(max-min))*0.8+0.1

Step5: a) set iter = 1


b) set pattern count = 1
c) set hidden node index = 1

Step6: a) calculate input to the hidden node(Ih)


b) calculate output of hidden node(Oh) using sigmoid function
c) increment hidden node index
d) is hidden node index > number of hidden nodes
if no go to step 6(a)
if yes, go to step 7

Step 7: set output node index = 1


a) calculate output of output nodes(Ooj) using sigmoid function
b) calculate error,
Error = expected output(Tj) – calculated output(Ooj)
c) increment output node index
d) Is output node index <= max. no. of output node
if yes, go to step 7(a)
if no, go to step 8

Step 8: Calculate square error


√∑ ( T j−O oj )2
sq.error = n , where ‘n’ is number of output nodes

Step9: Propagate error to all hidden nodes


[ΔW]t+1 = α[ΔW]t + η{Oh}(Tk-Ook)Ook(1-Ook)

Propagate error to all input nodes


[ΔV]t+1 = α[ΔV]t + η{Oi}ei(Ohi)(1-Ohi)

Step10: Update all hidden -output weights


[W]t+1 =[W]t +[ΔW]t+1
Set hidden node index = 1

Step11: a) Update input- hidden weights


[V]t+1 =[V]t +[ΔV]t+1

b) increment hidden node index;


if not equal to max. no. of hidden nodes go to step (11a)
if equal to max. no. of hidden nodes go to step 12

Step12: Increment pattern counter

Step13: Is pattern count > number of patterns


if no, go to step5(d)
if yes, go to step14

 (sq.error )
Step14: calculate error rate = no.set
Is error rate <= tolerance (say 0.0001)
if no, iter = iter + 1, and go to step 15
if yes, go to step 16

Step 15: Is iter > itermax


if yes, go to step16
if no, go to step 5(b)

Step16: store and print converged weights

Step 17: Present the Test pattern

Step 18: Print the result.

Step 19: end


Experiment No: 2
ANN TOOL BOX VERIFICATION OF LOAD FLOW SOLUTION

Step 1: Enter nntool on the command window. Neural network toolbox is displayed.

Step 2: Click on new data. Select on inputs .Enter the input data required for load flow
solution and then click on create button.

Step 3: Similarly click on new data button. Select the target outputs and enter the target
output values for the load flow solution and then click on create button.

Step 4: Click on create network .Set all the parameters in the block obtained as per the
requirement and then click on create button. The network with specified number of
input, hidden, output nodes is created internally.

Step5: After creating the new network click on the created network name in the networks
block of network/data manager. Then all other remaining buttons of network only
section gets activated.

Step 6: Then click on train button to get the network trained. A train window is displayed.
Adjust all the parameters in the window as per the requirement and then click on train
network button in that window. Then the network gets trained.

Step 7: Once the network is trained then present another set of inputs. The outputs are
displayed out which matches with target outputs.
Experiment No: 3
MAXIMISATION OF SIN(X) FUNCTION USING GENETIC ALGORITHM WITH ALL
BASIC OPERATORS

1. Read the relevant data and the tolerance ε.


2. Read GA parameters (population size, chromosome length, crossover probability(P c), mutation
probability(Pm), elitism probability(Pe)).
3. Randomly generate initial population of chromosomes
4. Set the iteration count=1
5. Set chromosome count =1
6. Decode the chromosomes and calculate the actual value of x.
7. Calculate the fitness value
fit =sin(x)
8. Increment chromosome count by 1 and Repeat the procedure from step no. 5 until
chromosome count = population size.
10. Sort the chromosomes and all their related data in the descending order of fitness.
11.Calculate error
error=abs(sin(x)-1);
Check if the error (1) is less than ε. if yes, go to 20.
12. Check if fit(1)=fit(last) .if yes goto step 19
13. Copy the % Pe chromosomes of old population to new population starting from
the best ones from the top
14. Perform crossover on selected parents and generate new child chromosomes,
repeat it to get required number of chromosomes.
15. Perform mutation on all chromosomes.
16.Add all the generated child chromosomes to new population.
17. Replace old population with new population.
18. Increment iteration count. If iteration count <max. Iteration, go for next iteration,
else print “problem not converged in maximum number of iterations”.
19. All chromosomes had equal value. Run the program once again by changing GA
parameters.
20. Problem converged. Print the value at which sin function has optimum value i.e.
x(1) value is to be printed out.
Experiment No: 4
ECONOMIC LOAD DISPATCH USING GENETIC ALGORITHM

1. Read generator data,cost coefficients of generators(a i,bi,ci), P limits, B-coefficients, power


demand(Pd) and GA parameters (population size, chromosome length(li), crossover
probability(Pc), mutation probability(Pm), elitism probability(Pe)).
2. Generate initial population of chromosomes.
3. Set the iteration count=1
4. Set chromosome count =1
5. Decode the chromosomes (DV) and calculate the actual system λ i.e incremental cost

  max - min 
i =imin +  i li i  DV(si )
 2 -1 

6. Calculate the generation output of all the units(i), for each chromosome (j), from its λ value
using,
P(i,j)= [λ(i)-b(i)] / [2*c(i)] and enforce Pi limits

7. Calculate transmission losses(Ploss) using B-coefficient equation.


8. Calculate the error and fitness value
error=Pg-Pd-Ploss, where Pg=ΣPi

fit =1/(1+k*error) where k is a number taken b/w 50 to1000.

9. Increment chromosome count by 1 and Repeat the procedure from step no. 5 until
chromosome count = population size.

10. Sort the chromosomes and all their related data in the descending order of fitness.

11.Calculate error for each iteration

error(i)=abs(Pg(i)-Pd-Ploss)

Check if the error (1) is less than ε. if yes, go to 20.

12. Check if fit(1)=fit(last) .if yes go to step 19

13. Copy the % Pe chromosomes of old population to new population starting from

the best ones from the top.

14. Perform crossover on selected parents and generate new child chromosomes,
repeat it to get required number of chromosomes.

15. Add all the generated child chromosomes to new population.

16. Perform mutation on all chromosomes.

17. Replace old population with new population.

18. Increment iteration count. If iteration count <max. Iteration, go for next iteration,

else print “problem not converged in maximum number of iterations”.

19. All chromosomes had equal value. Run the program once again by changing GA

parameters.

20. Calculate the total fuel cost .Print the results.


Experiment No: 5

MATLAB GA TOOLBOX VERIFICATION


ECONOMIC LOAD DISPATCH OF THERMAL UNITS INCLUDING LOSSES.

1. Open an M file and define a function with the same name as m file
EX : Function function name = M file name(pop)

2. Read all the required data, a, b, c, demand, P max, Pmin limits, Bcoeff..
3. compute output of each generator
P( j )=(pop - b( j ) )/(2*c( j )) for j=1:no of units

Check whether any generator output hits the max or min limits.

If yes update them with the limits

else go to step 4.

4. Compute the total generated power ( Pgen total).


5. Compute power loss using Bcoeff
6. Compute error =Pgen total – Pd - Ploss.
Note: function name must the objective function which is to be minimized

i.e error( function name must be error).

6. Save the M file and then use GA tool box to run rest of the program.

GA TOOL BOX
1. Enter gatool in command window. GA tool box is displayed out
2. Enter the criterion required
fitness function -> @ name of the m file

no of variables -> 1

All the remaining options in the tool box are set as per the requirement.

3. After setting out all the parameters then click on start button and the final
result is displayed out.
Experiment No: 6

LFC using with Fuzzy Logic tool box

1. Type fuzzy in the command window. Fuzzy Logic tool box is displayed out
2. Set all the parameters in the block. (Set inputs, rule base etc). Then save the file to disk using
export to disk option. Then close the tool box.
(No save option over here. Use export to workspace or export to disk options to save the fis file.
Export to disk saves the current fis file in the system at specified location with .fis extension. Export
to workspace exports the fis file created to the workspace with the name given. Similarly if you want
to open the already saved file, you don’t have open option here. Use import option for this.)

3. Use Simulink and picturise the single area load frequency control block diagram as shown.
Step

100
1
20s+1
den(s)
Fuzzy Logic Add1 Add Transfer Fcn1
Transfer Fcn
Controller Scope
with Ruleviewer

Gain

0.5

Gain1

Derivative

du/dt

den(s)=0.2s2+0.9s+1

4. Again open fuzzy logic tool box. Import the fis file created in step 2 using import from
disk option and check out all the required parameters.

5. The click on fuzzy logic controller with ruleviewer block in simulink. Block parameters block is
displayed. Enter the following in the block
fis matrix -> name of the fis file created in step 2.

refresh rate =2; then click on OK button.

6. Then simulate above circuit in Simulink. The response can be viewed in scope after simulation.
7. Repeat same procedure for 2 area load frequency control.
20

Gain3

change in load
1 1 1
10s+0.6
0.2s+1 0.5s+1
Governer2 Turbine1 Load1

-C-
constant

Scope1 Scope

Fuzzy Logic
Controller
with Ruleviewer

1
1 1 8s+0.9
0.3s+1 0.6s+1 Load2
Governor2 Turbine2

change in load1

16

Gain2

Two area load frequency control.

Experiment No: 7

ECONOMIC LOAD DISPATCH USING PARTICLE SWARM OPTIMIZATION.

1. Read generator data,cost coefficients of generator(a i,bi,ci), P limits, B-coefficients, power


demand(Pd), no. of particles, no. of units, itermax.
2. Initialize learning factors c1,c2, inertia weight w and Max Gen.
3. Generate the population of particles randomly with in the minimum and maximum limits of the
variables.
4. Generate the initial velocities of particles randomly clamped to the range [-vmax to +vmax]
randomly.
5. Set the iteration count=1
6. Set particle count=1
7. Calculate transmission losses (Ploss) using B-coefficient equation.
8. From the cost curve equation calculate incremental fuel cost equation. Substituting Pmin and
Pmax limits calculate lambda min& lambda max.
9. Calculate generations of units corresponding to the lambda.
for i=1 to number of particles

for j=1 to number of units

P(i,j)= [λ(i)-b(i)] / [2*c(i)] and check for power limits.

10. Calculate the fitness of each particle.


fit(i)= 1.0/(1 +abs(error(i))/Pd) where error= P gen-Pd-Ploss.

11. Pbest(i) is set as ith particles initial position; gbest is set as best one of Pbest(i), and the current
Generation number as 1.
12. Update each particles velocity
v k+1 =w i v k + c1 r 1 ( p besti -s k )+c 2 r 2 ( g best −s k )
i i i i

13. . Calculate each particles new fitness, if it is better than previous pbest(i), the current value is set
to be pbest(i). If the pbest(i) is better than gbest, the value is set to be gbest.
14. Gen = Gen+1.

15. If the number of generations is more than or equal to MaxGen then go to Step 15, otherwise go to
step8.
16. The position recorded in gbest is the optimal solution.
17. For all units calculate the fuel cost using
Fuel Cost(i)=a(i)+b(i)*P(i)+C(i)P(i) 2 .
Experiment No: 8
LOAD FORECASTING using ANFIS
1. Type anfisedit in the command window. ANFIS tool box is displayed out.

2. Load the data from the workspace or disc where ever it is stored. Set all the parameters in the
block (no. of. Epochs, algorithm of training, error tolerance etc) and press train button in anfis
GUI.Then save the file to disk using export to disk option. Then close the toolbox.

(Fuzzy inference system(fis) can be choose to generate manually or automatically. If we choose


to generate automatically, anfis toolbox ask us to select no. of. Membership functions for each
input and m.f type for input and m.f type for output. )

3. Use simulink and picturise the load forecasting block diagram as shown.

4. Again open ANFIS toolbox. Import the fis file created in step 2 using import from disk option
and check out all the required parameters.
5. Then click on fuzzy logic controller with rule viewer block in simulink. Block parameters block
is displayed Enter the following in the block

fis matrix -> name of the fis file created in step 2.

Refresh rate =2; then click on OK button.

6. Then simulate above circuit in Simulink. The response can be viewed in scope after simulation.

The Input data should be in a particular format, the format is as shown below

If there are 6 inputs and one output

Topology of ANFIS

i/p 1 i/p 2 i/p 3 i/p 4 i/p 5 i/p 6 o/p


Data 1 Data 1 Data 1 Data 1 Data 1 Data 1 Data 1
- - - - - - -
- - - - - - -
- - - - - - -
- - - - - - -
Data n Data n Data n Data n Data n Data n Data n
dat=[7 988 821 14.56 14.94 15.18 1103;
11 1156 1141 22.78 20.54 23.9 1168;
9 1207 1158 17.23 15.6 20.36 1205;
10 1234 1235 20.49 17.84 22.33 1221;
12 1189 1203 23.83 22.17 25.48 1096;
13 1076 1235 26.16 24.66 27.11 1216;
14 1275 1191 26.69 25.93 27.35 1326;
15 1320 1273 28.54 27.68 28.97 1284;
16 1278 1338 28.88 28.40 28.97 1234;
17 1198 1276 28.14 28.31 27.06 1252;
18 1249 1226 27.11 28.33 24.05 1233;
22 681 767 20.37 21.1 19.3 303;
19 1174 1196 26.41 28.69 23.51 850;
20 832 1228 24.21 26.85 22.83 727;
21 780 857 23.14 24.54 22.22 689;
23 614 711 21.08 22.41 20.23 532;
24 559 641 19.49 20.46 19.71 499;
1 526 578 17.52 17.8 19.33 509;
2 481 467 16.41 16.97 15.94 480;
3 461 467 15.97 16.83 15.32 467;
21 823 918 21.11 21.89 20.46 747;
4 449 444 16.35 15.7 16.28 455;
5 560 531 18.01 18.52 17.58 1033;
6 920 504 19.24 19.95 19.49 1109;
8 1300 1141 15.37 15.81 17.63 1377;
4 476 480 15.65 15.94 16.15 485;
24 578 598 17.8 18.57 18.22 526;
2 519 537 18.05 18.2 17.68 519;
4 465 450 18.62 19.22 17.96 504;
4 454 449 19.19 19.28 19.14 463;
2 439 429 16.36 17.82 15.7 444;
21 767 871 21.1 22.43 20.37 681;
20 850 1174 23.51 26.41 22.1 760;
24 617 651 19.14 19.75 17.59 576;
5 529 522 15.56 16.36 15.56 861;
19 1276 1318 25.75 27.82 22.85 901];

You might also like