1
00:00:00,090 --> 00:00:07,920
Hello and welcome to this lecture, where we are going to start working with the flight's casual problem

2
00:00:08,250 --> 00:00:12,960
and the first step we need should represent the problem.

3
00:00:13,290 --> 00:00:20,480
This is the part of the implementation that will take more time to implement seals.

4
00:00:20,520 --> 00:00:26,810
We need to prepare and understand all the data as we saw last lecture.

5
00:00:27,090 --> 00:00:33,360
There are six people who will travel from one city to Rome.

6
00:00:33,720 --> 00:00:39,420
So first, we need to define the list of people.

7
00:00:39,780 --> 00:00:43,320
Let's create these variable people.

8
00:00:43,710 --> 00:00:55,320
The Lisbon and I would hear these ladders al, I ask, which means the name of the airports in Lisbon

9
00:00:55,590 --> 00:01:01,980
because we will load our data sets and the dataset is in these four months.

10
00:01:02,280 --> 00:01:03,750
In some minutes, you will.

11
00:01:03,750 --> 00:01:14,820
Badger understands this section, some Madrid's and the name of the airports, and then the third person

12
00:01:15,060 --> 00:01:20,900
buries the name of the airports c the G.

13
00:01:21,330 --> 00:01:31,800
We just needs to close parenthesis here, open and close here for each one of the people.

14
00:01:32,780 --> 00:01:41,960
Then the next one, doubling the name of the airports, the you be.

15
00:01:42,970 --> 00:01:50,520
The next one, Boro sells the name of their words, B, are you?

16
00:01:51,490 --> 00:02:05,680
And finally, the last person London, the name of the airport Al H are we can create this new variable.

17
00:02:07,110 --> 00:02:17,430
We can just type the name people, and we have all this information here when we was access one of the

18
00:02:17,430 --> 00:02:18,180
lines.

19
00:02:18,510 --> 00:02:29,490
We can just type people position five London and we have the name of the person are the name of this

20
00:02:29,490 --> 00:02:32,760
city and the name of the airports.

21
00:02:33,270 --> 00:02:38,740
If we type number three here, we will get the blame.

22
00:02:39,120 --> 00:02:42,460
Just a reminder that's in Python indexes.

23
00:02:42,480 --> 00:02:53,070
It starts from zero position, zero position, one position queue and position three, which is equal

24
00:02:53,070 --> 00:02:53,880
to burbling.

25
00:02:54,510 --> 00:02:58,620
Let's create another variable which will be added.

26
00:02:58,620 --> 00:03:09,360
Destiny FC all, which is the name of the airports in Rome, just better understands how we are going

27
00:03:09,360 --> 00:03:12,930
to define this structure of our data.

28
00:03:13,500 --> 00:03:21,660
We can create a new variable cloud flights and it will be in the format of a dictionary.

29
00:03:21,930 --> 00:03:25,950
For this reason, we open and close breaths.

30
00:03:26,340 --> 00:03:31,620
For example, we will have a flight from Brussels.

31
00:03:32,100 --> 00:03:33,720
Sure run.

32
00:03:34,290 --> 00:03:40,590
The first column is the arranging, and this second column is the destiny.

33
00:03:40,950 --> 00:03:46,260
Then we can define the time of departure.

34
00:03:46,560 --> 00:03:57,390
For example, 15 and 44 and the time of arrival 18 55.

35
00:03:57,750 --> 00:04:09,000
So it means that the flight from Brussels to Rome departures at this time and arrives at this time.

36
00:04:09,450 --> 00:04:13,620
Then we can both hear the price of the flight.

37
00:04:13,920 --> 00:04:24,800
For example, three hundred and eighty two, let's create this variable type, the name of the new variable.

38
00:04:24,810 --> 00:04:27,450
Here we can see the data.

39
00:04:27,870 --> 00:04:36,960
And if you want to access, for example, there is information about the time and the information about

40
00:04:36,960 --> 00:04:37,860
the price.

41
00:04:38,160 --> 00:04:46,890
We can just type here flights and let's type B R you f c o.

42
00:04:47,250 --> 00:04:55,710
These are the indexes of the dictionary, and this list is the values of the dictionary.

43
00:04:56,070 --> 00:04:58,350
Let's run this set of codes.

44
00:04:58,620 --> 00:05:05,190
We gets the time of departure, the time of arrival and also the price.

45
00:05:05,550 --> 00:05:15,840
As we have a problem where the goal is to minimize the prices, we are going to get all these parts

46
00:05:15,840 --> 00:05:21,480
of the dictionary so we can access each one of the positions.

47
00:05:21,990 --> 00:05:27,840
For example, let's copy and paste this code here.

48
00:05:28,110 --> 00:05:36,660
If we type position zero, we will get only that time of departure.

49
00:05:37,200 --> 00:05:41,370
We can based the code again, position one.

50
00:05:41,730 --> 00:05:45,750
We will get the time of arrival.

51
00:05:46,110 --> 00:05:53,490
And finally, in position number two, we will get the price here.

52
00:05:54,060 --> 00:05:55,540
That is the goal.

53
00:05:55,540 --> 00:05:57,710
Well off our case is 30.

54
00:05:58,320 --> 00:06:06,780
Now that you have understood this structure of this dictionary, we can load the data sets.

55
00:06:07,230 --> 00:06:09,840
We will click this button here.

56
00:06:10,290 --> 00:06:18,570
You can click the uploads and we'll select this dataset flights, not the X.

57
00:06:18,570 --> 00:06:22,650
Then you can download it in the class materials.

58
00:06:23,100 --> 00:06:27,690
Let's open this file and we can see here.

59
00:06:28,230 --> 00:06:36,270
This section column is the arranging the name of the airports in this second column.

60
00:06:36,480 --> 00:06:38,940
We can find the destination.

61
00:06:39,180 --> 00:06:45,990
For example, the first row is a flight from Wrong to Lisbon.

62
00:06:46,560 --> 00:06:54,420
The next column is the departure time, the arrival time and the price.

63
00:06:54,810 --> 00:06:57,090
We can see rule number six.

64
00:06:57,540 --> 00:07:06,180
It is a flight from Lisbon to Rome, and the price is nine denied.

65
00:07:06,870 --> 00:07:10,850
We can also take a look at some other roles.

66
00:07:11,460 --> 00:07:21,960
This is a flight from Paris to Rome, and it costs three hundred and twenty six in this particular case

67
00:07:21,960 --> 00:07:22,550
study.

68
00:07:22,800 --> 00:07:33,000
We are not going to use the time of departure and the time of arrival because our goal is just to walk

69
00:07:33,000 --> 00:07:34,710
with this value.

70
00:07:35,070 --> 00:07:46,740
The price of the airline tickets now in these trades, this file in order to create this complete dictionary

71
00:07:47,010 --> 00:07:53,840
composed of all flights so we can open a new sale of codes.

72
00:07:54,480 --> 00:08:00,090
We will create this variable again and empty dictionary.

73
00:08:00,420 --> 00:08:05,970
Let's implement a for loop for road in open.

74
00:08:06,360 --> 00:08:16,380
And now we just needs to type the name of the datasets, which is here available in the Google CoLab

75
00:08:16,380 --> 00:08:17,400
environments.

76
00:08:17,790 --> 00:08:23,040
We can brands the road just to see the partial results.

77
00:08:23,490 --> 00:08:31,950
They can look here that we are going through each one of the rows now in these two extracts.

78
00:08:32,310 --> 00:08:41,910
The name of the airports and also the price of the airline tickets just to badger understand how we

79
00:08:41,910 --> 00:08:43,290
are going to do that.

80
00:08:43,650 --> 00:08:54,060
We can type role dot splits and when we find a comma, we will split the data.

81
00:08:54,390 --> 00:08:56,280
Let's run this code again.

82
00:08:56,580 --> 00:09:07,470
For example, we have this list here, and when we find a comma, we split that they that in at least

83
00:09:07,470 --> 00:09:08,220
four months.

84
00:09:08,460 --> 00:09:12,300
You can see open and close brackets here.

85
00:09:12,480 --> 00:09:21,990
For example, in the first position of the list, we can see the airports of bringing in this second

86
00:09:21,990 --> 00:09:26,760
position, the destination in the third position.

87
00:09:27,120 --> 00:09:31,370
The time of departure in the next position.

88
00:09:31,740 --> 00:09:33,780
The time for arrival.

89
00:09:33,960 --> 00:09:39,210
And finally, in the last position, the price of the tickets.

90
00:09:39,750 --> 00:09:46,080
So now we can create a variable for each one of the positions.

91
00:09:46,650 --> 00:09:54,120
The orange in the destiny departure, the arrival and the price.

92
00:09:54,570 --> 00:09:58,410
It will be equal to zero thoughts.

93
00:09:58,500 --> 00:10:00,300
Blitz comma.

94
00:10:00,990 --> 00:10:10,260
If you want to see the results, we can just bring into the variables our engine, destiny, departure,

95
00:10:10,670 --> 00:10:13,020
arrival and the price.

96
00:10:13,410 --> 00:10:17,910
Let's run this code again and we can see the results.

97
00:10:18,180 --> 00:10:25,260
Each one of the positions are starts in each one of these new variables.

98
00:10:25,740 --> 00:10:30,260
Now we can access our dictionary flights.

99
00:10:30,890 --> 00:10:42,390
Let's set the to initialize the dictionary, and the key will be orange and destiny, so we can put

100
00:10:42,390 --> 00:10:54,780
their origin and destiny similar to this structure here, because in this data sets that are more than

101
00:10:54,780 --> 00:10:59,700
one option off flights from Brussels to Rome.

102
00:11:00,270 --> 00:11:03,470
So we need the name of the airports.

103
00:11:03,480 --> 00:11:09,600
Ask is and then we will boards all the available flights.

104
00:11:09,990 --> 00:11:12,480
Let's finish this implementation.

105
00:11:12,780 --> 00:11:15,360
So it will be easier to understand.

106
00:11:15,570 --> 00:11:22,230
We will initialize the dictionary with empty spaces are empty list.

107
00:11:22,590 --> 00:11:28,500
We can brands the flights just to see the partial results.

108
00:11:28,860 --> 00:11:31,350
See, that's there are a lot of options.

109
00:11:31,680 --> 00:11:39,090
For example, FCO should Lisbon, FCO, Julius Balagan and so on.

110
00:11:39,390 --> 00:11:46,230
Now it needs to fill these empty lists here in order to do that.

111
00:11:46,530 --> 00:11:51,660
We can just access our flights dictionary.

112
00:11:52,140 --> 00:11:53,490
Let's put here.

113
00:11:53,880 --> 00:12:05,970
They are changing and the destiny and OWWA bands icons in the list, the departure de arrival and let's.

114
00:12:06,330 --> 00:12:11,900
Words the price should integer, let's run this quote.

115
00:12:12,440 --> 00:12:15,210
Now it will be easier to see the results.

116
00:12:15,500 --> 00:12:17,720
I will type flights.

117
00:12:18,290 --> 00:12:23,570
We can see here, for example, from Rome, actually is boom.

118
00:12:23,960 --> 00:12:29,780
And in this list here we can see all available flights.

119
00:12:30,050 --> 00:12:38,780
For example, the cheapest flight from Rome to Lisbon is one hundred and thirty six.

120
00:12:39,080 --> 00:12:45,590
And the more expensive is these first one, two hundred and thirty nine.

121
00:12:45,830 --> 00:12:57,530
In a similar way, we can see from London to Rome, all available flights from Lisbon to Rome, from

122
00:12:57,710 --> 00:13:09,260
my three children and so on, and we can see that there are one two three four five six seven eight

123
00:13:09,260 --> 00:13:16,610
nine 10 flights that are then flights in all these options here.

124
00:13:16,880 --> 00:13:27,500
And the goal is to select assets off flights that have the cheapest value if you want to visualize data

125
00:13:27,800 --> 00:13:31,040
about a specific destination.

126
00:13:31,520 --> 00:13:41,810
We can type flights, for example, if you wants to see the available flights from Lisbon short run,

127
00:13:42,920 --> 00:13:47,960
we can see all options here and in a similar way.

128
00:13:48,170 --> 00:14:01,130
We can also see the flights from FCO, from Rome to Lisbon brand escorts and we can see the options

129
00:14:01,400 --> 00:14:11,500
and remembering again, that's the goal of this case study is to select a flight from Lisbon to Rome

130
00:14:11,810 --> 00:14:16,100
and then the other flights from wrong to Lisbon.

131
00:14:16,460 --> 00:14:19,400
And the same for all other cities.

132
00:14:19,760 --> 00:14:24,110
And in the next lecture, we will finish this implementation.

133
00:14:24,440 --> 00:14:28,250
And then we will apply genetic algorithms.

134
00:14:28,610 --> 00:14:29,300
See you there!
