Hello and welcome to this lecture, where we are going to start working with the flight's casual problem
and the first step we need should represent the problem.
This is the part of the implementation that will take more time to implement seals.
We need to prepare and understand all the data as we saw last lecture.
There are six people who will travel from one city to Rome.
So first, we need to define the list of people.
Let's create these variable people.
The Lisbon and I would hear these ladders al, I ask, which means the name of the airports in Lisbon
because we will load our data sets and the dataset is in these four months.
In some minutes, you will.
Badger understands this section, some Madrid's and the name of the airports, and then the third person
buries the name of the airports c the G.
We just needs to close parenthesis here, open and close here for each one of the people.
Then the next one, doubling the name of the airports, the you be.
The next one, Boro sells the name of their words, B, are you?
And finally, the last person London, the name of the airport Al H are we can create this new variable.
We can just type the name people, and we have all this information here when we was access one of the
lines.
We can just type people position five London and we have the name of the person are the name of this
city and the name of the airports.
If we type number three here, we will get the blame.
Just a reminder that's in Python indexes.
It starts from zero position, zero position, one position queue and position three, which is equal
to burbling.
Let's create another variable which will be added.
Destiny FC all, which is the name of the airports in Rome, just better understands how we are going
to define this structure of our data.
We can create a new variable cloud flights and it will be in the format of a dictionary.
For this reason, we open and close breaths.
For example, we will have a flight from Brussels.
Sure run.
The first column is the arranging, and this second column is the destiny.
Then we can define the time of departure.
For example, 15 and 44 and the time of arrival 18 55.
So it means that the flight from Brussels to Rome departures at this time and arrives at this time.
Then we can both hear the price of the flight.
For example, three hundred and eighty two, let's create this variable type, the name of the new variable.
Here we can see the data.
And if you want to access, for example, there is information about the time and the information about
the price.
We can just type here flights and let's type B R you f c o.
These are the indexes of the dictionary, and this list is the values of the dictionary.
Let's run this set of codes.
We gets the time of departure, the time of arrival and also the price.
As we have a problem where the goal is to minimize the prices, we are going to get all these parts
of the dictionary so we can access each one of the positions.
For example, let's copy and paste this code here.
If we type position zero, we will get only that time of departure.
We can based the code again, position one.
We will get the time of arrival.
And finally, in position number two, we will get the price here.
That is the goal.
Well off our case is 30.
Now that you have understood this structure of this dictionary, we can load the data sets.
We will click this button here.
You can click the uploads and we'll select this dataset flights, not the X.
Then you can download it in the class materials.
Let's open this file and we can see here.
This section column is the arranging the name of the airports in this second column.
We can find the destination.
For example, the first row is a flight from Wrong to Lisbon.
The next column is the departure time, the arrival time and the price.
We can see rule number six.
It is a flight from Lisbon to Rome, and the price is nine denied.
We can also take a look at some other roles.
This is a flight from Paris to Rome, and it costs three hundred and twenty six in this particular case
study.
We are not going to use the time of departure and the time of arrival because our goal is just to walk
with this value.
The price of the airline tickets now in these trades, this file in order to create this complete dictionary
composed of all flights so we can open a new sale of codes.
We will create this variable again and empty dictionary.
Let's implement a for loop for road in open.
And now we just needs to type the name of the datasets, which is here available in the Google CoLab
environments.
We can brands the road just to see the partial results.
They can look here that we are going through each one of the rows now in these two extracts.
The name of the airports and also the price of the airline tickets just to badger understand how we
are going to do that.
We can type role dot splits and when we find a comma, we will split the data.
Let's run this code again.
For example, we have this list here, and when we find a comma, we split that they that in at least
four months.
You can see open and close brackets here.
For example, in the first position of the list, we can see the airports of bringing in this second
position, the destination in the third position.
The time of departure in the next position.
The time for arrival.
And finally, in the last position, the price of the tickets.
So now we can create a variable for each one of the positions.
The orange in the destiny departure, the arrival and the price.
It will be equal to zero thoughts.
Blitz comma.
If you want to see the results, we can just bring into the variables our engine, destiny, departure,
arrival and the price.
Let's run this code again and we can see the results.
Each one of the positions are starts in each one of these new variables.
Now we can access our dictionary flights.
Let's set the to initialize the dictionary, and the key will be orange and destiny, so we can put
their origin and destiny similar to this structure here, because in this data sets that are more than
one option off flights from Brussels to Rome.
So we need the name of the airports.
Ask is and then we will boards all the available flights.
Let's finish this implementation.
So it will be easier to understand.
We will initialize the dictionary with empty spaces are empty list.
We can brands the flights just to see the partial results.
See, that's there are a lot of options.
For example, FCO should Lisbon, FCO, Julius Balagan and so on.
Now it needs to fill these empty lists here in order to do that.
We can just access our flights dictionary.
Let's put here.
They are changing and the destiny and OWWA bands icons in the list, the departure de arrival and let's.
Words the price should integer, let's run this quote.
Now it will be easier to see the results.
I will type flights.
We can see here, for example, from Rome, actually is boom.
And in this list here we can see all available flights.
For example, the cheapest flight from Rome to Lisbon is one hundred and thirty six.
And the more expensive is these first one, two hundred and thirty nine.
In a similar way, we can see from London to Rome, all available flights from Lisbon to Rome, from
my three children and so on, and we can see that there are one two three four five six seven eight
nine 10 flights that are then flights in all these options here.
And the goal is to select assets off flights that have the cheapest value if you want to visualize data
about a specific destination.
We can type flights, for example, if you wants to see the available flights from Lisbon short run,
we can see all options here and in a similar way.
We can also see the flights from FCO, from Rome to Lisbon brand escorts and we can see the options
and remembering again, that's the goal of this case study is to select a flight from Lisbon to Rome
and then the other flights from wrong to Lisbon.
And the same for all other cities.
And in the next lecture, we will finish this implementation.
And then we will apply genetic algorithms.
See you there!