[MUSIC] Our last example about a gen based model will be simple simulation of bacteria chemotaxy. So, as I told you in the introduction, this phenomena is really interesting because bacterias, despite their really small size and simple nature, yhey are able to swim to a source of an attractant solution like sugar or a glucose solution that they would eat for energy. But in fact, they can also swim from a repellent solution like ethanol, for example. If you put a drop of ethanol, they will swim away from it. And it's quite interesting because it's a similar mechanism. And as I told you, the movement of bacteria is really, really simple. So bacteria, they have flagellum kind of filaments that can rotate. And if the filament rotate in counter-clockwise mode, every filament will join and bundle together, and some effect of all these will work as a small propeller and propels the bacteria in a straight line. But if the filament starts moving in the opposite direction, a clockwise direction, so the bundle of a flagella will segregate and due to turbulence, the bacteria will tumble and pick a random direction. And if you track a single bacteria moving in a gradient of sugar for example, you can track it automatically with a microscope, of course. You will see that Its trajectory is composed of lines, straight lines followed by turns. And quite abrupt turns. And people observing that, they emit the idea that, in fact, since bacteria cannot sense a spatial gradient. Because it's too small and the precision of a chemical receptor is not big enough to distinguish the concentration in the various direction of the bacteria along all the envelope. Since it can not sense these concentrations, the gradient concentrations in space, it can sense it in time by remembering the last amount the bacteria has seen. And moving bacteria can compare the current value with the last value to understand if it's going in the right direction or not. If it's going in the right direction, means a direction that makes an increase in the gradient, the bacteria will try to keep a straight line as much as possible. On the other side, if the concentration decreases along time, it means that the bacteria certainly has not chosen a good path. And it would start tumbling to try to find a better direction. in fact, of course, this behavior is stochastic. So, we can make a really interesting model here to test that. By coupling together a diffusion model, which is diffusion of nutrient, because the nutrient can diffuse. For example, suppose that we have agarous gel with low density, like a lb medium with really low density where bacteria can swim and a substance, chemicals can diffuse. We put some drops of sugar, and the sugar will diffuse. The bacteria will swim, and here we can simulate that system by coupling together the diffusion model of sugar and the based model of bacteria using some simple rule. So first the total model, it's Eulerian 2D grid, and in each cell, x y, we have first a list of bacteria. The list in the cell, and a concentration of nutrients. Every bacteria are indexed by i, and they have a state which is first, the last direction taken. Here, we suppose that the bacteria can just take four direction to simplify the model and using Eulerian view. So north, south, east and west, of course. We could implement the same with the totally free direction. And then the last concentration of nutrients, which here is a floating point number. And with just this two information we can then compute some, the next behavior. So the idea for every bacteria. It remember the last concentration, the last direction, and it perceives the current concentration. So we have to add two model parameters. The first one is pi, the probability of tumbling when the concentration increases. And the second is pd, the probability of tumbling when concentration decreases. And the idea is that pd should be smaller than pi. So, a bacteria has always a chance of tumbling but if the concentration is increasing, it has a higher chance of continuing straight. If the concentration's decreasing, the chance of the probability of tumbling increases, of course. And that's enough to model our system. Here is put in the Python, so the perception is the rho, the state is the last concentration seen and the last direction taken. If rho is smaller or equal that the last concentration seen, the concentration is decreasing and so we'll take the probability, the high probability of tumbling. If it's not the case, it will take the high probability of tumbling. Draws a random number, if it's smaller or equal than the probability of tumbling, it will tumble, so it means that first of all, it remember the current concentration. And so that's this data, and then it will take a new random direction, will tumble. If it's not the case, you will continue in the same direction as before, but updating the concentration. And that's enough to model our system. I can show you a simple animation of that. >> Here you can see two concentrations, two sources like a small paper with glucose that will diffuse. And the red dots of course, are the bacteria. As you can see, they are focusing, they are aiming for the high concentration. If you follow the path of a single one, you will see that the movement really looks like the experimental tracking of bacteria. It looks pretty random but at the end, it has a high chance of coming in the area with high concentration. You can see here the gradient of concentration is displayed by this gray level. And if you wait a few iteration, almost all bacteria, they will arrive at the source. Other source are high, so they will not be consumed. But if we consume some source, you will see like after a while, the bacteria will finish eating all they can and they will disperse and recover again. They will diffuse again on all the domain. So of course you can ask yourself, are bacteria smart to track concentration and draw random numbers, but it is the case. Oh yeah, I forgot to tell you of course, to solve the diffusion, I used the standard diffusion equation, so we find the differences which allows me to use the same grid for tracking the adjunct, and for tracking the concentration. And to have an update which is first day of the concentration, and then the agents. Bacterial movement is really easy. What is really interesting is that the molecular mechanism is known, so we know exactly how the bacteria, they have this memory how they can check if the concentration increases or decreases. Details are a bit complicated, and is the same system for being attract or repelled. It just depends of the receptor. So that's the outer, You can see it's the out of the bacteria so it's between two membrane for not really important, where you have a receptor that can sense attractive molecules or repulsive one. And also you have the molecular motors of the flagella, that's real biology. And you have lots of these flagella, and you have even more of these receptors. And what is really interesting in the system here is that we have several concurrent mechanisms. First of all, when these attractant molecules, the excitor receptor, in turn it will propagate this signal to a cascade of [COUGH] chemical modifications. And the fact, first of all it will change the probability of the flagellum to rotate in one direction, but it will also reduce its own sensitivity. And thus to keep the same level of excitation of signal, the concentration must increase because if it's not the case, an excited receptor will insensitive itself, so if the concentrate increases, the same response is constant. If the concentration stay even, since it is less and less sensitive, the output signal will decrease. And of course, if the concentration decreases, too. But on the other antagonist mechanism, which will restore the kind of default state which will help to forget the past. So a bacteria can again be surprised by the fact that this is again some nutrient, and that will reset in some way the mechanism if we wait long enough. So, the model presented you is exactly what happens in bacteria, except this description at higher level. But now of course if you're interested in that you can have better models by analyzing this older reaction, the chemical reaction here. Experimentally, we know the constants of these reaction, so we could build in every agent a small system with differential equations that are able to compute the amount of each of these molecules and have the probability. So the model will be perhaps more close to nature but at the end they will function with exactly the same principles. That concludes this lecture on agent based models. I hope you like the example, and my suggestion now, if you are more interested, is to read the references and to start playing with simple models. Thanks for your attention. [MUSIC]