1
00:00:00,360 --> 00:00:06,450
Hello and welcome to this lecture, where we are going to generate a new population.

2
00:00:06,930 --> 00:00:16,170
Let's recap all the process we create is the initial population and then evaluate it's in this part

3
00:00:16,170 --> 00:00:17,670
of the implementation.

4
00:00:18,030 --> 00:00:27,960
We are not considering this stopping there yet, but now we have all these functions here, select various

5
00:00:27,960 --> 00:00:29,940
crossover mutation.

6
00:00:30,270 --> 00:00:39,090
Then, after generating a new population, which is the application of crossover and mutation, we need

7
00:00:39,100 --> 00:00:42,120
to evaluate the population again.

8
00:00:42,480 --> 00:00:53,460
But now we will evaluate the new population that will be generated using crossover and mutation, and

9
00:00:53,460 --> 00:00:57,240
that's what we are going to implement in this lecture.

10
00:00:57,570 --> 00:01:04,050
Moving back to our Google collab file, I will open a new set of codes.

11
00:01:04,440 --> 00:01:11,490
Let's create a new variable new population and am the least.

12
00:01:12,000 --> 00:01:23,350
Let's also define the mutational probability equals zero point zero one, which means one percent.

13
00:01:23,760 --> 00:01:38,280
And let's implement a far loop for new individuals in range from zero to genetic algorithm population

14
00:01:38,280 --> 00:01:39,060
size.

15
00:01:39,630 --> 00:01:44,490
Let's bring out the new individuals variable.

16
00:01:45,060 --> 00:01:55,500
We can run this code, see that we are going through position zero two position nine thin, which means

17
00:01:55,500 --> 00:02:05,440
this size of our population and to generate a new population, we are going to use the crossover function.

18
00:02:05,790 --> 00:02:09,210
We can take a look at the differential here.

19
00:02:09,540 --> 00:02:18,180
It belongs to the individual Class C that we are returning to Childs.

20
00:02:18,450 --> 00:02:26,580
So when we run crossover only once there is old is two new individuals.

21
00:02:27,060 --> 00:02:33,930
So if we run these codes that way, it is defined in the here.

22
00:02:34,290 --> 00:02:46,380
So after running this far loop, here we will and we've for the individuals because in each one of these

23
00:02:46,380 --> 00:02:51,480
runs here, the result will be two individuals.

24
00:02:51,840 --> 00:02:59,280
So we will increase the size of the population birds when we work with genetic algorithms.

25
00:02:59,610 --> 00:03:07,650
The most common is to keep this same size so we can put an additional parameter here.

26
00:03:08,160 --> 00:03:15,630
Number two, it means that we are not going to run these codes one by one.

27
00:03:15,990 --> 00:03:22,200
Now we will run two by two zero two four six eight.

28
00:03:22,200 --> 00:03:23,340
And so one.

29
00:03:23,790 --> 00:03:27,030
Now we need to select two parents.

30
00:03:28,050 --> 00:03:31,230
We will create the new variable variants.

31
00:03:31,230 --> 00:03:37,350
One equals genetic algorithm, select parents.

32
00:03:37,800 --> 00:03:48,740
Let's send the here this sum, and I will also create parents to genetic algorithm, select parents.

33
00:03:48,750 --> 00:03:50,910
And how will PWDs here year?

34
00:03:50,910 --> 00:03:57,780
Also this so we can just go up to the class, the genetic algorithm.

35
00:03:58,050 --> 00:04:05,460
And I will put this Branston comments just to be easier to visualize with the results.

36
00:04:05,880 --> 00:04:10,140
Let's create again the genetic algorithm glass.

37
00:04:10,930 --> 00:04:17,820
I will go back to these barred to here where we are creating the population.

38
00:04:18,060 --> 00:04:20,850
We can run all this code again.

39
00:04:21,570 --> 00:04:25,830
Here we are, set the the best in the video.

40
00:04:26,730 --> 00:04:33,540
We can see that the new some value is one hundred and seventy.

41
00:04:33,870 --> 00:04:37,440
And now let's go back to this part here.

42
00:04:37,740 --> 00:04:43,650
We can friends' parents one and parents.

43
00:04:43,650 --> 00:04:44,130
Sure.

44
00:04:44,550 --> 00:04:50,790
And I will put at the beginning this school months choose Keep the line.

45
00:04:51,480 --> 00:04:59,860
For example, in the first section, we will combine individual zero with individual.

46
00:04:59,980 --> 00:05:07,060
Almost zero as the result is the same, we will combine the same individuals.

47
00:05:07,300 --> 00:05:09,910
So the result will be the same.

48
00:05:10,270 --> 00:05:15,010
If you want, you can implement an additional all the here.

49
00:05:15,280 --> 00:05:22,150
If you don't want to return, this same parents in this section is a crucial.

50
00:05:22,510 --> 00:05:31,180
We will combine 11 with three five nine five two seven nine.

51
00:05:31,180 --> 00:05:41,770
And so one, as we saw in the theoretical lecture, the probability of selecting the best individuals

52
00:05:42,130 --> 00:05:49,870
are higher than the probability of selecting the worst individuals to hear at the end.

53
00:05:50,260 --> 00:06:01,300
Because of that, you can see that we are selecting the individuals that are at the first positions

54
00:06:01,300 --> 00:06:02,200
of the list.

55
00:06:02,620 --> 00:06:07,840
The worst individual that was selected was 11.

56
00:06:08,110 --> 00:06:16,030
We can take a look at the value here, individual 11 and here is the solution.

57
00:06:16,330 --> 00:06:23,140
But in none of these equations we select, it's these bad solutions.

58
00:06:23,440 --> 00:06:29,320
For example, 14 15 where this score equals one.

59
00:06:29,620 --> 00:06:36,460
So these solutions are bad because we cannot load the products on the truck.

60
00:06:36,790 --> 00:06:41,560
This is the first step to generate a new population.

61
00:06:41,860 --> 00:06:44,620
We need to select the parents.

62
00:06:45,010 --> 00:06:53,860
Now let's create the children equals genetic algorithm population.

63
00:06:54,310 --> 00:07:06,050
Let's select parents one and we are going to call the cross over functional and we'll sans population.

64
00:07:06,850 --> 00:07:07,480
Parents.

65
00:07:08,860 --> 00:07:10,690
In this saccone's equation.

66
00:07:11,020 --> 00:07:15,700
We are combining 11 with three in the third.

67
00:07:15,910 --> 00:07:17,860
Five with four nine.

68
00:07:17,860 --> 00:07:21,580
And so one, we can bring the results.

69
00:07:22,880 --> 00:07:36,680
Brent's genetic algorithm, but population parents, one but chromosome we can all brands, population,

70
00:07:37,070 --> 00:07:43,280
parents, true, but chromosome we can run.

71
00:07:43,280 --> 00:07:47,360
This code suggests you see the partial results.

72
00:07:47,660 --> 00:07:50,030
Now we have different values.

73
00:07:50,450 --> 00:07:59,300
We selected Position Zero, which is the best solution because it is in the first position of the list

74
00:07:59,660 --> 00:08:04,580
and we are combining with solution number five.

75
00:08:05,210 --> 00:08:16,460
Then we select then, which is the these chromosome here and we are combining with nine these chromosome

76
00:08:16,460 --> 00:08:16,910
here.

77
00:08:17,180 --> 00:08:23,840
And we keep combining the chromosomes using crossover after dads.

78
00:08:24,050 --> 00:08:28,030
We can see the children that were generated.

79
00:08:28,580 --> 00:08:45,380
Brian's children was these zero dots chromosome and also children in position one dots chromosome.

80
00:08:45,860 --> 00:08:48,170
Let's run this code again.

81
00:08:48,440 --> 00:08:51,110
We will get different values.

82
00:08:51,590 --> 00:08:58,460
We are combining individual number three with individual number one.

83
00:08:59,330 --> 00:09:07,010
These two lines represent the chromosome of the regional parents.

84
00:09:07,340 --> 00:09:10,340
And these are their two lines.

85
00:09:10,340 --> 00:09:13,610
Each represents the combination.

86
00:09:13,820 --> 00:09:17,390
We are applying the cross over function.

87
00:09:17,900 --> 00:09:23,360
And now we need to access the new population list.

88
00:09:23,870 --> 00:09:25,190
Let's set bands.

89
00:09:25,190 --> 00:09:30,320
The new individuals, children position zero.

90
00:09:30,590 --> 00:09:37,430
And then we can apply the mutation in order to change some of the genes.

91
00:09:37,910 --> 00:09:53,060
Let's send the here mutation probability new population dots, bands, children position one again mutation,

92
00:09:53,060 --> 00:09:57,050
and let's send the here mutation probability.

93
00:09:57,410 --> 00:09:59,660
Let's run this code again.

94
00:10:00,110 --> 00:10:05,150
We can see the massagers related to the mutation.

95
00:10:05,690 --> 00:10:10,670
For example, let's review this first execution.

96
00:10:10,970 --> 00:10:16,760
We are selecting solution number three of the original population.

97
00:10:17,240 --> 00:10:27,830
It is this chromosome here and solution our individual number nine, which is the first chromosome here.

98
00:10:28,290 --> 00:10:31,190
Then we apply crossover.

99
00:10:31,760 --> 00:10:37,460
And as a result, we have these two combinations here.

100
00:10:37,700 --> 00:10:41,540
We are combining three with nine.

101
00:10:41,960 --> 00:10:47,660
Then we are applying mutation with one percent probability.

102
00:10:47,930 --> 00:10:50,600
We have a before and after.

103
00:10:51,080 --> 00:10:55,370
We can see that it was a curated for our children.

104
00:10:55,370 --> 00:11:00,350
Number one, the original value was zero.

105
00:11:00,590 --> 00:11:10,520
And then we change its H1 and then you can see all the results here, according to the individuals that

106
00:11:10,520 --> 00:11:11,810
were selected.

107
00:11:12,230 --> 00:11:16,520
And this is how you can create a new generation.

108
00:11:17,120 --> 00:11:27,500
However, that codes is creating only one new generation, and we need to create several new generations.

109
00:11:27,890 --> 00:11:38,600
So in the next lecture, we are going to start working with this stop being reburial so we can define

110
00:11:38,600 --> 00:11:48,170
the number of generations that we may use in order to have the final result of the genetic algorithm.

111
00:11:48,620 --> 00:11:49,340
So there?
