1
00:00:00,540 --> 00:00:07,050
Hello and welcome to this lecture, where we are going to start with the implementation of their genetic

2
00:00:07,050 --> 00:00:15,060
algorithm to solve deterrence parts problem, we already have this Google CoLab file.

3
00:00:15,480 --> 00:00:23,310
If you were new to Google collab, you just need to follow the link, which is available in the class

4
00:00:23,310 --> 00:00:28,260
materials and to make changes are to run this file.

5
00:00:28,620 --> 00:00:35,430
You need to click on file, save a copy drive when you click this link.

6
00:00:35,700 --> 00:00:45,300
A copy of this notebook will be made on your own Google Drive, so you must have a Google account and

7
00:00:45,300 --> 00:00:48,660
you also needs to be connected to it.

8
00:00:49,080 --> 00:00:56,700
The Google collab is very useful because we don't need to install anything in our old machine.

9
00:00:57,000 --> 00:01:06,570
We can type the code using the browser and we'll click Connect to connect to the Google servers, and

10
00:01:06,570 --> 00:01:09,720
now we'll open a new set of codes.

11
00:01:10,110 --> 00:01:20,520
Clicking this button here The goal of this lecture is to build the product glass in order to represent

12
00:01:20,520 --> 00:01:24,540
our problem, as we saw last lecture.

13
00:01:24,870 --> 00:01:33,000
We have a set of 14 products and each product has a name.

14
00:01:33,450 --> 00:01:40,510
This base that the product occupies in the truck, and also this sales price.

15
00:01:40,890 --> 00:01:46,980
And now we need the wage who represents each one of these products.

16
00:01:47,400 --> 00:01:51,810
And the best way to do that is to create a class.

17
00:01:52,170 --> 00:02:01,230
This is a concept of object oriented programming, and if you were new to this technology, don't worry,

18
00:02:01,230 --> 00:02:09,210
because we will implement all step by step and later on we will perform some tests.

19
00:02:09,600 --> 00:02:13,470
Less great, the class products.

20
00:02:14,370 --> 00:02:24,630
And in order to build a class in Python, we need to define this function, which is called INITS.

21
00:02:24,930 --> 00:02:33,750
This is a kind of system, their function that will be called when we create the objects and it will

22
00:02:33,750 --> 00:02:36,780
receive as a parameter self.

23
00:02:37,110 --> 00:02:41,910
This is a system that are parameter that you need is just sans.

24
00:02:42,360 --> 00:02:44,550
So that's Python language.

25
00:02:44,790 --> 00:02:53,430
We understands that the variables that we are going to create later will be associated with this class.

26
00:02:54,120 --> 00:03:03,300
Let's sans the main parameter, this space and also the price as we saw in this light.

27
00:03:03,750 --> 00:03:11,700
Now we need to create some attributes and in order to do that, we need to use the word self.

28
00:03:12,160 --> 00:03:20,910
I will create a new attribute called name, which will be equal should the name parameter that we are

29
00:03:20,910 --> 00:03:21,390
going to.

30
00:03:22,020 --> 00:03:30,330
Later on, I will create on larger attributes safe space equals space.

31
00:03:30,480 --> 00:03:37,620
This parameter here self Dot's price equals price.

32
00:03:38,100 --> 00:03:46,230
We are creating the attributes which are related to the concepts of object oriented programming.

33
00:03:46,740 --> 00:03:53,760
Let's create this glass and now it will be easier to understand these variables.

34
00:03:54,090 --> 00:03:56,360
Let's create product.

35
00:03:56,370 --> 00:04:05,130
One equals let's go the name of the class with the find the here and take a look at that.

36
00:04:05,130 --> 00:04:10,800
We can send three parameters namespace and price.

37
00:04:11,040 --> 00:04:16,680
As I said before, the parameters self is not used here.

38
00:04:16,890 --> 00:04:22,560
It's a kind of an internal process of Python programming language.

39
00:04:22,890 --> 00:04:35,700
Let's suppose we want to represent a refrigerator a this size zero point seven five one and the price

40
00:04:35,700 --> 00:04:39,180
nine nine nine point nine.

41
00:04:39,570 --> 00:04:45,660
It is the representation of this first product, refrigerator a.

42
00:04:45,930 --> 00:04:54,510
We can run these codes and now we can take a look at the attributes that we defined the here.

43
00:04:54,720 --> 00:04:58,770
We can type B1 dots name.

44
00:04:59,370 --> 00:05:06,000
Run this code, we can say the name of the product refrigerator, eh?

45
00:05:06,330 --> 00:05:17,070
Just to better understand when we call this glass, these in needs function will also be codes and then

46
00:05:17,490 --> 00:05:20,220
we sends this parameter.

47
00:05:20,520 --> 00:05:21,480
Should the name.

48
00:05:21,840 --> 00:05:25,950
And it will be copied should the attribute of the glass.

49
00:05:26,430 --> 00:05:29,400
Then we send this space.

50
00:05:29,880 --> 00:05:32,120
Should this section two reports.

51
00:05:32,340 --> 00:05:36,030
And finally, we copy this value.

52
00:05:36,270 --> 00:05:43,020
Should these parameter and then we associate with the attribute of the glass.

53
00:05:43,380 --> 00:05:47,340
We can also take a look at the other parameters.

54
00:05:48,150 --> 00:05:48,570
One.

55
00:05:48,870 --> 00:05:50,070
But space?

56
00:05:50,400 --> 00:05:53,040
And B word dot price.

57
00:05:53,250 --> 00:06:02,220
Let's run these codes and we can see the results according to the values with sense, should the parameters.

58
00:06:02,610 --> 00:06:09,030
We can also create products show equals products.

59
00:06:09,390 --> 00:06:12,690
Let's Typekit the name of the product.

60
00:06:12,930 --> 00:06:26,160
The first barometer cell phone this space zero point one two three four five zero eight nine nine and

61
00:06:26,160 --> 00:06:26,970
the price.

62
00:06:27,870 --> 00:06:31,230
One line nine points twelve.

63
00:06:31,440 --> 00:06:35,760
It is the representation of this cell phone here.

64
00:06:36,270 --> 00:06:47,400
Now we can take a look at the values just to make sure feature, but the main feature dot space feature

65
00:06:47,700 --> 00:06:48,960
dot price.

66
00:06:49,560 --> 00:06:51,760
Let's create the object.

67
00:06:51,790 --> 00:07:00,660
Be sure we can take a look at the values which are the same, which is specified as a parameter.

68
00:07:01,020 --> 00:07:09,600
Take a look here that as we have a very small number, it was sports in scientific notation.

69
00:07:09,900 --> 00:07:19,080
Just to recap, first, we need to build the glass, which is the general structure, and then we can

70
00:07:19,080 --> 00:07:21,030
create the variables.

71
00:07:21,030 --> 00:07:23,520
Are the objects in this case.

72
00:07:24,030 --> 00:07:25,350
One and bit.

73
00:07:26,130 --> 00:07:36,210
Now we need a way to represent all the 14 products, and we can put all the products in the format of

74
00:07:36,210 --> 00:07:37,830
a list in by them.

75
00:07:38,230 --> 00:07:42,840
So let's create another variable products list.

76
00:07:43,320 --> 00:07:53,640
Initially, it is an empty list, and when you use open and close brackets in Python, it means that

77
00:07:53,760 --> 00:07:55,260
you are defining.

78
00:07:55,290 --> 00:08:00,330
At least now we can ods the products to this list.

79
00:08:00,780 --> 00:08:08,490
We can use the app bands Colman's and then we can just call our glass.

80
00:08:08,940 --> 00:08:20,730
Let's send the heater defers, products refrigerate or a band we need should specify the space seven

81
00:08:20,730 --> 00:08:26,970
five one and the price nine nine nine point nine.

82
00:08:27,510 --> 00:08:33,240
Then we need should do exactly the same for all other products.

83
00:08:33,630 --> 00:08:37,120
Let's sup bands this cell phone I.

84
00:08:37,220 --> 00:08:42,250
We'll just copy and paste this code here.

85
00:08:42,600 --> 00:08:49,890
Then we need to move on to the next product, according to our slides.

86
00:08:50,430 --> 00:08:56,520
The next one products TV 55 inches.

87
00:08:56,820 --> 00:09:08,280
Now let's specify the space zero point forty and the price for the trip for this six point ninety nine.

88
00:09:08,490 --> 00:09:13,830
Now we should do exactly the same for all other products.

89
00:09:14,290 --> 00:09:21,630
I we'll just paste this code here in order to have all the products in this list.

90
00:09:21,960 --> 00:09:30,120
Now we can create this variable products list and we can take a look at the values.

91
00:09:30,360 --> 00:09:37,770
If we type products list, we can see each one of the positions.

92
00:09:38,100 --> 00:09:42,180
See, that's in each position off this list.

93
00:09:42,450 --> 00:09:51,850
There is a product and you see the values we need to implement a far loop for products.

94
00:09:52,180 --> 00:09:58,770
Product is the variable grading now in product lists and we.

95
00:09:59,300 --> 00:10:03,770
Just Sprint's products, not that's name.

96
00:10:04,370 --> 00:10:09,950
Let's run these codes and we can see the name of all products.

97
00:10:10,370 --> 00:10:13,580
We can also take a look at the price.

98
00:10:14,540 --> 00:10:25,820
Let's Oxes products that price and also the space just type products, dot space.

99
00:10:26,210 --> 00:10:27,410
Run these codes.

100
00:10:27,650 --> 00:10:30,770
And finally, we can see the results.

101
00:10:31,070 --> 00:10:39,500
This is the first part of our algorithm in which we just implemented the list of products.

102
00:10:39,770 --> 00:10:46,130
And in the next lecture, we'll move on to the concepts of genetic algorithms.

103
00:10:46,520 --> 00:10:47,210
So you there?
