﻿1
00:00:00,720 --> 00:00:09,810
‫But now we discussed that when we wanted to find a solution that minimizes the cost function.

2
00:00:10,440 --> 00:00:17,820
‫And at the same time, we take constraints into account, then this gradient method here, it was not

3
00:00:17,820 --> 00:00:18,870
‫suitable anymore.

4
00:00:19,440 --> 00:00:21,420
‫And the reason for that was very simple.

5
00:00:21,990 --> 00:00:27,360
‫The gradient method makes the gradient of the cost function zero.

6
00:00:27,630 --> 00:00:31,350
‫That's why you have here this condition here.

7
00:00:31,950 --> 00:00:35,070
‫And from that, you compute your solution.

8
00:00:35,790 --> 00:00:36,930
‫Delta, you global.

9
00:00:37,530 --> 00:00:45,390
‫But if you look at this mini example here, then you can clearly see that the only place where the gradient

10
00:00:45,390 --> 00:00:50,690
‫is zero is this place here in the center of these circles.

11
00:00:51,180 --> 00:00:53,040
‫But that's also in the red region.

12
00:00:53,730 --> 00:01:00,420
‫The minimum of the cost function, considering the constraints, is in this corner here where the green

13
00:01:00,420 --> 00:01:01,410
‫area starts.

14
00:01:02,130 --> 00:01:09,690
‫That's where you're Jay means superscript see is and its corresponding Delta Delta zero and Delta Delta

15
00:01:09,690 --> 00:01:10,110
‫One.

16
00:01:10,680 --> 00:01:13,620
‫But is your gradient zero in this corner of here?

17
00:01:14,250 --> 00:01:15,110
‫No, it's not.

18
00:01:15,120 --> 00:01:16,080
‫It's something else.

19
00:01:16,650 --> 00:01:19,260
‫A gradient is like a derivative in one D.

20
00:01:19,530 --> 00:01:24,540
‫It's like a slope, and it's definitely not zero in this corner here.

21
00:01:25,170 --> 00:01:31,950
‫That's why the gradient method does not work when you also want to include constraints in your optimization.

22
00:01:32,400 --> 00:01:39,630
‫In fact, I told you that finding the solution that also respects your constraints by hand is very hard

23
00:01:39,900 --> 00:01:41,070
‫and impractical.

24
00:01:41,700 --> 00:01:47,760
‫You can minimize your cost function subject to constraints by hand when you have one or two independent

25
00:01:47,760 --> 00:01:56,010
‫variables, let's say Delta Delta zero and Delta Delta One, but not when you have more like 20, for

26
00:01:56,010 --> 00:02:01,320
‫example, which was our case control engineers don't do it by hand.

27
00:02:01,860 --> 00:02:05,790
‫Instead, they use programs called solvers.

28
00:02:06,420 --> 00:02:14,580
‫We discussed that soldiers are programs created by very smart people, and the task of solvers is to

29
00:02:14,580 --> 00:02:23,310
‫find that unique combination of independent variables that gives you the smallest possible value for

30
00:02:23,310 --> 00:02:24,330
‫your cost function.

31
00:02:24,960 --> 00:02:26,400
‫Your Jay means superscript.

32
00:02:26,400 --> 00:02:31,110
‫See the green solution that also respects your constraints.

33
00:02:31,740 --> 00:02:37,350
‫So this delta you global superscript see it will be found by a solver.

34
00:02:37,950 --> 00:02:46,830
‫The idea behind solvers is that you give it information about your cost function and your constraints,

35
00:02:47,460 --> 00:02:50,940
‫and in return they give you your solution.

36
00:02:51,360 --> 00:02:58,890
‫Delta, your global superscript see that minimizes your cost function and respects all your constraints.

37
00:02:59,520 --> 00:03:06,600
‫And so in the concourse, I taught you how to transmit information about your cost function and your

38
00:03:06,600 --> 00:03:12,420
‫constraints to solvers correctly so that they would give you the right solutions.

39
00:03:13,170 --> 00:03:19,620
‫There are many solvers out there, some of them are more advanced and some of them are less advanced.

40
00:03:20,190 --> 00:03:26,820
‫The algorithms that they use to perform these optimization tasks are subject on its own.

41
00:03:27,420 --> 00:03:30,510
‫We use kewpie solvers in Python.

42
00:03:31,230 --> 00:03:32,790
‫This is how you imported it.

43
00:03:33,390 --> 00:03:39,240
‫And then from the kewpie service library, there was a function solve on this called kewpie.

44
00:03:39,870 --> 00:03:46,800
‫And so we use it in order to compute our solution Delta you global that respects our constraints.

45
00:03:47,400 --> 00:03:56,370
‫And together with kewpie solvers, we also used another solver type called Sirieix OPPT that's proved

46
00:03:56,370 --> 00:04:01,830
‫to work better in windows and everything that you can see here inside the parentheses.

47
00:04:02,310 --> 00:04:03,780
‫We'll get to that very soon.

48
00:04:04,380 --> 00:04:08,490
‫And so I chose kewpie solvers for two reasons.

49
00:04:09,030 --> 00:04:16,680
‫Firstly, it works just like a very popular quadratic solver in MATLAB called Quad Proc.

50
00:04:17,280 --> 00:04:21,720
‫So if you know how to use kewpie solvers, you also know how to use quite proc.

51
00:04:22,350 --> 00:04:29,820
‫And the second reason is that it's built specifically for optimization problems that have a quadratic

52
00:04:29,820 --> 00:04:31,950
‫positive, definite cost function.

53
00:04:32,280 --> 00:04:34,200
‫Subject to linear constraints.

54
00:04:34,770 --> 00:04:37,950
‫So the cost function is quadratic.

55
00:04:38,580 --> 00:04:44,490
‫It's also positive definite because a double bar is positive definite.

56
00:04:45,090 --> 00:04:48,000
‫And then the constraints there are linear.

57
00:04:48,570 --> 00:04:50,340
‫That's exactly our case.

58
00:04:51,000 --> 00:04:53,070
‫Our cost function is quadratic.

59
00:04:53,730 --> 00:04:59,340
‫H double bar is positive definite and our constraints are linear in the core.

60
00:04:59,650 --> 00:05:08,350
‫As I explained to you that if you have constraints, for example, these ones here, and if you could

61
00:05:08,350 --> 00:05:18,100
‫rewrite them in this form here where this matrix here and this vector here, where they are constant,

62
00:05:18,640 --> 00:05:24,790
‫meaning that you don't have independent variables inside this matrix, nor in this vector.

63
00:05:25,390 --> 00:05:32,710
‫And then also, if this vector here is like this and not something like this where you have Delta Delta

64
00:05:32,710 --> 00:05:39,580
‫zero squared here in Delta Delta One, where for example, this one here where you have Delta Delta

65
00:05:39,580 --> 00:05:47,440
‫Zero and then the square root of Delta Delta One for as long as you have this form here, that's when

66
00:05:47,440 --> 00:05:49,600
‫you have linear constraints.

67
00:05:49,870 --> 00:05:51,310
‫And that's our case.

68
00:05:52,000 --> 00:05:54,310
‫That was our case in the car course.

69
00:05:54,610 --> 00:05:58,090
‫And that's the case here in this drone course as well.

70
00:05:58,630 --> 00:06:07,360
‫And kewpie solvers and quite prog in MATLAB are specifically built for these kind of optimization problems

71
00:06:07,990 --> 00:06:10,450
‫in which you have a quadratic cost function.

72
00:06:10,850 --> 00:06:15,580
‫Your double is positive definite and the constraints are linear.

73
00:06:16,120 --> 00:06:20,800
‫And so here as well, we will use kewpie solvers in the next video.

74
00:06:20,980 --> 00:06:29,680
‫Let's see how we transmitted information about our cost function and our constraints to our solver in

75
00:06:29,680 --> 00:06:36,580
‫order to find our solution that minimizes the cost function and respects all our constraints.

76
00:06:37,180 --> 00:06:38,080
‫Thank you very much.

