 Good afternoon everybody. So I will go a little bit back and restart some of the GAs such that yeah evolutionary algorithms and The idea is that Adoptation is intelligence and people put it in a Rather I don't know Not not nice way at least for in a social context that this is a this is The survival of the fittest which is somewhat misleading so during the evolution Many many species come and go on a daily basis several species disappear Some of it is our fault in recent times most of it Naturally happens and We may understand it at this the survival of the fittest So as we as in the last lecture, I'm sure you have heard a little bit So it's about how do we use this? So how to use this idea? for optimization We talked about it that some colleagues within AI may not necessarily agree that evolutionary algorithms are Part of AI because they are designed to do optimization and Optimization in a strict sense may not be understood as learning So I don't want to get into that fight because I have used evolutionary algorithm a lot They are very useful techniques and there is no way that we can do AI without optimization no neural network will run without some sort of optimization so and Something that in the modern in modern nature has taken millions of years to create really highly sophisticated species Cannot be stupid. So it's it's is the concept of learning from from the idea To that adaptation is intelligence. So if you adapt yourself to the circumstances, you're going to be an intelligent species Sometimes you know you have to adapt But you just not flexible enough to run from the stone that is coming from the heavens. So You get this thing like the dinosaurs Maybe they wanted to adapt, but they were not fast enough to adapt the cockroaches adapt really fast and Mars too and us so Let's say even is a strange function. Let's say I have a function f of x and I just come up with with something something really arbitrary, let's say x1 squared plus log of x2 plus sine of x over 1 minus x Sorry, this is x3 and this is x4 So I have a function that has four variables x1 x2 x3 x4 and for some reason I want to find the maximum of f of x Given some constraints If you remember when we talked about support Victor machines, there were some constraint There is always some constraints. There is no optimization So if I say maximize this so that the algorithm will go and put all values at the maximum value that computer can understand So okay here the maximum value But we know or if I say minimize them we put them all all minus infinity or zero and okay is minimal So optimization makes sense when you have some constraints So I say okay, no no x1 should go between this and this x2 should go between them this and this Exponent x2 have this relationship. Okay. There are some constraints which clearly come from from From application so now you want to you want to you you want to solve equations like this Quite arbitrary. I just I don't It doesn't make sense even to try to maximize or minimize this so I just grabbed an arbitrary function and Okay, this idea now. This is a really this is a far-fetched Action that we try to solve something like this with the idea of evolution. So we know I'm sure you saw something like this that You have a population so you're talking about a species And this is already a huge simplification because No species can be isolated. You are always affected by other species by by nature by many things But assuming that you can isolate a species the gene pool of a species when you say population We mean the gene pool of a species So then the gene pool of that species is a collection of many many chromosomes That over time has created the characteristics and Attributes of that species So these are chromosomes This is a quiet Low-level understanding of a population. So evolution affects the genes so a Population for me is the collection of see when you send your If you want to find out your Ancestry I Have done it is fun. I don't take it seriously So and then you send something and they they Compare your genes with different group of people because you're selective They select a small part of it because if you compare the entire genome of us with each other 100% match Congratulations, you are homo sapiens But we compare specific parts with specific groups and I say okay you match with Irish and you match with Italian And you get a ticket you want to go to Italy find your ancestors Because Italy is the center of civilization. Okay, whatever whatever makes you happy. So what we are working on genes Okay, so these chromosomes that contain the material that are affected over time millions of years Even from the get go before you tell me anything whatever this idea of evolutionary algorithm is it cannot be fast algorithms Why not because evolution is sluggish? Evolution is slow Evolution does not happen. So what why do I I don't change my skin color if I go from this continent to that continent within 50 years Why it takes time? It takes time it takes a long time So what the evolution does? You do some sort of selection So you select chromosomes. How do you select chromosome? What it happens? So it in the natural course of things you select chromosomes now. We are you're trying to intentionally Intentionally select chromosomes Let's say I don't know one of them is chromosome like this and The other one is chromosome like this So I'm just doing some arbitrary pattern to be able to do something with that So these are these are parents I told you so when when when when life came about on the planet and for a long time there was no diversity We talked about that I guess I mentioned that Maybe it was another class. I don't know. So we had a few species on the planet and Then they'd have tiny time from with a very very short time from 35 million years, which is extremely small time Suddenly the number of species on the planet explodes We get millions of forms of life Called Cambrian explosion. We don't know why that happened We have some guesses we said Life life organisms didn't have vision before that so vision developed things got accelerated More more popular among scientists. There was no sexuality before sexuality developed things got accelerated So but whatever happened is happens with mating Male and female sexuality. So that's the way that genes develop in most species so then of Course you have to do crossover So when you do crossover, basically you select a random position So now I'm talking I'm trying to get inspiration from modern nature and trying to come up with a model So let's say I grab this position So because this will be in my computer just a vector I Can grab any index of any vector and if that happens so the crossover the way the simplest way that we can basically a Simplest way that we can simulate Crossover and mating is okay. This part is coming from this individual and this part now is coming from that individual and Other way around So now this is my offspring So and this was the point The point of crossover so that's this is very simplistic, of course as Perhaps is a if you show it to a biologist and say what are you talking about? It's not happening like that. Well, we know we are you're coming over with an abstraction abstraction to make things happen in computer So I have Go back go back. So I have I have a pool of randomly generated vectors I have to work with numbers Randomly generated right and random weights of a network random set of actions values for reinforcement learning And then I grab maybe at the moment. I have no idea how to do it I randomly grab some pairs of chromosomes vectors and then randomly grab a position and Then I swap those parts those fragments such that my offspring my new vectors are a combination of the parent vectors Okay, I just heard random random random. What do you want to do with so much randomness? Oh Trust me the god of randomness is very powerful extremely powerful and So we can also grab one of them So let let's see I grab this one and I grab one position And I apply mutation So why that? Because we know that mutation which appears to be a random change in genetic material Brings about a gigantic possibility for the evolution to create new things of course mutation is also Extremely dangerous you mutate one gene and you get out of Hitler or You get Albert Einstein So it's a very risky business. So we should not exaggerate mutation Don't mutate too much This has to happen a lot This has to happen a lot. This is this is the engine of evolution mating But this you've got to be economical with this You cannot this very often So and then we take a look at this So this is one of them that has been now genetically modified and then we put it back if Fit So which means it could be that you create offsprings and you don't add it to the pool. Why? You have to answer one question So if I have a pool of certain number of chromosomes which for us in the algorithmic world or individuals Do you want to keep increase the size of population? You can't so what do you do with memory management? So we assume this is an island that has a certain capacity. You cannot go over capacity I only get hundred chromosomes not more so if they are good kids and I want to add them. I have to get rid of two existing parents Sounds quite brutal. Why is I don't know this type of nightmare Why social Darwinism is something really ugly terribly ugly that you think you can bring the concept of evolution in the society Racists love that theory So, yeah survival of deficits. Why you are not if you are not the fittest you are just a racist bastard So this has this is very different from the course of evolution that things happen really slowly Evolution does not make a list To kill a certain group of people one by one that doesn't happen that way it happens naturally slowly and Actually, nobody good hurt because the way that nature does it is very very graceful very graceful So I have to answer many questions to come up with an algorithm for this How many what is the size of my population? I? Would say that depends how difficult this problem is How how do I select parents? Was a Bible of the fittest I need good parents fit parents What is that the guarantee you see many good parents their kids really not good kids and Other way around you see good kids and you see the parents who say how do they get this kid? So you have to answer all those questions and then the mating and then the mutation how often do we apply the mutation? Okay, so the first question in my mind is How to apply This abstract idea to the Real valued Optimization problem what that's that's not easy and we have seen several cases so far. We started we started with Frank Rosenblatt So it's an enormous pioneering work When you come from an abstract idea to an explicit computer algorithm, that's a huge achievement Your name definitely goes into Wikipedia if that's important for you John Holland was one of the first ones was thinking about this so okay, so how can we do this? Well, if I go back to this Weird-looking equation you can grab anything. It doesn't really matter x1 square plus. What was it? log of x2 plus Whatever it was sign up x3 divided by 1 minus x4 Some some constraints. I don't care about the constraints at this stage what there has to be constraints Everything is limited. So there's an island. There's not enough food for everybody I don't know x1 and x2 are close to each other x3 and x4 don't like each other Whatever that is so you need to put the constraints in place. So, okay, so which means we we want to We have to Find the optimal values for these guys So maybe Depending on their value I Encode them as binary numbers So I just took randomly five bits. Is that is that enough? I have no idea. I Don't know what I'm doing. This is research one two three four five one zero zero one one and then I have one here Zero zero one one zero and I have one here One one one zero one So this is this guy. This is this guy So if I convert my numbers the parameters that need to be optimized in Binary format why binary? I don't know. Binary is easy At the moment I just want to get it up and running after after it start to work And I will think about other type of encodings Because you have to encode the information make it accessible to make it accessible to the algorithm So, okay, if I do this Then my chromosome My chromosome will have one two three four parts four fragments one two Three four and each one of them has Five one two three four five one two three four five one two three four five two three four five So I want to write it here one one zero one zero down the next one is one zero zero one one the next one is Extreme let's say one one one. You have to keep it consistent. The last one is zero zero one one zero Voila, I got a chromosome. So now I generate many of this binary chromosomes binary vectors Nobody can prevent me from creating my own terminology one of the one of the one of the really Good characteristics of a scientist as they don't give it down They create their own terminology because if you're creating something new You have you cannot you cannot talk with the existing words. You have to create your own words So I call this vector my chromosome. Okay, whatever makes you happy show me show me that it works and I'm right with you So then I can generate This is four times five 20 bits 20 bits if I give it to somebody from information technology he or she will immediately ask How much information can you encode with 20 bits? I'm not there yet I'm just trying to just establish the framework now I can generate as many as I want from this type of vector and Create my population So now any binary vector that I grab I know the first five bits X1 the second five bits are x2 and so on and so on So I'm changing everything at the same time and I'm looking of course for the solution I'm looking for the chromosome that gives me the best value for x1 x2 x3 and x4 Okay, good luck with that because at the moment. I don't see any deterministic Algorithm, how do you want to do this? I don't hear gradient descent or I Don't know. Well, how do you want to do this? Well, we get there We get so okay How would a simple? Genetic algorithm work it was it there wasn't explosion Before deep learning came along and killed everybody else There was an explosion of new ideas after we saw that evolutionary algorithms are so successful And then people went out and looked at other part of nature look at ants, okay Let's come up with an ant algorithm bees. Oh my god bees. How do they move? How do they make honey? and so on and so on so a lot of Naturally nature inspired techniques were born many of them very powerful and colony optimization is one of them Hopefully we have time to talk about it. If not, I will I will upload some some material so a simple Genetic Algorithm short GA So GA when you talk about GA we mean canonical GA the initial the simple the conventional There are many many advanced versions that We don't have to talk. We don't have time to talk about it. So first of all you initialize your population of course, I Don't have anything else if I don't have a population of chromosomes. I cannot do anything. So How many just grab a number whatever? 50 hundred five hundred Generate randomly 500 vectors that are randomly set to zero or one Okay, you see you get to be a little bit insane because if you're playing by the rules nothing gonna change Playing by the rules you will be still multiplying matrices Which is which is which is a nice thing to do TensorFlow does that so Then we go we go ahead and we say okay now calculate the fitness of your population Okay Now I'm starting to freak out because I have no idea what you're talking about What is fitness? What what was the driving force for neural networks error? What was the driving force for reinforcement learning reward on punishment? What is the driving force for evolutionary algorithm? fitness So anything that I develop it has to be fit anything that evolves has to become fitter But what does that mean? Well? depends on your application This is one of this is a this is a key design factor for evolutionary algorithm. You have to figure out what is Function describes the goodness the quality of the final solution. What is it? Then we have to go inside a loop Of course, there's always a loop while stopping criterion not satisfied I Have no idea how long I have to do this because if this is inspired by evolution while evolution is ongoing forever I cannot go forever So I have to do it within a specific amount of time We'll have to think about that Okay, then we go inside the loop and we do what I did select parents How okay? I don't know select good parents select fit parents So you already set your fitness function There could be that you somehow you feed in those binary numbers binary vectors and the fitness function Just gives you a number that says the quality is that much the fitness is that much So select parents Then perform Crossover so when you perform crossover you get offspring Why do we do that because we need new genetic material? Modern nature doesn't like it when things to stay the same In contrast to us we love we love things to stay the same We are afraid of change in contrast to our nature nature loves to change things You have to change Okay, if you don't change I will punish you and I don't even tell you that I will punish you and When you realize I'm punishing you is too late. You got to get distinct in five seconds So and after you have offsprings We apply mutation properly In a suitable manner we apply mutation again mutation is a very different mechanisms than crossover which is mating To create new genetic material if This is if each one of them is really a number that we converted to binary number Then you have low significant bits and high significant bits So if you apply mutation on a low significant bits You're converting 22 to 21 who cares If I apply it on high significant bits you convert 2 to 255. Oh, that's a big change So we can play with that carefully. How can I bring diverse? You know, this is the mind of an algorithm. There's on a forget about AI Algorithm design has nothing to do with AI in 50 years AI is gone something else is calm, but algorithm design is still there Because we have to bring the idea to these stupid computers and they become Stupid every day So they become faster and faster, but more stupid So we have to our job becomes more difficult to make them understand what we want from them so apply mutation and then of course calculate Total fitness Calculate the total fitness of population. How fit are you? So because what it happens is over time you start with a random selection of your gene pool your chromosomes And you select you and you mutate and you cross over mutate and if they are good You add it to the population and you grab the worst parent and you say get the hell out of here Go Again think about social Darwinism so Okay, what what happens then over time only good parents stay So if you come if good parents are green and bad parents are red You start with a mixture of red and green and you see that the population is turning green green green green green Green and then everybody is green and then the intensity of green starts to go Light green dark green extremely dark green. Oh my god. Everybody's green so that means Now at the end the fitness of the entire population should be very high Then you have converged then you have a bunch of solutions bunch of solutions with no or not But we were only after one solution whole different beast Evolutionary algorithm. They are really good if you are in a highly complex environment But ideally you have more than one solution So they can find some of them And that's why the astochastic nature comes so handy so, okay, okay, so Again, if you have a good abstract mind that can take abstract ideas and turn it into a specific Python algorithm, this is enough To implement the first GAs you don't need to there are many many Implementation available So but before I do that before I invest my valuable time Instead of going on vacation. I should sit down and write code for evolution in algorithm you have to answer some other questions to convince me to do it because You already have we already know so many good techniques, you know, you know K means we know SOM We know back propagation. We know reinforcement learning. We know, you know deep learning who's beating everybody Why should I think about yet another method? Why should I do that? I thought we can apply deep learning on everything No, we can't so why should we use GAs Well, I virtually algorithms are more than genetic algorithms, but I Intentionally want to restrict that to genetic algorithms because this is the prototype It's very simple Things can get really complicated. I'll give you one example. Maybe at the end things can get really complicated So I want to I want to stick with the canonical Genetic algorithm really simple structure So why should I use that? Wow, you know what I? Love coding and I'm really big on things that are simple and easy to implement. So this is easy to code You disagree can how long does it take you to code a? flexible model for convolutional neural network from scratch you would need two three months and Of course, I would need probably four months in my age So how long do you need for this? Give me a I don't know. Okay with old debugging. Okay a day. I Haven't so this is easy to code That's a big factor for me as an engineer But you say okay, there are libraries I know but there is always the possibility that you have to come up with customized solution And as engineers when you go out there you will realize it within the first year The libraries are great and we have to know them, but they will not solve all problems in many situations You have to develop from scratch So another reason that we should use j a genetic algorithms they use many solutions or They provide many solutions So that means they can avoid They can avoid local extreme So if they give me at the end after whatever 10,000 What do we say for evolution algorithm iterations? episodes Generation I like that generation So after 500 generations Then what it remains in the population is only fit parents That's really good. You give me a lot of alternatives get take this solution or that solution of this solution That's very flexible. Of course You can do genetic algorithms in parallel So I can I can send it to several cores several processors to say you do this you do this you do this you do this I don't need GPUs. Well, unless you are working with images That's extremely valuable That you can break it down that population sends I don't know a quarter of it to this cork No, I days you have 94 cores on on a single machine. So if you can do multi-threading fantastic, so Life is good. Things are fast evolution is not that slow Okay, good easy to code it uses or I don't know maybe maybe I do gives or provides many solutions and That's good because it avoids Many of them are really high quality solutions and then I can I can implement it in a parallel fashion, so it goes fast Okay But there is no free lunch, so what is what is the problem with GAs? Well, they have problems too like any other technique So what are the shortcomings of GAs? You know toward the end of the the term I have grown more suspicious Because I was beaten badly by complex Techniques and I didn't ask this at the beginning. What is good about this technique? What is bad about this technique and I went into it. Oh my god It takes such a long time to design a deep network and train it reinforcement learning even worse Fuzzy system. Yeah, but they cannot learn every method has a problem. I want to know it now for from the beginning Such that I can plan my design Well Guess what? They are slow They are not just slow. They are extremely slow. They drive you to insanity. There's that slow And that's of course because of their nature evolution cannot happen really fast You have to give the evolution time to change things in proper way So they are slow If you have a real-time application, you need you have 200 microseconds time to do something I would guess from the get go evolutionary techniques are not the best approach so because You get to have I don't know five six seconds at least even if you use multi-core and whatever so Have to know that that's that's very important fitness function may not be May not be easily Design, how do I know? Well, we don't know What is the fitness fun the driving force of evolutionary techniques or fitness function and There is no classic fitness function also. I go with RBF. No, there is no RBF Okay, I go with sigmoidone. What are you talking about? The fitness function for evolution algorithm comes from the nature of the problem. So we have to sit down understand the problem Something that sometimes when we are lazy, we don't like to do that. Just give it to me. Well, I don't know what it is Okay, okay. You are slowly but surely convincing me. Okay. Okay. Good. Okay. I can't I can't get engaged with this idea But if I want to start this and you're talking about initialization of population How many so what is the population size or basically you are asking how many how many chromosomes in one generation and we said that that word Generation is our replacement for iteration episodes and So on so now we will talk about evolutionary algorithm if you go to an evolutionary conference and Between the break with in two session talks to I don't know postdocs and it's like yeah My evolution algorithm had some iterations. I said well what? Your algorithm did what they don't get it because they talk only about generation Sometimes of course, they do it intentionally so just to Be annoying so okay, so one is you may choose too many So I have a problem. I don't know you have to see what the problem is. Okay. What computers are good I have a lot of memory I go with one million chromosomes Okay, so then your genetic algorithm will be extremely extremely sluggish It will be it will be just go forever You're back in 1995 and you have a multi-layer perceptron with eight layers and runs and runs and runs and doesn't come back So it's not a solution to just okay. I have memory. Just go with as many as you want. You cannot do that Okay, okay, so I go all the way around I Will grab just too few No, I go with ten ten chromosomes. So the if you do that there are not many possibilities Formating which is crossover. What type of society would that be? There is there's not my choice Nobody likes that which makes the algorithm behave in a way that only a Part of The search space Will be sampled did we talk last time about? 400 and chess and to to power 400 and How big that number is That if you even start counting from the big bang to today You have not even started to count how much how big to to far under this 400 bits if you go with ten bits How much is the search space that you can search? It's not big So you will be very limited. Yes Absolutely not We don't care about derivatives. This is modern nature. So it just has its own forces It doesn't need to be Differentiable at all it has to be connected to the application But not differentiable so maybe we get there and we have some some some Better idea What that means? Okay Differentiable is all for gradient descent That's the engineering wall, but not not the natural one Okay Yes, yes, yes I'm sure there are But we don't model that at least I'm not aware of any GA evolutionary model who has made that Specification among the chromosomes because then you have to really model what is what is female what is male? So is it let's say it's an extremely tolerant society. So what about the crossover frequency? They may be some versions out there. I don't I'm not aware of any So How how often do we let fit parents mate? Well, you can say, okay, you know what all the time so a hundred percent That if you do that that means all offsprings All offsprings are made By a crossover right How else if you do Never so zero percent Then that means you're just copying the parents. Can you do that? Can I just copy? If I see a couple or parent Which extremely fit? Maybe I give that parents a bonus and say you can copy paste yourself That's such a good parent. We need more like you So we can we can we can reproduce we can select to we can select to cross over we can let them Reproduce just by itself something that there's also no Well, not on the normal circumstances unless it's a Hollywood movie. No individual in a species can do Yeah, you need always the pair so perhaps It's reasonable to copy some Chromosomes Which is what does it mean how many some chromosomes? Into next generation into next into into the next generation Perhaps it makes sense We don't need to mate and pair them all the time If you see that there are good parents as a yeah, okay, I copy paste you. Yeah, two more like you come on Okay, probably I don't know 80% to 95% something like that. We have to play with this for some cases For some cases, maybe I don't know 60% I'm just throwing empirical numbers at you one of the things that you have to learn in AI is don't freak out When you hear the number who said that? What is the formula for that 60% nope? People made some experiment and it seems that number makes sense for some applications That's what all what it's all means You may work on as a no, not 60% 52% okay Good Okay, so sometimes We should just copy paste balance And it's also cheaper Copy-pasting we're producing just by itself is much cheaper than crossover. I have to find the crossover point. I have to Just swap them. It's a lot of computational If I have one million chromosomes is a lot of work Okay, okay, what about mutation frequency? So how often should I apply mutation again? You can go. You know what never So zero percent of the time so what happens if I never apply mutation Then there is no additional from sporadic from time to time appearing Diversity in the offsprings so no change in Copies if you copied or in offsprings No additional change, right? If you never apply mutation and you will make the painful experience That it does take longer and there is no mutation interesting You have no idea where to apply mutation you randomly select. I mean a certain probability So here you are saying never so with zero probability So let's say we send them second option is too often. What is too often? I don't know whatever So let's say half of the time so 50% It's 50% too much for mutation. What if the danger is to get adult filter? Yes But maybe we're lucky when we get a lot of Albert Einstein Wishful thinking Those comes just maybe one or two per century. So what happens what happens what's bad about that? Think about it if I apply mutation too often 50% of the time I grab a random digit and say this guy this position Flip it from zero to one or from one to zero. That's the mutation if I go with binary encoding Just flip it you mutated to a new state But then the position with a slow significant bit or high significant bit It makes a small impact or a big impact. So what can go wrong if I do this too often? What can go wrong? Not bad. I'm supplying mutation. I know you may get 50 hitlers and They are fighting There's no peace What is peace convergence so huge variability preventing Convergence So if you if you just do that you don't you don't let the nature take its course and Get somewhere I want to get somewhere you create another guy another guy another guy this person that person Let me work with what I have. I Want to figure out where to go and then you suddenly change it again So diversity is good, but too much diversity is problematic again. Don't bring this in social Darwinism talking algorithm So and then third time third possibility is rarely I don't know what what is rarely let's say 1% of the time Okay, what is the difference between 0% of the time and 1% of the time a lot a lot So this is one of those things you see you see piece of work with genius artists and It's just blue Then there is a yellow dot and as in a museum and people are willing to pay $450 million to buy it. So this is additional diversity Contributing to good solutions Why is that why don't forget we do crossover we do reproduction copy pasting That already brings the crossover part brings a lot of diversity So you don't need to exaggerate it here Just be modest be modest with mutation For instance the probability of mutation is one over thousand So one out of thousand chromosomes we apply mutation Every every 999 go the thousands one apply so typically typically we are between 0.5% to 1% Typically this is this is the range of mutation for most problems Okay, good. Good. I'm getting a good picture how to implement this stuff Because this is clear guidance for implementation. How do I do that because every algorithm need a setting needs to be configured then I can Apply to get something meaningful Okay. Okay. One more question. One more question How do I select parents? How to select? Parents What this is the actual thing? Because the population is the first step of any generation is select parents and Then either copy paste them because they are good parents or Apply crossover and in some cases mutation and then put them back in the population the offspring's if they are good kids Okay, there are there are some ways of doing it first How do I select parents? When fitness values are very different So what does that mean? So I have some fitnesses and The fitness values are all over the place. I have low. I have medium. I have high. I have very high I have extremely low. So if that happens I can rank my chromosomes based on their fitness and Then I can select the ones maybe at the top because they're very fit So we do parent selection if there is a gigantic amount of diversity in the fitness values. So So we call this rank selection Which means we rank We rank all chromosomes We rank all chromosomes based on Based on their fitness values their fitness values And then you select the top ones Can it be that I in some generation I grab again and again the same two panels because they are fit They are at the top that can happen. Yes, but don't forget the crossover because crossover happens at a random Random bit random position But you have to keep you need to do some bookkeeping if that happens Maybe I come down and grab another one is always good to bring in a little bit of randomness in the selection Second What happens when when fitness values are not very different? Fitness values are not very different. It doesn't mean they are good or bad. They are just not different So it could be all of them are have low fitness values So all of them have medium fitness values or all of them have high fitness values So they are not very different. So I cannot say who is good who is bad? All of them are bad at the same level. Which one should I take? So if if values are very different, I know who is on the top who is at the bottom What in these cases we can do? Roll out wheel selection just rotate the wheel and Select one of them. So Which means you have if I can draw that circle So you assume you assign segments or fragments of that? Wheel that you are rotating According to the fitness value of people Sorry according to the probability of Accurance of those fitness values. How many times do I have that fitness value? You may need to discretize to count them together So that means for example, so if I if this is the point and Then you rotate it and it stops at one of them. It's okay. I go with this one So if it is very frequent It's a higher chance that you grab it If it is not very frequent like this one So I will not grab it very often So if the fitness values are not very different, I have to go with the probability Frequency how many times I see things like this and I have to put them together because You may not get exactly Or to group them you have to put things you see this is what there will be a lot of details in the implementation How do I do this? This would be one of the sticky points for me? Okay? This is one of the points that I come down and go drink a coffee come back Grab the paper on this. Okay. Let me look it up on the back How have other people done it? You have to think about it, but it's clear if Fitness values are very different. I rank them themselves Grab the best one simple if they are not very different Then I have to work with some sort of frequency and probability for which I may be forced to quantize stuff Okay, okay What are other models? What are many models other GA models? maybe I'm just so excited I just want to know ahead of time Island models were quite interesting and so we said you you have a population and Inside that population you have a lot of chromosomes and then you apply whatever I talked about you apply selection cross over mutation Added to the population if if good enough now what happens if I have another population What happens if I have another population? Well, this is what happens in the nature. What happens if I have another population? So and they are migrating among each other Well, I would not implement this first because definitely this would be much more difficult to implement So I would implement just one circle and assume that this species has nothing to do with other species So but each if you have four or five ten and populations With distinct genetic material and there is possibility to migrate So they have I don't know either either they come illegally And you cannot build a wall to not them let them go they come Or you are nice and you have an immigration policy. It's a common guys. You want to live here come just behave Come here so we can do that but clearly the Implementation of this is much more complicated than than individual model So these are these are basically subpopulation and this arrows indicate migration Which has been a powerful Powerful way in the nature to things so Homo sapiens came out went To to Europe went to to South Asia went to far East Asia So and there was there was a time that this is just interesting to know So there was a time that for political reason the government in China tried to prove That the Chinese are from descendant from home erectors not from Homo sapiens Very interesting story when politics come into the play and want to change science and They they did so this is no we are we are we are Chinese. We are different Nobody wants to be the same Everybody wants to be different. I don't I have not still Understood that why do you want to be different whereas we exactly know we are the same. No, no, I'm different So the government wanted to prove that the Chinese are from descendant from Homo erectors For political reason clearly so they run the largest Genetic experiment ever conducted if I'm not mistaken more than 70,000 sample taken across China China is not a small country and Many many years of changing and matching and so on surprise surprise Chinese are also Homo sapiens You could have asked me I would have told you and you could give that money to me and support my research Yeah, okay, so migration is good And of course that the reason that they thought that they had they had a little bit of base because there was a lot more fossils of Homo erectors in forest Asia than let's say in Europe in specific part of Europe and that was a good pretext. I said, oh look look we are you're this you're not that Well, we migrated a lot So if we would just for fun if you have that hundred twenty dollar do that DNA test for fun Don't take it seriously and you will see you are mixed in a tiny tiny tiny tiny fragment of the genome So, okay Interesting Okay, I'm getting close. How should I initialize? How to initialize GAs how to initialize the population? How do I do that? Well Generally random. I'm pretty sure Randomness has played a role when we left today's Ethiopia The beautiful Africa and you and so some of us is okay. I go left. That's also I go right I'm pretty sure most of those decisions have been random and second We could Embed domain knowledge You could embed domain knowledge to seed the population So if you know something about the problem, there is no reason to torture the algorithm If you have something if you know something give it to the algorithm I say there could be good solutions here Stay spend more time here Why not? You are biasing it of course, but is it really based on knowledge? Okay, then bias it and bias is a good thing. Why is it and third? It has to Be a uniform uniform mixture It has to be a uniform mixture of possible values We talked about that normal network. You cannot Initialize the weights of an all-network just with zeros you don't go anywhere You have to break the symmetry Same applies here Everybody cooks with water So diversity is good having a really diverse population to start with it's always good Network reinforcement learning genetic algorithm. It doesn't matter It's a good starting point to start from a diverse population Okay I'm getting really close Really close I want to have a break, but I have maybe one more question Before I have a more realistic idea about this. Okay. Okay. Okay. So let's say I do this I go through the all the torture and implement this Okay, when to stop? When to stop the evolution? Wow, there are many options We can go with maximum number of Generations Which you will do some painful experiments until you find okay? Hundred generation is super fast 500 generation is very small very slow I don't know I go with 200 or 5,000 generation generations or 10,000 generation So you have to find out but then I said it and say Go 5,000 generation and then stop then give me the population whatever you get second You can look for a minimum level of diversity you don't want maximum diversity, right? If if the evolution has done his job then everybody inside the population is fit Everybody is fit So you don't want much diversity at the end At the beginning you like diversity Toward the end you don't like diversity So minimum level of diversity to stop third Well some level of fitness some level of fitness If you have an idea What is the maximum fitness for a chromosome is? two and You have 500 chromosome, okay 500 times 2 is thousand Okay, go until maximum fitness is 700 at least so Target a Some level of some level of fitness for so we have many ways to stop apparently certain number of certain number of Generations when No significance no significant no significant fitness Change occurs So not just a certain number of maximum number of generation What you say, you know what? Why do we say that? Because if I have number of generations and I have the fitness total the total fitness then What happens is this something like this so the last one is saying look What is a certain number of? Generations that no big change happened No big change so Then here you stop you realize is is 150 Generations there is no big change in fitness anymore I pushed it at the beginning I gained a lot after fluctuations But now is going 222 221 222 221 200 so it's not going anywhere anymore. So stop it Don't waste the computational time so a certain number of generations Which could be whatever 10 20 50 100 depending of what is the max number of generation? If no significant change, what is significant? Have you taken statistics? Significant no significant just is happening standard deviation is really low. Okay So we want to take eight minutes break and then we start at 650 that good