650 likes | 742 Views
Genetic Algorithms W02. What is randomness?. What is randomness?. Having no specific pattern, purpose, or objective; lacking a definite plan, purpose, or pattern. What is probability?. What is probability?. The quality or condition of being probable; likelihood.
E N D
What is randomness? Having no specific pattern, purpose, or objective; lacking a definite plan, purpose, or pattern
What is probability? • The quality or condition of being probable; likelihood. • 2. A probable situation, condition, or event. • 3.a. The likelihood that a given event will occur. • b. Statistics. A number expressing the likelihood that a specific event will occur, expressed as the ratio of the number of actual occurrences to the number of possible occurrences.
001001001001001001001001001001001001001001001001001001001 000000000000100000000100000000000001000001000100000000001 010100111010001101001010111010010001110101001011010100010
001001001001001001001001001001001001001001001001001001001 000000000000100000000100000000000001000001000100000000001 010100111010001101001010111010010001110101001011010100010
$k = 0; while(true){ string $genome = (int)rand(2) + "" + (int)rand(2) + (int)rand(2) + (int)rand(2); print(($k++) + " " + $genome + "\n"); if($genome=="0011")break; };
$k = 0; while(true){ string $genome = (int)rand(2) + "" + (int)rand(2) + (int)rand(2) + (int)rand(2); print(($k++) + " " + $genome + "\n"); if($genome=="0011")break; }; 0 0001 1 0101 2 0111 3 1000 4 0011
$k = 0; while(true){ string $genome = (int)rand(2) + "" + (int)rand(2) + (int)rand(2) + (int)rand(2); print(($k++) + " " + $genome + "\n"); if($genome=="0011")break; }; 0 0001 1 0101 2 0111 3 1000 4 0011 0 1000 1 1000 2 1011 3 1111 4 0001 5 0111 6 1111 7 0000 8 0010 9 1111 10 1100 11 1001 12 1011 13 0110 14 0100 15 1000 16 1001 17 1100 18 0101 19 1011 20 0100 21 0101 22 0110 23 0111 24 0001 25 0011
$k = 0; while(true){ string $genome = (int)rand(2) + "" + (int)rand(2) + (int)rand(2) + (int)rand(2); print(($k++) + " " + $genome + "\n"); if($genome=="0011")break; }; 0 0001 1 0101 2 0111 3 1000 4 0011 0 1000 1 1000 2 1011 3 1111 4 0001 5 0111 6 1111 7 0000 8 0010 9 1111 10 1100 11 1001 12 1011 13 0110 14 0100 15 1000 16 1001 17 1100 18 0101 19 1011 20 0100 21 0101 22 0110 23 0111 24 0001 25 0011 0 0011
$k = 0; while(true){ string $genome = (int)rand(2) + "" + (int)rand(2) + (int)rand(2) + (int)rand(2); print(($k++) + " " + $genome + "\n"); if($genome=="0011")break; }; 0 0001 1 0101 2 0111 3 1000 4 0011 0 1000 1 1000 2 1011 3 1111 4 0001 5 0111 6 1111 7 0000 8 0010 9 1111 10 1100 11 1001 12 1011 13 0110 14 0100 15 1000 16 1001 17 1100 18 0101 19 1011 20 0100 21 0101 22 0110 23 0111 24 0001 25 0011 0 0011 0 1011 1 0101 2 1001 3 1000 4 1011 5 1000 6 1011 7 0101 8 1110 9 1011 10 1101 11 0111 12 0101 13 1011 14 1110 15 1011 16 1110 17 0101 18 0100 19 1001 20 0000 21 1000 22 1110 23 0011
$k = 0; while(true){ string $genome = (int)rand(2) + "" + (int)rand(2) + (int)rand(2) + (int)rand(2); print(($k++) + " " + $genome + "\n"); if($genome=="0011")break; }; 0 0001 1 0101 2 0111 3 1000 4 0011 0 1000 1 1000 2 1011 3 1111 4 0001 5 0111 6 1111 7 0000 8 0010 9 1111 10 1100 11 1001 12 1011 13 0110 14 0100 15 1000 16 1001 17 1100 18 0101 19 1011 20 0100 21 0101 22 0110 23 0111 24 0001 25 0011 0 0011 0 1011 1 0101 2 1001 3 1000 4 1011 5 1000 6 1011 7 0101 8 1110 9 1011 10 1101 11 0111 12 0101 13 1011 14 1110 15 1011 16 1110 17 0101 18 0100 19 1001 20 0000 21 1000 22 1110 23 0011 0 1010 1 0001 2 1011 3 0100 4 0100 5 0111 6 1100 7 0100 8 1100 9 0111 10 0001 11 0001 12 0010 13 1000 14 1000 15 1110 16 0100 17 1000 18 0001 19 0100 20 1011 21 1111 22 0111 23 1010 24 1001 25 1111 26 1101 27 1110 28 0101 29 1111 30 0011
$k = 0; while(true){ string $genome = (int)rand(2) + "" + (int)rand(2) + (int)rand(2) + (int)rand(2); print(($k++) + " " + $genome + "\n"); if($genome=="0011")break; }; 0 0001 1 0101 2 0111 3 1000 4 0011 0 1000 1 1000 2 1011 3 1111 4 0001 5 0111 6 1111 7 0000 8 0010 9 1111 10 1100 11 1001 12 1011 13 0110 14 0100 15 1000 16 1001 17 1100 18 0101 19 1011 20 0100 21 0101 22 0110 23 0111 24 0001 25 0011 0 0011 0 1011 1 0101 2 1001 3 1000 4 1011 5 1000 6 1011 7 0101 8 1110 9 1011 10 1101 11 0111 12 0101 13 1011 14 1110 15 1011 16 1110 17 0101 18 0100 19 1001 20 0000 21 1000 22 1110 23 0011 0 1010 1 0001 2 1011 3 0100 4 0100 5 0111 6 1100 7 0100 8 1100 9 0111 10 0001 11 0001 12 0010 13 1000 14 1000 15 1110 16 0100 17 1000 18 0001 19 0100 20 1011 21 1111 22 0111 23 1010 24 1001 25 1111 26 1101 27 1110 28 0101 29 1111 30 0011 0 1000 1 0000 2 1000 3 0110 4 1000 5 0101 6 0111 7 1010 8 1100 9 1001 10 1101 11 0110 12 1111 13 1011 14 0011
$k = 0; while(true){ string $genome = (int)rand(2) + "" + (int)rand(2) + (int)rand(2) + (int)rand(2); print(($k++) + " " + $genome + "\n"); if($genome=="0011")break; }; 0 0001 1 0101 2 0111 3 1000 4 0011 0 1000 1 1000 2 1011 3 1111 4 0001 5 0111 6 1111 7 0000 8 0010 9 1111 10 1100 11 1001 12 1011 13 0110 14 0100 15 1000 16 1001 17 1100 18 0101 19 1011 20 0100 21 0101 22 0110 23 0111 24 0001 25 0011 0 0011 0 1011 1 0101 2 1001 3 1000 4 1011 5 1000 6 1011 7 0101 8 1110 9 1011 10 1101 11 0111 12 0101 13 1011 14 1110 15 1011 16 1110 17 0101 18 0100 19 1001 20 0000 21 1000 22 1110 23 0011 0 1010 1 0001 2 1011 3 0100 4 0100 5 0111 6 1100 7 0100 8 1100 9 0111 10 0001 11 0001 12 0010 13 1000 14 1000 15 1110 16 0100 17 1000 18 0001 19 0100 20 1011 21 1111 22 0111 23 1010 24 1001 25 1111 26 1101 27 1110 28 0101 29 1111 30 0011 0 1000 1 0000 2 1000 3 0110 4 1000 5 0101 6 0111 7 1010 8 1100 9 1001 10 1101 11 0110 12 1111 13 1011 14 0011 0 0101 1 0010 2 0000 3 1001 4 1111 5 0000 6 1000 7 1111 8 0110 9 1001 10 0110 11 0111 12 0110 13 1111 14 1000 15 1111 16 1111 17 0010 18 0010 19 0101 20 1010 21 0110 22 1010 23 1001 24 0010 25 0100 26 1100 27 0111 28 1111 29 1111 30 0111 31 0011
$acc = 0; for($i=0; $i<100; $i++){ $k = 0; while(true){ string $genome = (int)rand(2) + "" + (int)rand(2) + (int)rand(2) + (int)rand(2); $k++; if($genome=="0011")break; }; $acc += $k; }; print(($acc/$i));
$acc = 0; • for($i=0; $i<100; $i++){ • $k = 0; • while(true){ • string $genome = (int)rand(2) + "" + (int)rand(2) + (int)rand(2) + (int)rand(2); • $k++; • if($genome=="0011")break; • }; • $acc += $k; • }; • print(($acc/$i)); • 15 • 16 • 16 • 17 • 14 • 15 • 15 • 16 • 17 • 17 • …
001010 a) 110100 b) 111101 c) 011011 d) 101100
001010 a) 110100 b) 111101 c) 011011 d) 101100 a 110100 score 1 b 111101 score 1 c 011011 score 4 d 101100 score 3
001010 a) 110100 b) 111101 c) 011011 d) 101100 a 110100 score 1 b 111101 score 1 c 011011 score 4 d 101100 score 3 4. Crossover: take first 2 digits of c + last 4 of d: e 011100 5. Crossover: take first 2 digits of d + last 4 of c: f 101011 6. Crossover: take first 4 c + last 2 d: g 011000 7. Crossover: take first 4 d + last 2 c: h 101111
001010 a) 110100 b) 111101 c) 011011 d) 101100 a 110100 score 1 b 111101 score 1 c 011011 score 4 d 101100 score 3 4. Crossover: take first 2 digits of c + last 4 of d: e 011100 5. Crossover: take first 2 digits of d + last 4 of c: f 101011 6. Crossover: take first 4 c + last 2 d: g 011000 7. Crossover: take first 4 d + last 2 c: h 101111 e 011100 score 3 f 101011 score 4 g 011000 score 4 h 101111 score 3
001010 a) 110100 b) 111101 c) 011011 d) 101100 a 110100 score 1 b 111101 score 1 c 011011 score 4 d 101100 score 3 4. Crossover: take first 2 digits of c + last 4 of d: e 011100 5. Crossover: take first 2 digits of d + last 4 of c: f 101011 6. Crossover: take first 4 c + last 2 d: g 011000 7. Crossover: take first 4 d + last 2 c: h 101111 e 011100 score 3 f 101011 score 4 g 011000 score 4 h 101111 score 3 10. Crossover 1st f + last 5 g: i 111000 11. Crossover 1st g + last 5 f: j 001011 12. Crossover first 3 f + last 3 g: k 101000 13. Crossover first 3 g + last 3 f: l 011011 15. Crossover 1st 5 j + last 1 k: m 001010
001010 a) 110100 b) 111101 c) 011011 d) 101100 a 110100 score 1 b 111101 score 1 c 011011 score 4 d 101100 score 3 4. Crossover: take first 2 digits of c + last 4 of d: e 011100 5. Crossover: take first 2 digits of d + last 4 of c: f 101011 6. Crossover: take first 4 c + last 2 d: g 011000 7. Crossover: take first 4 d + last 2 c: h 101111 e 011100 score 3 f 101011 score 4 g 011000 score 4 h 101111 score 3 10. Crossover 1st f + last 5 g: i 111000 11. Crossover 1st g + last 5 f: j 001011 12. Crossover first 3 f + last 3 g: k 101000 13. Crossover first 3 g + last 3 f: l 011011 15. Crossover 1st 5 j + last 1 k: m 001010 i 111000 score 3 j 001011 score 5 k 101000 score 4 l 011011 score 4 m 001010 score 6 = solution in 13 guesses
0 Best: lRDt2 p:h4do fitness: 10 5 Best: Je51+ wAr\d! fitness: 6 10 Best: HeQ7o wAr[d! fitness: 4 15 Best: Hex:o w9r=d! fitness: 4 20 Best: He8$o wWr9d! fitness: 4 25 Best: HeM$o wQrsd! fitness: 4 30 Best: HeELo worsd! fitness: 3 35 Best: He4xo worrd! fitness: 3 40 Best: Hew]o worVd! fitness: 3 45 Best: Hew,o worod! fitness: 3 50 Best: He7<o worjd! fitness: 3 55 Best: He]\o worKd! fitness: 3 60 Best: He.Mo world! fitness: 2 65 Best: Hel)o world! fitness: 1 70 Best: Qello world! fitness: 1 73 Best: Hello world! fitness: 0
P = {(x, y, c) x, y, c N, 0x<w, 0y<h, 0c<d } where w=132, h=193, and d=2. So, possible combinations are 2 (132 x 193) = 1.097669
Designer A designs home for client B Designer A designs home for client C C A B
D Designer A designs home for client B Designer A designs home for client C Designer A designs home for client D C A B
D Designer A designs home for client B Designer A designs home for client C Designer A designs home for client D Designer A designs home for client E C A E B
D Designer A designs home for client B Designer A designs home for client C Designer A designs home for client D Designer A designs home for client E Designer A designs home for client F … C A E B F
D Designer A designs home for client B Designer A designs home for client C Designer A designs home for client D Designer A designs home for client E Designer A designs home for client F … Designer A designs home for client A C A E B F
You know that you know You know that you do not know
You know that you know You know that you do not know You do not know that you know
You know that you know You know that you do not know You do not know that you know You do not know that you do not know