[MUSIC] In this video, we're going to simulate the finite state machine that will be used to control the temperature for a room. That was part of one of the videos where we described the machine that will control the input to the temperature system, the heater, according to the threshold Tmin and Tmax. So the idea was that whenever the temperature that is being measured is larger or equal than Tmax and the heater was on, that means we should turn off the heater. So therefore, we should transition from K equal to on or k equal to one and k equal to zero means meaning k equal to off. Or when the temperature was less or equal than this minimum value to mean, and the heater was off the q was equal to off, then we should switch from off to on using this machine. So the way we're going to do that is using the Harrod equation toolbox, and I already prepared the model for that. In this MDL, what you going to see is the front of the machine corresponding to the logic. So let's go in there. We're going to have two parameters. The parameters are Tmin and Tmax, and those will play the role of triggering the events in the jump set. The jump map will essentially change from q equal to on to q equal to off, and back to on when needed. And we're going to associate q equal to zero to off and q equal to one to on. And therefore, the role of the jump map is essentially targeting the value of q. And the function 1-q, that stands for us as when q is equal to 0, this becomes 1. When q is equal to 1, this becomes 0. So that's the definition of the jump map for this machine or the discrete transition function. And the more interesting thing happens in the jump set where we're passing a parameter, what we call a parameters. The first element in the parameter's vector is Tmax, the maximum value of temperature. And the minimum temperature is the second entry in the parameter's vector. And the logic is as we describe in the video and is written here, when the heater is on, correspond or equal to 1. And the temperature is larger or equal to Tmax, then we want you to write the jump. Or if q = 0 meaning the heater is off, and the temperature was below the threshold Tmin. They are going to generate the jump, otherwise, they're going to launch generator jump. So as you probably see here, this u is really thought as being assigned to a temperature in the room. And at this point, it's not so, but we are just thinking about that for an interconnection with that in another simulation. So let's look at the initialization file. The initialization file sets the initial condition of the machine, and sets the parameters that are being passed to the machine. The maximum is 100, the minimum is 80. And the horizon for simulation, the rule for gems and the tolerances. And the post process here is going to pretty much plot this logic state, and the input apply to the machine. As you see right here, these plots are input, and these plots, the logic state. Okay, so we're going to simulate that. First, we're going to initialize. And we can do that from here, and then check that everything goes to initialize as we expected. And, This is the initial value of x0, 1, 2, let's see. Supposed to be that. Let's close that, let's close. All right, have some plots from before. All right, let's go back in this. Okay. And then relative parable three realization. X0 = 1, okay. So for some reason, that's not what we want. Okay, x0 now is 1, okay? It's good to check. And Tmax, okay, we have it right here. Tmax equal to 100, that means xD is equal to 1, horizon is 10. Okay, so now we're good to go. Now, we can simulate these. Creates the code, prepares the files for simulation, then we'll start doing the simulation for the horizon given. Pretty much up to ten seconds, as far as I could see. And now, we can plot these functions. I think this is calling the wrong file. So let's just try it from here. [INAUDIBLE] processing. FSN [INAUDIBLE]. Okay, so what's happening here? So the input to the machine is gone from 7 to 120, that's a good input because our thresholds are 80 and 100. So initially, when we are at 0 and the output, which is the molar machine, is initially equal to 1 and remains at 1, that means that it will be trying to tell the heater to heat up. Again, this is not connected to the heater. But as soon as the input becomes 120, which is larger than 100, what happens to the transition from q equal to 1 to q equal to 0 happens because the input is larger than the largest threshold, Tmax. And it will remain there until the temperature becomes more than 80. And in here, 6 seconds, it becomes 0 and it generates the transition from off to on right here. So that's the simulation of the finite state machine that we would like to connect to the temperature problem. [MUSIC]