1
00:00:00,390 --> 00:00:07,710
Hello and welcome to this lecture, where you are going to learn how to evaluate each individual of

2
00:00:07,710 --> 00:00:12,720
the population again in the flow of the genetic algorithm.

3
00:00:13,020 --> 00:00:25,590
Last lecture we created an initial population of 20 individuals and now we need to assign a score to

4
00:00:25,590 --> 00:00:30,420
each one, which indicates the quality of the solutions.

5
00:00:30,810 --> 00:00:39,870
This score is this some of the prices of all products and together to discover where we use the fitness

6
00:00:39,870 --> 00:00:42,470
function that we implement as before.

7
00:00:42,780 --> 00:00:50,400
So we are going to implement this second step of the flow of the genetic algorithm.

8
00:00:50,880 --> 00:00:54,120
Let's go back to our Google collab file.

9
00:00:54,480 --> 00:01:02,250
I will open a new set of codes and let's implement a far look for in video.

10
00:01:02,400 --> 00:01:09,870
This variable and great now in genetic algorithm dot population.

11
00:01:10,110 --> 00:01:19,830
Just a reminder that these attributes of the glass, we will start the list off of 20 individuals.

12
00:01:20,230 --> 00:01:29,730
Now we need to go through each one of them and we will just call this fitness function we implement

13
00:01:29,730 --> 00:01:30,480
as before.

14
00:01:31,200 --> 00:01:40,630
If we go back here, should the individual class see here that we have this faith in this function.

15
00:01:40,920 --> 00:01:50,280
And then we updated the attribute score evaluation, which is the total price of the products.

16
00:01:50,520 --> 00:01:54,840
And also we update the used space.

17
00:01:55,260 --> 00:01:59,490
How much space the products use in the truck.

18
00:01:59,940 --> 00:02:08,610
So now we can just run these codes to evaluate each one of the individual blocks.

19
00:02:08,910 --> 00:02:13,210
Now we can implement a for loop to see the results.

20
00:02:13,710 --> 00:02:28,260
For I in range genetic algorithm dots, population size and then let's orient d'informations first in

21
00:02:28,260 --> 00:02:33,600
the video, then we will brilliance this basis.

22
00:02:34,440 --> 00:02:35,760
Just what's here.

23
00:02:36,510 --> 00:02:42,540
A but population in position, I thought.

24
00:02:42,630 --> 00:02:53,920
Basis, then let's brilliant did prices a lot, population position.

25
00:02:53,940 --> 00:02:56,730
I thought prices.

26
00:02:57,210 --> 00:03:04,380
Then we will perience the grandson, which is the solution.

27
00:03:04,830 --> 00:03:08,460
G a got population position.

28
00:03:08,460 --> 00:03:13,080
I let's access the attributes, the chromosome.

29
00:03:14,460 --> 00:03:20,100
And finally, let's brands discarded.

30
00:03:20,130 --> 00:03:28,110
Total price a bot's population position I inlets access.

31
00:03:28,110 --> 00:03:33,120
The at throughput is Esquire evaluation at the end.

32
00:03:33,240 --> 00:03:35,010
Let's just keep the light.

33
00:03:35,670 --> 00:03:41,310
Now we can run this set of codes and we can see the results.

34
00:03:41,610 --> 00:03:44,850
For example, the video zero.

35
00:03:45,210 --> 00:03:48,910
This car is only a thousand.

36
00:03:49,310 --> 00:03:58,740
Here we can see this basis, and the price is just a reminder that this base is and the prices are the

37
00:03:58,740 --> 00:04:01,470
same for all individuals.

38
00:04:01,740 --> 00:04:11,970
Because we are just copying the values from our case study data, we can see the chromosome which indicates

39
00:04:11,970 --> 00:04:15,810
the products that we are going to load on the truck.

40
00:04:16,200 --> 00:04:19,650
Individual twelve thousand.

41
00:04:19,860 --> 00:04:20,970
It's bad there.

42
00:04:20,970 --> 00:04:26,930
Then the first in the video in the video show as well.

43
00:04:26,940 --> 00:04:29,300
Thousands in the video.

44
00:04:29,310 --> 00:04:42,300
Three This car is only one because this set of products X sets the maximal capacity of the truck as

45
00:04:42,300 --> 00:04:44,060
we implement as before.

46
00:04:44,370 --> 00:04:54,370
Another solution only four thousand one one eleven thousand one, again sixteen thousand.

47
00:04:55,050 --> 00:04:59,010
And then we can take a look at all these solutions.

48
00:04:59,400 --> 00:04:59,940
But.

49
00:05:00,130 --> 00:05:05,380
We can see that these values are not in order.

50
00:05:05,710 --> 00:05:16,390
So we need to order the individuals to gather to the best one so we can go back to our genetic algorithm

51
00:05:16,390 --> 00:05:22,120
class and we will implement another function to order the data.

52
00:05:22,720 --> 00:05:34,750
Let's create different gene after population, each one to receive any parameter cell population, which

53
00:05:34,750 --> 00:05:37,660
is the least that we want to order.

54
00:05:38,200 --> 00:05:41,290
It will be equal to start dates.

55
00:05:41,530 --> 00:05:45,430
This is a python function to start, at least.

56
00:05:46,090 --> 00:05:47,410
Let's send here.

57
00:05:48,100 --> 00:05:58,600
The population the attribute that was just start, and then we need to specify the key what value we

58
00:05:58,600 --> 00:06:01,570
are going to use to start the list.

59
00:06:01,930 --> 00:06:09,070
And we'll create a function in room time using the land that Coleman's population.

60
00:06:09,520 --> 00:06:18,340
And then we just specify a population dot score evaluation.

61
00:06:18,610 --> 00:06:29,500
So we are going to start this list based on the attributes of the individual class, which is this one

62
00:06:29,500 --> 00:06:29,980
here.

63
00:06:30,250 --> 00:06:35,380
This core evaluation, which stars the total price.

64
00:06:35,920 --> 00:06:45,100
And finally, we can put here reverse equals true to get the higher values first.

65
00:06:45,460 --> 00:06:48,280
Let's recreate this glass.

66
00:06:48,730 --> 00:06:51,910
Let's go back to this part here.

67
00:06:52,270 --> 00:06:56,240
We will create again a new population.

68
00:06:57,010 --> 00:07:01,810
We can just make sure that we have 20 individuals.

69
00:07:02,230 --> 00:07:04,690
We can see the solutions.

70
00:07:04,930 --> 00:07:12,460
Just a reminder that every time you create a population, you will have different values here.

71
00:07:12,910 --> 00:07:15,910
Now, let's run this code again.

72
00:07:16,390 --> 00:07:26,770
We can see that we have similar results because after evaluating the individuals, we need to call our

73
00:07:26,770 --> 00:07:30,130
new function or order population.

74
00:07:30,520 --> 00:07:41,320
So first, we evaluate them, and after we are dirt boarding the higher values at the lower positions

75
00:07:41,320 --> 00:07:44,710
of the list, let's run this code again.

76
00:07:45,010 --> 00:07:47,140
And let's check the results.

77
00:07:47,620 --> 00:08:00,120
For example, individual zero disquiet is 15000 individual one fifteen thousand one hundred.

78
00:08:00,580 --> 00:08:12,730
This value is higher than these other value individual in the individual three, 13, individual four

79
00:08:13,090 --> 00:08:18,580
and five, all 13 individual 612.

80
00:08:18,880 --> 00:08:26,140
And we can go to the last positions, for example, for Individual 15.

81
00:08:26,470 --> 00:08:30,500
This score is only 6000.

82
00:08:30,790 --> 00:08:35,560
And regarding 16, 17, 18.

83
00:08:35,560 --> 00:08:46,180
And then this card equals one because these sets of products X sets the capacity of the drug.

84
00:08:46,750 --> 00:08:50,710
That's how you can evaluate the individuals.

85
00:08:51,010 --> 00:09:01,720
And in this particular implementation, we are voting the best individual at position numbers zero of

86
00:09:01,720 --> 00:09:02,410
the list.

87
00:09:02,830 --> 00:09:06,850
Because of that, we had this implementation here.

88
00:09:07,360 --> 00:09:17,140
When we initialize the population, we keep the best solution as the first position of the list and

89
00:09:17,140 --> 00:09:21,310
in the next lecture, we are going to continue the implementation.

90
00:09:21,610 --> 00:09:22,330
See you there.
