1
00:00:00,850 --> 00:00:08,470
Hello and welcome to this lecture, where you are going to understand the theory and also implement

2
00:00:08,470 --> 00:00:18,880
the evaluation or defeat the mis function, which is a measure of quality to is how goods each chromosome

3
00:00:18,880 --> 00:00:23,860
is or how well the chromosome solves the problem.

4
00:00:24,280 --> 00:00:30,040
Remembering that the chromosome is this sets off ones and zeros.

5
00:00:30,340 --> 00:00:40,030
That's indicates whether you will load the products on the truck, and we need to evaluate whether it

6
00:00:40,030 --> 00:00:49,210
is an acceptable solution and if it can be used in the future or in the next two generations.

7
00:00:49,600 --> 00:00:57,400
You can see this here much again, in which we have the indication of the products that we are going

8
00:00:57,400 --> 00:00:59,200
to load on truck.

9
00:00:59,470 --> 00:01:09,910
Zero indicates that we are not going to load the product and one indicates that we are going to load

10
00:01:09,910 --> 00:01:10,780
the product.

11
00:01:11,080 --> 00:01:17,200
The question is how are we going to evaluate this individual?

12
00:01:17,230 --> 00:01:22,480
Are these chromosome as we have a maximization problem?

13
00:01:22,930 --> 00:01:29,680
The goal is to maximize the profits based on the price of the products.

14
00:01:30,040 --> 00:01:41,020
So we need to load products that this some of their prices is as high as possible, making the best

15
00:01:41,020 --> 00:01:49,540
possible use of the space available in the truck, selecting all these products here.

16
00:01:50,020 --> 00:02:02,650
The total value is ten thousand eight hundred fifty six dollars and 48 cents, and the total space occupied

17
00:02:02,650 --> 00:02:06,490
by Dan is one point seventy six.

18
00:02:06,820 --> 00:02:15,760
It is not a very good solution because the capacity of the truck is three and we are only using one

19
00:02:15,760 --> 00:02:23,500
point seventy six, so we could load more products and have higher values.

20
00:02:23,890 --> 00:02:33,740
In short, the evaluation function will go through each of the products, adding up the prices and space

21
00:02:33,740 --> 00:02:37,190
is occupied by each one Indians.

22
00:02:37,540 --> 00:02:47,050
The solutions that have the highest prices and that do not exceed the space limits will be see, they

23
00:02:47,060 --> 00:02:56,680
are the best and we got the total value by adding each one of the prices of the selected products.

24
00:02:57,130 --> 00:03:07,600
Now let's go back to the Google CoLab file and we will implement a new function inside the individual

25
00:03:07,600 --> 00:03:10,990
class, their fitness.

26
00:03:11,260 --> 00:03:14,500
It wont receive any parameter.

27
00:03:14,770 --> 00:03:25,690
I will create a new variable squared equals zero and some spaces equals zero.

28
00:03:26,200 --> 00:03:31,300
This car variable will start this number here and this.

29
00:03:31,300 --> 00:03:36,280
Some spaces will start, though, though cubic meters.

30
00:03:36,790 --> 00:03:40,540
Now we need to go through each one of the products.

31
00:03:40,960 --> 00:03:53,620
For I in range length Cell Dot's chromosome, we are going through each one of these zeros and ones

32
00:03:54,100 --> 00:04:05,710
I will implement and if statement if self Dot's chromosome was issue, I equals one.

33
00:04:06,010 --> 00:04:09,550
It means we selected the products.

34
00:04:09,970 --> 00:04:22,390
Then we can access this core variable plus equal self thoughts crisis position i.e. we are accessing

35
00:04:22,660 --> 00:04:27,240
these attributes here and we are doing the values.

36
00:04:27,640 --> 00:04:34,900
This core value will start this sum of all prices of this select its products.

37
00:04:35,260 --> 00:04:47,190
We will do something very similar should this order variable some spaces, plus equal cell spaces positioned

38
00:04:47,200 --> 00:04:47,680
high.

39
00:04:48,040 --> 00:04:54,810
It is these parameter that we are sending when we create the individual.

40
00:04:55,060 --> 00:05:00,250
When we finish executing this far loop, we will have four.

41
00:05:00,380 --> 00:05:10,280
These values, the total price and the total cubic meters, but the truck has a limited space, which

42
00:05:10,280 --> 00:05:23,030
is three in this case study, so we need to input and if statements, if some space is greater than

43
00:05:23,420 --> 00:05:34,670
self space limits, it means that it won't be possible to load the products regarding this solution

44
00:05:34,970 --> 00:05:39,560
since there is lots available space in the truck.

45
00:05:39,860 --> 00:05:46,400
If it happens, this car will be reduced to only one.

46
00:05:46,670 --> 00:05:57,040
So it means that if we are not able to load the products of this solution, this car will be very bad,

47
00:05:57,590 --> 00:05:59,360
very small number.

48
00:05:59,570 --> 00:06:05,420
So we want to use this solution in the other generations.

49
00:06:05,810 --> 00:06:16,550
For example, this solution here, the sense exceeds the maximum capacity and the total value is 10000.

50
00:06:16,670 --> 00:06:25,040
And if we exceeds the capacity of the truck, this told no value will be equal to one.

51
00:06:25,520 --> 00:06:33,260
This is a way to discard this solution because the products cannot be loaded on the truck.

52
00:06:33,590 --> 00:06:43,360
And though we need to store both values on the objects, and in order to do that, we can create two

53
00:06:43,400 --> 00:06:52,610
new attributes self bots score evaluation equals zero.

54
00:06:52,670 --> 00:07:01,340
The initialization of the object and also sells used space equals zero.

55
00:07:01,670 --> 00:07:06,290
Now we can just view these attributes here.

56
00:07:06,560 --> 00:07:22,790
According to the calculations, self scoring evaluation equals score, and self use space equals some

57
00:07:23,000 --> 00:07:23,870
space.

58
00:07:24,380 --> 00:07:28,880
Now we can create again the individual glass.

59
00:07:29,660 --> 00:07:39,080
We can go to this part here and let's perform some tests after creating the individual.

60
00:07:39,350 --> 00:07:46,880
We can call the fitness function individual thoughts, fitness.

61
00:07:47,360 --> 00:07:49,310
Let's run the scalds.

62
00:07:49,790 --> 00:08:00,500
See that one air was returns because we need to put self here the default parameter in Python.

63
00:08:00,860 --> 00:08:03,290
Let's recreate the function.

64
00:08:03,890 --> 00:08:07,880
Call it it's again, we can see another error.

65
00:08:08,180 --> 00:08:18,650
Some space is not defined because the name of the variable is some spaces correct?

66
00:08:18,710 --> 00:08:22,010
Here, create the function again.

67
00:08:23,290 --> 00:08:28,750
Run the codes, and now we can see this same results.

68
00:08:29,080 --> 00:08:34,590
Let's take a look at the values of the new attributes of the glass.

69
00:08:35,000 --> 00:08:40,750
I will print this card off the social card, though no price.

70
00:08:41,320 --> 00:08:46,450
Let's access in this video score evaluation.

71
00:08:46,600 --> 00:08:58,960
The new attributes we can also prints the users space individual one dots use space.

72
00:08:59,350 --> 00:09:02,290
Let's run this set of codes.

73
00:09:02,860 --> 00:09:04,210
Take a look here.

74
00:09:04,480 --> 00:09:13,210
That's this card is eleven thousand dollars and they used space is two point forty.

75
00:09:13,990 --> 00:09:15,340
Let's run again.

76
00:09:15,670 --> 00:09:17,020
Then thousands.

77
00:09:17,290 --> 00:09:19,120
Seventeen thousand.

78
00:09:19,390 --> 00:09:25,540
See, that's it's also used all the space available in the truck.

79
00:09:26,260 --> 00:09:28,930
Let's run more times.

80
00:09:29,380 --> 00:09:31,480
We can see the values here.

81
00:09:31,690 --> 00:09:37,450
Every time we run this code, we will have different values.

82
00:09:37,900 --> 00:09:40,780
Take a look at these solutions here.

83
00:09:41,230 --> 00:09:55,000
If we load refrigerator, a TV 55 ventilator, microwaves B and C, refrigerator C and Notebook C,

84
00:09:55,510 --> 00:09:59,860
they used space is three point thirteen.

85
00:10:00,190 --> 00:10:04,180
So it's greater than the limits of the truck.

86
00:10:04,510 --> 00:10:11,050
So it is impossible to load all these products together.

87
00:10:11,320 --> 00:10:14,440
So it is a bad solution.

88
00:10:14,680 --> 00:10:23,980
And this car of its is only one because of these if state we implement as before.

89
00:10:24,190 --> 00:10:29,560
And that's how we can evaluate each one of these solutions.

90
00:10:29,800 --> 00:10:34,210
And in the next lecture, we will continue the implementation.

91
00:10:34,660 --> 00:10:35,350
See you there.
