1
00:00:00,210 --> 00:00:07,560
Hello and welcome to this lecture, where we are going to solve the problem related to the transport

2
00:00:07,560 --> 00:00:12,000
of products using M. L Rose Library.

3
00:00:12,300 --> 00:00:20,100
This is another interesting library where you can find implementations of genetic algorithms.

4
00:00:20,400 --> 00:00:21,820
Follow this link!

5
00:00:21,960 --> 00:00:31,440
If you want to know more detail, you can see some informations about optimization problems and differently

6
00:00:31,440 --> 00:00:36,540
from deep, which is focused on evolutionary algorithms.

7
00:00:36,930 --> 00:00:43,920
These order library is focused on optimization algorithms.

8
00:00:44,370 --> 00:00:53,420
For example, we can click algorithms here and then our implementations of the hillclimb algorithm.

9
00:00:53,880 --> 00:01:01,230
We can see here the simulated annealing and also genetic algorithms.

10
00:01:01,740 --> 00:01:09,420
They are different kinds of algorithms to minimize or maximize of value.

11
00:01:09,690 --> 00:01:19,470
So instead of using genetic algorithms to solve this problem, you can also use simulated annealing

12
00:01:19,470 --> 00:01:22,110
and also the hillclimb.

13
00:01:22,590 --> 00:01:27,570
The good point is that you have easy access to the source codes.

14
00:01:27,900 --> 00:01:37,650
For example, you can click Sirs here, and you can take a look at the genetic algorithm implementation.

15
00:01:37,940 --> 00:01:48,120
Maybe if you was to make some changes to our algorithm implemented from scratch, you can see more information

16
00:01:48,120 --> 00:01:48,540
here.

17
00:01:49,200 --> 00:01:51,840
Now, let's install the library.

18
00:01:52,380 --> 00:01:54,420
Let's type PIP.

19
00:01:54,870 --> 00:01:58,000
Install Email Rose.

20
00:01:58,650 --> 00:02:06,840
Run this sale of codes we are using version one point three point zero.

21
00:02:07,110 --> 00:02:12,450
If you have some problem in music, you would think the codes we are going to implement.

22
00:02:12,720 --> 00:02:21,020
Maybe it is because of different versions so you can type B install.

23
00:02:21,610 --> 00:02:33,570
Email rose equal one point three point zero, so the codes will be compatible with the one we are going

24
00:02:33,570 --> 00:02:35,190
to implement now.

25
00:02:35,490 --> 00:02:42,140
The next step we need to impart to the library in parts and URLs.

26
00:02:42,480 --> 00:02:43,980
Run this cell.

27
00:02:44,250 --> 00:02:51,330
No error was returns, so it means the library was successfully installed.

28
00:02:51,750 --> 00:02:55,530
Now we need to define the list of products.

29
00:02:55,890 --> 00:03:00,720
Any stands of defining use in the four months of a class.

30
00:03:01,020 --> 00:03:07,920
We can also paste this code, which is a simple list in Python.

31
00:03:08,280 --> 00:03:13,980
In each one of the positions, we can see the features about the products.

32
00:03:14,310 --> 00:03:19,380
The name this base and also the price you can use.

33
00:03:19,380 --> 00:03:26,250
The class we implement as before, and also you can define in the form of a list.

34
00:03:26,640 --> 00:03:28,740
We can create this variable.

35
00:03:29,280 --> 00:03:31,770
Lets type products.

36
00:03:33,090 --> 00:03:37,290
You can see all the information about our data.

37
00:03:37,470 --> 00:03:46,530
Let's also create another variable limit equals three, which means the available space in the truck.

38
00:03:46,860 --> 00:03:54,360
Now in these should define the in function again and choose not to be so repetitive.

39
00:03:54,720 --> 00:04:00,060
I will just based this code to here fitness function.

40
00:04:00,420 --> 00:04:06,270
We sans a solution which is composed of zeros and ones.

41
00:04:06,570 --> 00:04:14,760
Just a reminder, zero means that we are not going to load the products on the truck, and one means

42
00:04:14,760 --> 00:04:18,510
that we are going to load the product on the truck.

43
00:04:18,840 --> 00:04:29,460
At the end, we return the cost and we don't need to type a call here because it is not necessary.

44
00:04:29,490 --> 00:04:36,990
Using this library, let's create the function and now we can create a new variable.

45
00:04:37,650 --> 00:04:48,630
Fitness equals email rose custom fitness because we are using our own fitness function.

46
00:04:49,230 --> 00:04:51,170
Let's just dive here.

47
00:04:51,540 --> 00:04:53,080
Fit in this function.

48
00:04:53,220 --> 00:04:55,500
This same name of the function?

49
00:04:56,130 --> 00:04:57,630
Run this code.

50
00:04:58,140 --> 00:04:59,770
Now we needs to refer.

51
00:04:59,890 --> 00:05:01,540
Zandt's, the problem?

52
00:05:01,930 --> 00:05:06,700
Email rules got this crap.

53
00:05:07,000 --> 00:05:14,710
Obesity this crats means that we are going to work only with integer numbers.

54
00:05:15,130 --> 00:05:19,210
We need to specify the length of this solution.

55
00:05:19,610 --> 00:05:24,400
Land products we can type this code to here.

56
00:05:25,030 --> 00:05:30,070
Land products just correct this typo.

57
00:05:30,070 --> 00:05:39,880
Here we can see that the results equals 14, which means the amount of products in our data.

58
00:05:40,330 --> 00:05:49,360
Then, when these two is specified, this fit in this function, which will be equal to fitness.

59
00:05:49,930 --> 00:06:00,580
This variable we define the higher than the X parameter maximize equals true because we want higher

60
00:06:00,580 --> 00:06:01,450
values.

61
00:06:01,990 --> 00:06:06,340
And finally, Max Vo equals chu.

62
00:06:06,610 --> 00:06:13,420
It means we was to generate only zeros and ones.

63
00:06:13,690 --> 00:06:25,000
So when we define number two, the library will generate only zeros and once we run this sale of codes.

64
00:06:26,080 --> 00:06:30,310
And finally, we can create two new variables.

65
00:06:30,610 --> 00:06:43,030
The first one, the best solution and the best fit in this are the best value equals email rules we

66
00:06:43,030 --> 00:06:46,300
can call the genetic algorithm.

67
00:06:47,080 --> 00:06:49,540
We will sans the problem.

68
00:06:50,110 --> 00:06:54,700
Then the experimenter pops size, population size.

69
00:06:54,940 --> 00:07:04,840
For example, we can define only 20 individuals, and there is another parameter mutational prob the

70
00:07:04,840 --> 00:07:09,220
probability of mutation zero point zero one.

71
00:07:09,520 --> 00:07:18,580
This same parameters according to our last implementation, and we don't need to specify the number

72
00:07:18,580 --> 00:07:28,960
of generations because the algorithm itself will try to find the optimal number of generations after

73
00:07:28,960 --> 00:07:30,160
ruining this code.

74
00:07:30,370 --> 00:07:39,460
We can take a look at the best solution and the best fit in this let's run this code.

75
00:07:39,880 --> 00:07:43,290
We can see the chromosome, and here it is.

76
00:07:43,290 --> 00:07:48,880
Solution twenty four thousand three hundred and eighty five.

77
00:07:49,300 --> 00:07:58,270
Every time we run this code, we will get a different value because the initialization of the chromosome

78
00:07:58,480 --> 00:08:01,630
in the beginning of the algorithm is random.

79
00:08:02,080 --> 00:08:11,440
Let's run these codes a couple of times, and we can see results quite similar to the one we got before.

80
00:08:11,890 --> 00:08:21,970
To show the products that we are going challenge, we can implement the far loop for I in range length

81
00:08:22,450 --> 00:08:24,370
based solution.

82
00:08:24,820 --> 00:08:30,010
We are going through these lists of zeros and ones.

83
00:08:30,700 --> 00:08:37,450
If the best solution position, I equals one.

84
00:08:38,200 --> 00:08:42,820
Let's just sprints the name of the product.

85
00:08:43,240 --> 00:08:48,070
We can access our list products position.

86
00:08:48,070 --> 00:09:02,320
I am position zero and then the price of the product lets access again our list products position.

87
00:09:02,320 --> 00:09:05,590
I am position to just two.

88
00:09:05,590 --> 00:09:16,670
Badru understands we can type where products we can see all information if we was to get the cell phone.

89
00:09:17,410 --> 00:09:21,610
It is in position zero and position one.

90
00:09:22,000 --> 00:09:27,520
We can type a products position when we get only the cell phone.

91
00:09:27,940 --> 00:09:32,860
If we want to get the name, it is in position zero.

92
00:09:33,490 --> 00:09:37,570
For this reason, we have these implementation here.

93
00:09:37,930 --> 00:09:46,690
We can also access the price products product one and position two.

94
00:09:48,410 --> 00:09:53,060
Ran this code, and we have the price of the product.

95
00:09:53,390 --> 00:09:58,520
Now we can run this code, and here is our results.

96
00:09:58,970 --> 00:10:03,830
This is the list of products that we are going to load on the drug.

97
00:10:04,190 --> 00:10:13,610
As you could see, it's much easier to work with Melrose Library in the next lecture and we will present

98
00:10:13,610 --> 00:10:13,910
you.

99
00:10:13,940 --> 00:10:21,530
This second case is the the the second problem that we are going to solve using both libraries.

100
00:10:21,860 --> 00:10:22,550
See you there!
