﻿1
00:00:00,730 --> 00:00:01,660
‫Welcome back.

2
00:00:02,260 --> 00:00:08,560
‫So how did we transmit information about our cost function and our constraints to our saw?

3
00:00:09,100 --> 00:00:19,120
‫Well, both kewpie soldiers and quite brag, they assume that your cost function is in this form, including

4
00:00:19,120 --> 00:00:26,330
‫this one half year, and that your constraints they are in this form in the car course.

5
00:00:26,350 --> 00:00:35,860
‫I showed you a simple example our quadratic cost function in which Delta You Global was a two dimensional

6
00:00:35,860 --> 00:00:36,610
‫vector.

7
00:00:37,240 --> 00:00:44,440
‫This cost function was subject to constraints that looked like this, and then we could rewrite them

8
00:00:45,100 --> 00:00:46,480
‫in this form here.

9
00:00:47,050 --> 00:00:54,550
‫You can see that on the left side of the inequality sign, you have this matrix here and on the right

10
00:00:54,550 --> 00:00:56,380
‫side, you have this vector here.

11
00:00:56,950 --> 00:01:06,070
‫In principle, if your constraints are linear, then this matrix and this vector, they give you all

12
00:01:06,070 --> 00:01:14,530
‫the information you need about your constraints, except that you won't be able to tell if this sign

13
00:01:14,530 --> 00:01:22,510
‫here, whether it's like this or like this, you won't know that if you just look at this matrix and

14
00:01:22,510 --> 00:01:32,680
‫this vector, that's why kewpie solvers and quite POC insist that your constraints have to be in this

15
00:01:32,680 --> 00:01:33,370
‫form.

16
00:01:34,000 --> 00:01:40,270
‫Where this inequality sign points to the left, it's less than or equal to.

17
00:01:40,750 --> 00:01:43,300
‫But in our case, it points to the right.

18
00:01:43,900 --> 00:01:51,460
‫However, we can easily change that if we multiply both sides by minus one.

19
00:01:52,030 --> 00:01:57,940
‫If we do that, then this matrix and this vector, they will be like this.

20
00:01:58,540 --> 00:02:03,340
‫You will have minus signs here distributed among their elements.

21
00:02:03,970 --> 00:02:07,900
‫And then this sign here, it will change its direction.

22
00:02:08,530 --> 00:02:15,940
‫And now you have rewritten your constraints in the right form, and then we will call this Matrix G

23
00:02:16,570 --> 00:02:18,490
‫and this vector H.

24
00:02:19,150 --> 00:02:23,950
‫And that's exactly what Kewpie Solvers and quant project need.

25
00:02:24,280 --> 00:02:31,300
‫And so in order to give all the necessary information to the solver about the cost function, you would

26
00:02:31,300 --> 00:02:38,080
‫need to give it your h double bar matrix and your small F transposed.

27
00:02:38,650 --> 00:02:45,940
‫And in order to give the solver all the information it needs about your constraints, you simply give

28
00:02:45,940 --> 00:02:50,230
‫it your G Matrix and your H vector.

29
00:02:50,830 --> 00:02:59,770
‫Once you give the solver these four things, it will know exactly what kind of cost, function and constraints

30
00:02:59,770 --> 00:03:03,130
‫it is dealing with based on that information.

31
00:03:03,790 --> 00:03:09,460
‫It will return a solution that minimizes your cost function and respects your constraints.

32
00:03:10,120 --> 00:03:19,570
‫Note that in kewpie solvers, we also had to transpose our H vector because both the H vector and small

33
00:03:19,570 --> 00:03:23,920
‫have transposed they had to be role vectors small.

34
00:03:23,920 --> 00:03:26,620
‫If transposed, he's already a role vector.

35
00:03:26,920 --> 00:03:28,780
‫So no need to transpose that.

36
00:03:29,290 --> 00:03:35,950
‫But as you can see, H is a common vector, but q p solvers needs H to be a role vector.

37
00:03:36,580 --> 00:03:41,440
‫So that's why I'm transposing it here in quite prog in MATLAB.

38
00:03:41,710 --> 00:03:42,550
‫It doesn't matter.

39
00:03:43,150 --> 00:03:51,850
‫You can have small f and then this h vector as Coleman vectors, or you can have them as role vectors

40
00:03:51,850 --> 00:03:52,360
‫as well.

41
00:03:52,960 --> 00:03:56,980
‫So quite prog in MATLAB in this sense is a bit more flexible.

42
00:03:57,550 --> 00:04:01,180
‫And so here you can see the syntax for kewpie solvers.

43
00:04:01,450 --> 00:04:03,640
‫You can see that you're using this function here.

44
00:04:03,970 --> 00:04:05,620
‫Sort of underscore kewpie.

45
00:04:06,250 --> 00:04:09,160
‫And then here you can see the syntax for quite proc.

46
00:04:09,730 --> 00:04:12,490
‫As you can see these two elements.

47
00:04:12,490 --> 00:04:21,520
‫They can be either role vectors small if transposed and h transposed or vectors, small F and H.

48
00:04:22,090 --> 00:04:29,270
‫And so in order to find your optimal solution, your delta you global that respects your constraints.

49
00:04:29,890 --> 00:04:31,180
‫That's what you need to do.

50
00:04:31,810 --> 00:04:40,000
‫You need to take your h double bar matrix, your small F transposed your G matrix and your h transpose

51
00:04:40,000 --> 00:04:43,570
‫vector and you need to put them here in this order.

52
00:04:44,140 --> 00:04:52,780
‫And as mentioned before, later, it turned out that in windows, if you put here solver equals Civic's

53
00:04:52,780 --> 00:04:56,140
‫OPPT, then kewpie solvers works better there.

54
00:04:56,740 --> 00:04:59,230
‫So that would be your fifth parameter here.

55
00:04:59,840 --> 00:05:06,170
‫Also note that kewpie solvers gives you the solution as a role vector.

56
00:05:06,740 --> 00:05:10,370
‫Later on, however, I need it to be a common vector.

57
00:05:10,910 --> 00:05:12,980
‫That's why I transpose it here.

58
00:05:13,430 --> 00:05:21,500
‫Quite broke in MATLAB gives me the solution built a global C as a code vector, so that's another small

59
00:05:21,500 --> 00:05:22,670
‫difference between them.

60
00:05:23,210 --> 00:05:30,890
‫But to both of them, you need to give the same h double bar matrix small if transpose g and then each

61
00:05:30,890 --> 00:05:31,640
‫transposed.

62
00:05:32,210 --> 00:05:38,060
‫And so that was the entire game here in the car course, we constrained a lot of things.

63
00:05:38,690 --> 00:05:47,720
‫We can shrink Delta, Delta, Delta, A Delta A and then also small x dot and small.

64
00:05:47,750 --> 00:05:52,130
‫Why don't we kept them between minimum and maximum boundaries?

65
00:05:52,760 --> 00:06:00,230
‫I covered extensively how to do it there, but it all boils down to one thing the game was always to

66
00:06:00,230 --> 00:06:02,930
‫put all your constraints in this form.

67
00:06:03,530 --> 00:06:10,700
‫G times delta you global less than or equal to, and then your h vector.

68
00:06:11,360 --> 00:06:12,500
‫That was the game.

69
00:06:13,040 --> 00:06:21,350
‫It was all about mathematical manipulation in order to, in the end, obtain your G Matrix, which you

70
00:06:21,350 --> 00:06:26,030
‫can see here and your H vector, which you can see here.

71
00:06:26,600 --> 00:06:34,550
‫So all we did was that we played around with our equations and we manipulated them mathematically in

72
00:06:34,550 --> 00:06:43,610
‫such a way so that by the end of the day, your constraints would be formulated in such a way that you

73
00:06:43,610 --> 00:06:47,240
‫will end up having your G Matrix and each vector.

74
00:06:47,780 --> 00:06:55,460
‫And then you simply gave them to your kewpie solvers together with a double bar and small if transposed.

75
00:06:55,820 --> 00:07:03,290
‫And then the solver will give you Delta you global c, which is this one here in green, which minimizes

76
00:07:03,290 --> 00:07:06,770
‫your cost function and respects all your constraints.

77
00:07:07,340 --> 00:07:15,800
‫And so in this course, you have a drone, you have four motors, and these four motors have a minimum

78
00:07:15,800 --> 00:07:20,060
‫and the maximum angular velocity during the flight.

79
00:07:20,180 --> 00:07:29,570
‫Each model needs to have an omega that stays between your omega minimum and omega maximum.

80
00:07:30,170 --> 00:07:34,910
‫You cannot go below omega minimum and above omega maximum.

81
00:07:35,510 --> 00:07:39,140
‫So these are the constraints that we have to respect in this course.

82
00:07:39,800 --> 00:07:44,510
‫However, from the mathematics point of view, the goal is exactly the same.

83
00:07:45,080 --> 00:07:54,620
‫You have to obtain this form G times delta your global less than or equal to and then your H vector,

84
00:07:55,220 --> 00:08:02,750
‫and then you simply take your G Matrix and each vector and you give it to kewpie solvers together with

85
00:08:02,750 --> 00:08:07,820
‫your h double bar matrix and small f transposed.

86
00:08:08,090 --> 00:08:11,270
‫And then the solver will give you a solution.

87
00:08:11,660 --> 00:08:17,360
‫Delta your global c that minimizes your cost function and respects your constraints.

88
00:08:18,020 --> 00:08:24,440
‫We will simply have to do some smart mathematical moves to achieve that, and we will start doing that

89
00:08:24,440 --> 00:08:25,400
‫in the next video.

90
00:08:25,640 --> 00:08:26,510
‫Thank you very much.

