Hello and welcome to this lecture, where we are going to implement another function in the genetic
algorithm class, we already implemented the creation of the initial population.
And we also have already evaluated the population.
Now we are going to move on should this part here, select parents, because in order to apply crossover
and mutation, we need to select some of the parents who created the new generation.
So we will implement an additional function then in the next two lectures.
You are going to learn how to use this function to select the parents moving back to the Google collab
file.
I will create a new function.
They have some evaluations and it will not receive any parameter.
As the name suggests, we are going to some all the prizes off each one of the individuals in our sample
that are 20 individuals and each individual has a value, which is the score evaluation which is calculated
using the fitness function.
It is this some of the prices of the products that we are going to load on this drug.
This function will go through each one of the individuals and we are going to add this value in order
to return this sum.
Don't worry now about understanding why we needed this value.
It will be explained in the next two lectures.
Let's create a variable quote some, and let's go through each one of the individuals for individual
in cell population.
We are accessing this list here.
Some B+ equal in the video, but score evaluation Etienne's after executing the far loop.
Let's just return this sum.
It's a very simple and easy function.
Let's create the glass again.
Go back.
Should this part of the codes where we are creating the new population, we can just check this brand
see here, just just see the values.
Run this code again.
Just a reminder that's in position No.
Zero.
We can see the best solution.
And the goal of this function is to go through each one of these individuals and adds, all these values
here discard off each one of the individuals we can fast.
They function we implemented before.
The current best solution is third.
In thousands, we can see the best solution.
16000.
Now we can call our function should change the best in the video we can see here.
That's now the best solution.
Is these one here?
We can also see the chromosome.
And finally, let's open.
A new sale of codes should test our new function.
We'll create a new variable sum equals genetic algorithm, and let's just go some evaluations.
We can bring into the results some of evaluations, but here is some run this code.
See, that's the sum of all scores in this population is one hundred and ninety six thousand.
Just a reminder, it is this sum of all these values here.
And in the next lecture, you are going to understand how to select the parents.
And right after we will move back to the Google collab and we will use this sum to select the best individuals
to apply crossover and mutation.
See you there!