‫Finally, once your embassy simplification has given you your seat to the Star Global, why max global
‫and why mean global?
‫Now we can use them in the main file.
‫So just like in section eight, here I compute my small f transposed.
‫And now if my constraints, which equals one meaning that I'm considering my constraints, then here
‫I create my CC matrix.
‫It's this one here you see, see till their star Global Times C double bar.
‫And then from that, I can create my g matrix that I need for my constraints.
‫And I simply take this CC matrix and I concatenate them like this.
‫And I have this minus sign here, because that's what you have in the G Matrix.
‫And so this g matrix here that we had derived some videos ago, it's this one here.
‫And now we also need to generate our H vector, which is this one here and this entire generation process.
‫It happens here with these two lines.
‫I multiply C Tilde Star Global Times.
‫A double circle flex times the augmented presence state vector.
‫So it's this term here.
‫Then this h one, it's y max global minus.
‫And then what you had received here.
‫So this is essentially your h one and then your H two that you have here.
‫It's minus y min global plus what you had here, what you had generated with these two lines.
‫So this one here, the second element, that's your H.
‫And remember this Y global star max and Y global star men.
‫And then your c till the Star Global.
‫They all came from your MPAC simplification function.
‫They are these ones here.
‫And once you have your H1 and H2, you can simply concatenate them like this.
‫And so you have your H vector and then once you have it, you also need to transpose it because your
‫kewpie solvers needs to have it as a role vector.
‫So this entry here, it's your role vector, the same thing like your small f transposed.
‫It's also your role vector.
‫And that's how you find your Delta U Global.
‫Is this one here?
‫Delta U global superscript c and then all this.
‫It's your solution that minimizes your cost function and respects all your constraints.
‫You put here your age double bar that you got from your MBC simplification function, then small if
‫transposed that you had calculated here and then your G matrix that you have from here and your h transposed
‫that you have here.
‫And then if you put here smaller equals CVS, except then it simply works better.
‫And then just like in section eight, you only extract the first delta.
‫You two, the first Delta you three and the first Delta you four and you discard everything else.
‫These are your previous two Q3 and Q4 values, and these are your new Q2, Q3 and Q4 values.
‫And then this block here, that's what you had in section eight.
‫That's when you choose not to consider MVC constraints.
‫Now you can see that here I have two brackets like this, and then here I only have one bracket.
‫The reason for that is that if I use the solver in order to compute my delta, you'll global, then
‫it's a roll vector.
‫And then I extract the first elements from this dual variable like this with one bracket.
‫But this role here, which we had in section eight, that's finding the solution using the gradient
‫method.
‫And this row here it gives me a column vector.
‫And so when you want to extract the first elements from your column vector, then you need to have two
‫brackets here.
‫And that's it.
‫Everything else in this code file is the same.
‫You calculate your Omegas, you go inside your plant, you get your new states and then you start with
‫a new loop.
‫And then starting from here, the animation code starts.
‫And there is also a course about how to create awesome animations in Python.
‫And now let's take a look at some of the results.
‫And let's see if our embassy constraints work.
‫Thank you very much.