Genetic Algorithm Questions: Q 1) Using a genetic algorithm find the minimum value for the following function () = − , 0 ≤ x ≤ 10 Where is 6 chromosome for each generation and the length of a chromosome 4-bits? Solution: Step 1: Represent the problem variable domain as a chromosome of a fixed length # of chromosome in each generation N= 6 length of chromosome is 4bit Step 2: Define a fitness function It’s F(x ) Step 3: Randomly generate an initial population of chromosomes of size N=6 Decoded integer Chromosome string Chromosome label 4 0 1 0 0 1 X 1 0 0 0 1 2 X 5 0 1 0 1 3 X 9 1 0 0 1 4 X 2 0 0 1 0 5 X 7 0 1 1 1 6 X Step 4: Calculate the fitness of each individual chromosome and compute ratio The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering ECOM5039:Artificial Intelligence Eng. Ibraheem Lubbad
7
Embed
Genetic Algorithm - Islamic University of Gazasite.iugaza.edu.ps/.../files/2017/02/Genetic-Algorithm.pdf · 2017-05-15 · Genetic Algorithm Questions: Q 1) Using a genetic algorithm
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Genetic Algorithm
Questions:
Q 1) Using a genetic algorithm find the minimum value for the following function
𝑭(𝒙) = 𝒙𝟐 − 𝟏𝟎𝒙 , 0 ≤ x ≤ 10
Where is 6 chromosome for each generation and the length of a chromosome 4-bits?
Solution:
Step 1: Represent the problem variable domain as a chromosome of a fixed length
# of chromosome in each generation N= 6
length of chromosome is 4bit
Step 2: Define a fitness function
It’s F(x )
Step 3: Randomly generate an initial population of chromosomes of size N=6
Decoded
integer
Chromosome string Chromosome label
4 0 1 0 0 1X
1 0 0 0 1 2X
5 0 1 0 1 3X
9 1 0 0 1 4X
2 0 0 1 0 5X
7 0 1 1 1 6X
Step 4: Calculate the fitness of each individual chromosome and compute ratio
The Islamic University of Gaza
Faculty of Engineering
Dept. of Computer Engineering
ECOM5039:Artificial Intelligence
Eng. Ibraheem Lubbad
التي تعطي اقل قيمة xالمطلوب في السؤال إيجاد قيمة انفي المرحلة التالية , بما الكرموسوماحتمالية اختيار تمثل ratioقيمة
00و 0بين في الفترة
.على المجموع الكرموسوم قسمة قيمة chromosomeطريقة حسابها لكل
Ratio % Chromosome fitness Chromosome label
80.02 F( X1 )=-24 X1
2..8 -9 X2
.0.8. -25 X3
2..8 -9 X4
08.02 -0. X5
8.80
.
-21 X6
Sum = -104
تاخذ اكبر احتمال (اقل قيمة اي ) فان القيمة التي الها اعلى سالبية لذالك بسالب fitness الحظ كل كل قيم
Step 5: Select a pair of chromosomes for mating from the current population
لذا احتمالية كرموسوملكل ratio, حسب قيم Roulette wheel selectionعن طريق عملية االختيار تتم بشكل العشوائي
.اكبر الرقم االقل اختيار
Step 6: Create a pair of offspring chromosomes by applying the genetic operators - crossover and
mutation
geneticفي المرحلة السابقة يتم تطبيق عليهم احدي عمليات ال chromosemeبعد ان تم اختيار زوج من
Crossover او mutation
جدا ضئيلةوتحدث بنسبة cross over ليةتكون بانقالب جين واحد من الكرموسوم بعد عم ) الطفرة (: mutationعملية
لجيل افراد في ا ليصبحوا بعد ذالك ان الكرموسوم ما بعد النقطة في تبادل اجزاء عندها يتم تحديد نقطة يتم crossoverفي عملية
الجديد
X 0: 0 1 0 0 X’0: 0 1 0 1
X 4: 1 0 0 1 X’4 1 0 0 0
Step 7: Place the created offspring chromosomes in the new population
Step 8: Repeat Step 5:
.لحتى يتم توليد جميع الكرمسومات الجبل الجديد التي يجب ان يكون عددها
X 0: 0 1 0 0 X’0: 0 0 0 0
X 8: 0 0 0 0 X’8 :0 0 0 0
,X 0: 0 1 0 0 X’’0: 0 1 0 0
X 8: 0 0 0 0 X’’8 : 0 0 0 0
Step 9: Replace the initial (parent) chromosome population with the new (offspring) population
Decoded
integer
Chromosome string Chromosome label
5 0 1 0 1 X1
8 1 0 0 0 X2
4 0 0 0 0 X3
3 0 0 0 0 X4
7 0 1 0 1 X5
1 0 0 0 0 X6
Step 01:
x للقيم الجديدة وتكرار العمليات حتى إيجاد قيمة fittnes وحساب قيمة الرابعة بعد ايجاد قيم الجيل الجديد يتم الرجوع للخطوة
خالل النهائي اي اقل قيمة لدالة يكون الحل بعد إجراء العمليات السابقة عدة مرات اقل قيمة , في هذا السؤالعندها الدالة التي تعطي
x= 5 عند الفترة المحددة
الهدف من السؤال فهم االلية التي يتم من خاللها حساب المطلوب
Q 2) Using a genetic algorithm find the minimum value for the following function
F(𝑥1, 𝑥2)= (𝑥1 2 + 𝑥2 − 11 )2 + (𝑥1 + 𝑥2
2 + −7 )2 , 0 ≤ 𝑥1 , 𝑥2 ≤ 6
Where is 6 chromosome for each generation and the length of a chromosome 8 bits for each X’s ?
Solution:
Step 1: Represent the problem variable domain as a chromosome of a fixed length