‫But now we discussed that when we wanted to find a solution that minimizes the cost function.
‫And at the same time, we take constraints into account, then this gradient method here, it was not
‫suitable anymore.
‫And the reason for that was very simple.
‫The gradient method makes the gradient of the cost function zero.
‫That's why you have here this condition here.
‫And from that, you compute your solution.
‫Delta, you global.
‫But if you look at this mini example here, then you can clearly see that the only place where the gradient
‫is zero is this place here in the center of these circles.
‫But that's also in the red region.
‫The minimum of the cost function, considering the constraints, is in this corner here where the green
‫area starts.
‫That's where you're Jay means superscript see is and its corresponding Delta Delta zero and Delta Delta
‫One.
‫But is your gradient zero in this corner of here?
‫No, it's not.
‫It's something else.
‫A gradient is like a derivative in one D.
‫It's like a slope, and it's definitely not zero in this corner here.
‫That's why the gradient method does not work when you also want to include constraints in your optimization.
‫In fact, I told you that finding the solution that also respects your constraints by hand is very hard
‫and impractical.
‫You can minimize your cost function subject to constraints by hand when you have one or two independent
‫variables, let's say Delta Delta zero and Delta Delta One, but not when you have more like 20, for
‫example, which was our case control engineers don't do it by hand.
‫Instead, they use programs called solvers.
‫We discussed that soldiers are programs created by very smart people, and the task of solvers is to
‫find that unique combination of independent variables that gives you the smallest possible value for
‫your cost function.
‫Your Jay means superscript.
‫See the green solution that also respects your constraints.
‫So this delta you global superscript see it will be found by a solver.
‫The idea behind solvers is that you give it information about your cost function and your constraints,
‫and in return they give you your solution.
‫Delta, your global superscript see that minimizes your cost function and respects all your constraints.
‫And so in the concourse, I taught you how to transmit information about your cost function and your
‫constraints to solvers correctly so that they would give you the right solutions.
‫There are many solvers out there, some of them are more advanced and some of them are less advanced.
‫The algorithms that they use to perform these optimization tasks are subject on its own.
‫We use kewpie solvers in Python.
‫This is how you imported it.
‫And then from the kewpie service library, there was a function solve on this called kewpie.
‫And so we use it in order to compute our solution Delta you global that respects our constraints.
‫And together with kewpie solvers, we also used another solver type called Sirieix OPPT that's proved
‫to work better in windows and everything that you can see here inside the parentheses.
‫We'll get to that very soon.
‫And so I chose kewpie solvers for two reasons.
‫Firstly, it works just like a very popular quadratic solver in MATLAB called Quad Proc.
‫So if you know how to use kewpie solvers, you also know how to use quite proc.
‫And the second reason is that it's built specifically for optimization problems that have a quadratic
‫positive, definite cost function.
‫Subject to linear constraints.
‫So the cost function is quadratic.
‫It's also positive definite because a double bar is positive definite.
‫And then the constraints there are linear.
‫That's exactly our case.
‫Our cost function is quadratic.
‫H double bar is positive definite and our constraints are linear in the core.
‫As I explained to you that if you have constraints, for example, these ones here, and if you could
‫rewrite them in this form here where this matrix here and this vector here, where they are constant,
‫meaning that you don't have independent variables inside this matrix, nor in this vector.
‫And then also, if this vector here is like this and not something like this where you have Delta Delta
‫zero squared here in Delta Delta One, where for example, this one here where you have Delta Delta
‫Zero and then the square root of Delta Delta One for as long as you have this form here, that's when
‫you have linear constraints.
‫And that's our case.
‫That was our case in the car course.
‫And that's the case here in this drone course as well.
‫And kewpie solvers and quite prog in MATLAB are specifically built for these kind of optimization problems
‫in which you have a quadratic cost function.
‫Your double is positive definite and the constraints are linear.
‫And so here as well, we will use kewpie solvers in the next video.
‫Let's see how we transmitted information about our cost function and our constraints to our solver in
‫order to find our solution that minimizes the cost function and respects all our constraints.
‫Thank you very much.