AI Lab Manual
AI Lab Manual
List of Experiments
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.
Step4: Normalize input vectors and target vectors (expected output) using
Train output=((train output)-min)/(max-min))*0.8+0.1
(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 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
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
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.
error(i)=abs(Pg(i)-Pd-Ploss)
13. Copy the % Pe chromosomes of old population to new population starting from
14. Perform crossover on selected parents and generate new child chromosomes,
repeat it to get required number of chromosomes.
18. Increment iteration count. If iteration count <max. Iteration, go for next iteration,
19. All chromosomes had equal value. Run the program once again by changing GA
parameters.
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.
else go to step 4.
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
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.
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
Experiment No: 7
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.
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
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
Topology of ANFIS