‫Welcome back.
‫So how did we transmit information about our cost function and our constraints to our saw?
‫Well, both kewpie soldiers and quite brag, they assume that your cost function is in this form, including
‫this one half year, and that your constraints they are in this form in the car course.
‫I showed you a simple example our quadratic cost function in which Delta You Global was a two dimensional
‫vector.
‫This cost function was subject to constraints that looked like this, and then we could rewrite them
‫in this form here.
‫You can see that on the left side of the inequality sign, you have this matrix here and on the right
‫side, you have this vector here.
‫In principle, if your constraints are linear, then this matrix and this vector, they give you all
‫the information you need about your constraints, except that you won't be able to tell if this sign
‫here, whether it's like this or like this, you won't know that if you just look at this matrix and
‫this vector, that's why kewpie solvers and quite POC insist that your constraints have to be in this
‫form.
‫Where this inequality sign points to the left, it's less than or equal to.
‫But in our case, it points to the right.
‫However, we can easily change that if we multiply both sides by minus one.
‫If we do that, then this matrix and this vector, they will be like this.
‫You will have minus signs here distributed among their elements.
‫And then this sign here, it will change its direction.
‫And now you have rewritten your constraints in the right form, and then we will call this Matrix G
‫and this vector H.
‫And that's exactly what Kewpie Solvers and quant project need.
‫And so in order to give all the necessary information to the solver about the cost function, you would
‫need to give it your h double bar matrix and your small F transposed.
‫And in order to give the solver all the information it needs about your constraints, you simply give
‫it your G Matrix and your H vector.
‫Once you give the solver these four things, it will know exactly what kind of cost, function and constraints
‫it is dealing with based on that information.
‫It will return a solution that minimizes your cost function and respects your constraints.
‫Note that in kewpie solvers, we also had to transpose our H vector because both the H vector and small
‫have transposed they had to be role vectors small.
‫If transposed, he's already a role vector.
‫So no need to transpose that.
‫But as you can see, H is a common vector, but q p solvers needs H to be a role vector.
‫So that's why I'm transposing it here in quite prog in MATLAB.
‫It doesn't matter.
‫You can have small f and then this h vector as Coleman vectors, or you can have them as role vectors
‫as well.
‫So quite prog in MATLAB in this sense is a bit more flexible.
‫And so here you can see the syntax for kewpie solvers.
‫You can see that you're using this function here.
‫Sort of underscore kewpie.
‫And then here you can see the syntax for quite proc.
‫As you can see these two elements.
‫They can be either role vectors small if transposed and h transposed or vectors, small F and H.
‫And so in order to find your optimal solution, your delta you global that respects your constraints.
‫That's what you need to do.
‫You need to take your h double bar matrix, your small F transposed your G matrix and your h transpose
‫vector and you need to put them here in this order.
‫And as mentioned before, later, it turned out that in windows, if you put here solver equals Civic's
‫OPPT, then kewpie solvers works better there.
‫So that would be your fifth parameter here.
‫Also note that kewpie solvers gives you the solution as a role vector.
‫Later on, however, I need it to be a common vector.
‫That's why I transpose it here.
‫Quite broke in MATLAB gives me the solution built a global C as a code vector, so that's another small
‫difference between them.
‫But to both of them, you need to give the same h double bar matrix small if transpose g and then each
‫transposed.
‫And so that was the entire game here in the car course, we constrained a lot of things.
‫We can shrink Delta, Delta, Delta, A Delta A and then also small x dot and small.
‫Why don't we kept them between minimum and maximum boundaries?
‫I covered extensively how to do it there, but it all boils down to one thing the game was always to
‫put all your constraints in this form.
‫G times delta you global less than or equal to, and then your h vector.
‫That was the game.
‫It was all about mathematical manipulation in order to, in the end, obtain your G Matrix, which you
‫can see here and your H vector, which you can see here.
‫So all we did was that we played around with our equations and we manipulated them mathematically in
‫such a way so that by the end of the day, your constraints would be formulated in such a way that you
‫will end up having your G Matrix and each vector.
‫And then you simply gave them to your kewpie solvers together with a double bar and small if transposed.
‫And then the solver will give you Delta you global c, which is this one here in green, which minimizes
‫your cost function and respects all your constraints.
‫And so in this course, you have a drone, you have four motors, and these four motors have a minimum
‫and the maximum angular velocity during the flight.
‫Each model needs to have an omega that stays between your omega minimum and omega maximum.
‫You cannot go below omega minimum and above omega maximum.
‫So these are the constraints that we have to respect in this course.
‫However, from the mathematics point of view, the goal is exactly the same.
‫You have to obtain this form G times delta your global less than or equal to and then your H vector,
‫and then you simply take your G Matrix and each vector and you give it to kewpie solvers together with
‫your h double bar matrix and small f transposed.
‫And then the solver will give you a solution.
‫Delta your global c that minimizes your cost function and respects your constraints.
‫We will simply have to do some smart mathematical moves to achieve that, and we will start doing that
‫in the next video.
‫Thank you very much.