Revision
Revision
INTELLIGENCE
DR. MANAL TANTAWI
ASSOCIATE PROFESSOR
IN
SCIENTIFIC COMPUTING DEPARTMENT
FACULTY OF COMPUTER & INFORMATION
SCIENCES
AIN SHAMS UNIVERSITY
PART 7
➢Revision
PARTICLE SWARM OPTIMIZATION (PSO)
Consider maximizing the following function:
F(x, y) = ( 2x + y – 2 )(x + 2y +1)
we have three particles (Bees) searching for the optimum values for variables x and y and the status
after first iteration is as in the following table:
Velocity of bee 2
Inertia + cognitive component + Social component
0.1 * 0 + (0.3*0.4) dis ([ -2, 1] , [-2, 1] ) + (0.4 * 0.5) dis ([4, 3] , [-2, 1])
0 + 0 + 0.4 * 0.5 * 6.3245
0 + 0 + 1.265= 1.265
Velocity of bee 3
Inertia + cognitive component + Social component
0.1 * 0 + (0.3*0.4) dis ([ 3, -1] , [3, -1] ) + (0.4 * 0.5) dis ([4, 3] , [3, -1])
0 + 0 + 0.4 * 0.5 * 4.123
0 + 0 + 0.824 = 0.824
SOLUTION
F(x, y) = ( 2x + y – 2 )(x + 2y +1)
Dis = 11
P=9
A
Dis = 14
C
P = 11
Dis = 9
P=7
D
B
Best parents
C2 1 1 0 1 8
C4 1 0 1 0 6
GENETIC ALGORITHMS
First parent
C2 1 1 0 1 8
C1 0 0 1 1 5
single point crossover (assume the random integer is 2) Mutation random integers 2, 1
for these offsprings respectively
Offspring 1 1 1 1 Offspring
1 1
1 0 1 1 9
Offspring 0 0 0 1 Offspring
2 2
1 0 0 1 7
GENETIC ALGORITHMS
First parent
C4 1 0 1 0 6
C2 1 1 0 1 8
single point crossover (assume the random integer is 2) Mutation random integers 2, 1
for these offsprings respectively
Offspring 1 0 0 1 Offspring
1 3
1 1 0 1 8
Offspring 1 1 1 0 Offspring
2 4
0 1 1 0 3
GENETIC ALGORITHMS
Choose next generation
APPLY SINGLE POINT CROSSOVER ON THE FOLLOWING TWO PARENTS TO GENERATE TWO
OFFSPRINGS ( CONSIDER THE NEEDED RANDOM INTEGER = 1)
C1 2 4 0 0
C5 1 5 1 0
Solution
C1 2 5 1 0
C5 1 4 0 0
GENETIC ALGORITHMS
For genes ranged from 0 to 10, apply boundary mutation on a randomly selected
gene and show the resulted chromosome if the mutation random integer = 3
0 4 3 2 1 0 6 8 5 2
Solution
0 4 10 2 1 0 6 8 5 2
GENETIC ALGORITHMS
For the following binary encoded offspring, apply mutation with rate 0.4 and show the resulted chromosome.
Genes 0 1 1 0 1 0 1 0 1 0
Random Numbers 0.6 0.5 0.1 0.55 0.8 0.72 0.25 0.3 0.78 0.15
Solution
0 1 0 0 1 0 0 1 1 1
0.6 0.5 0.1 0.55 0.8 0.72 0.25 0.3 0.78 0.15
GAME PLAYING
Calculate the scores for the following game tree
max
Agent is x
Player is o
Agent winning score is +10 -10 0
min
Player winning score is -10
+10
max
-10 0 +10 0
0 +10 0
GAME PLAYING
Apply alpha-beta pruning on the following game tree
GAME PLAYING
Apply alpha-beta pruning on the following game tree
a=7
b=∞ 7
Solution
a =-∞ a=7
b=7 b=1
7 1
a= 8 a=7
b= 7 b=∞
a=7 7
b=∞ 8 1
SOLVING MAZE USING A*
(2,2) 2+5
(3,2) 3+4
(3,2) 3+2
(3,3) 4+1
(F 8)
(E 11)
(A 16)
(C 23)
(E 11)
(A 16)
(C 23)