1
00:00:00,690 --> 00:00:08,340
Hello and welcome to this lecture, where we are going to implement another function in the genetic

2
00:00:08,340 --> 00:00:15,750
algorithm class, we already implemented the creation of the initial population.

3
00:00:16,080 --> 00:00:20,880
And we also have already evaluated the population.

4
00:00:21,270 --> 00:00:31,710
Now we are going to move on should this part here, select parents, because in order to apply crossover

5
00:00:31,710 --> 00:00:40,500
and mutation, we need to select some of the parents who created the new generation.

6
00:00:40,830 --> 00:00:47,800
So we will implement an additional function then in the next two lectures.

7
00:00:47,820 --> 00:00:57,000
You are going to learn how to use this function to select the parents moving back to the Google collab

8
00:00:57,000 --> 00:00:57,630
file.

9
00:00:58,070 --> 00:01:00,720
I will create a new function.

10
00:01:01,440 --> 00:01:09,420
They have some evaluations and it will not receive any parameter.

11
00:01:09,810 --> 00:01:20,790
As the name suggests, we are going to some all the prizes off each one of the individuals in our sample

12
00:01:21,000 --> 00:01:33,990
that are 20 individuals and each individual has a value, which is the score evaluation which is calculated

13
00:01:34,050 --> 00:01:36,360
using the fitness function.

14
00:01:36,660 --> 00:01:44,160
It is this some of the prices of the products that we are going to load on this drug.

15
00:01:44,670 --> 00:01:54,600
This function will go through each one of the individuals and we are going to add this value in order

16
00:01:54,600 --> 00:01:56,280
to return this sum.

17
00:01:56,700 --> 00:02:02,250
Don't worry now about understanding why we needed this value.

18
00:02:02,550 --> 00:02:06,720
It will be explained in the next two lectures.

19
00:02:07,320 --> 00:02:17,730
Let's create a variable quote some, and let's go through each one of the individuals for individual

20
00:02:18,190 --> 00:02:21,300
in cell population.

21
00:02:21,630 --> 00:02:25,310
We are accessing this list here.

22
00:02:26,340 --> 00:02:38,910
Some B+ equal in the video, but score evaluation Etienne's after executing the far loop.

23
00:02:39,360 --> 00:02:42,000
Let's just return this sum.

24
00:02:42,300 --> 00:02:45,440
It's a very simple and easy function.

25
00:02:45,810 --> 00:02:48,120
Let's create the glass again.

26
00:02:49,290 --> 00:02:50,250
Go back.

27
00:02:50,610 --> 00:03:00,000
Should this part of the codes where we are creating the new population, we can just check this brand

28
00:03:00,000 --> 00:03:02,340
see here, just just see the values.

29
00:03:02,910 --> 00:03:04,980
Run this code again.

30
00:03:05,490 --> 00:03:08,940
Just a reminder that's in position No.

31
00:03:08,950 --> 00:03:09,600
Zero.

32
00:03:09,750 --> 00:03:12,420
We can see the best solution.

33
00:03:12,720 --> 00:03:23,010
And the goal of this function is to go through each one of these individuals and adds, all these values

34
00:03:23,010 --> 00:03:30,060
here discard off each one of the individuals we can fast.

35
00:03:30,480 --> 00:03:32,820
They function we implemented before.

36
00:03:33,330 --> 00:03:36,450
The current best solution is third.

37
00:03:36,610 --> 00:03:40,830
In thousands, we can see the best solution.

38
00:03:41,040 --> 00:03:42,750
16000.

39
00:03:43,050 --> 00:03:51,300
Now we can call our function should change the best in the video we can see here.

40
00:03:51,300 --> 00:03:53,490
That's now the best solution.

41
00:03:53,970 --> 00:03:56,160
Is these one here?

42
00:03:56,550 --> 00:03:58,770
We can also see the chromosome.

43
00:03:59,130 --> 00:04:01,260
And finally, let's open.

44
00:04:01,260 --> 00:04:06,060
A new sale of codes should test our new function.

45
00:04:06,580 --> 00:04:16,740
We'll create a new variable sum equals genetic algorithm, and let's just go some evaluations.

46
00:04:17,100 --> 00:04:27,750
We can bring into the results some of evaluations, but here is some run this code.

47
00:04:28,020 --> 00:04:38,220
See, that's the sum of all scores in this population is one hundred and ninety six thousand.

48
00:04:38,670 --> 00:04:44,940
Just a reminder, it is this sum of all these values here.

49
00:04:45,300 --> 00:04:52,770
And in the next lecture, you are going to understand how to select the parents.

50
00:04:53,040 --> 00:05:03,270
And right after we will move back to the Google collab and we will use this sum to select the best individuals

51
00:05:03,450 --> 00:05:06,420
to apply crossover and mutation.

52
00:05:06,840 --> 00:05:07,530
See you there!
