﻿1
00:00:00,730 --> 00:00:05,500
‫But now this has been an easy and unrealistic example.

2
00:00:06,100 --> 00:00:12,040
‫In reality, our cost function was much larger and we had many more constraints.

3
00:00:12,700 --> 00:00:19,840
‫The standard form of our cost function was J equals one half delta.

4
00:00:19,840 --> 00:00:21,390
‫Your global transposed.

5
00:00:22,000 --> 00:00:30,430
‫Then this is your h double bar matrix delta, your global plus small f transposed times, delta, you

6
00:00:30,430 --> 00:00:30,940
‫global.

7
00:00:31,510 --> 00:00:41,440
‫And this small f transposed that was essentially this one here in the concourse, our horizon period

8
00:00:41,440 --> 00:00:42,250
‫equals 10.

9
00:00:42,850 --> 00:00:46,450
‫But you could have also made it bigger, like 15 or 20, perhaps.

10
00:00:47,110 --> 00:00:49,870
‫But let's stick with 10 in that case.

11
00:00:50,500 --> 00:00:53,890
‫How many dimensions would you have in your cost function?

12
00:00:54,460 --> 00:01:00,640
‫Well, Delta U equals Delta Delta and Delta A..

13
00:01:01,270 --> 00:01:03,310
‫And your horizon equals 10.

14
00:01:03,940 --> 00:01:07,930
‫So your delta, your global, would equal all that.

15
00:01:08,530 --> 00:01:15,700
‫So in total, you have 20 independent variables, so you have a 20 dimensional domain.

16
00:01:16,330 --> 00:01:22,750
‫Of course, this is not something you can visualize, but I recommended you to think about it differently.

17
00:01:23,350 --> 00:01:33,430
‫In terms of a table with 20 columns, each column is reserved for one specific independent variable,

18
00:01:34,000 --> 00:01:39,370
‫and that variable could range from minus infinity to plus infinity.

19
00:01:39,940 --> 00:01:48,160
‫And so instead of visualizing something, in my opinion, a better way is to think about it like this.

20
00:01:48,820 --> 00:01:57,370
‫What's the unique combination of all the variables here that would give you the smallest j possible

21
00:01:58,000 --> 00:02:03,010
‫out of all the possible values that each variable can have?

22
00:02:03,640 --> 00:02:12,340
‫There is one unique combination of values that would give you the smallest cost function possible.

23
00:02:12,910 --> 00:02:16,870
‫Any other combination here would give you a bigger j.

24
00:02:17,500 --> 00:02:21,760
‫That's essentially minimization of the cost function.

25
00:02:22,360 --> 00:02:27,380
‫And so your solution delta you global, which is in red here.

26
00:02:28,090 --> 00:02:37,000
‫That's that unique combination that gives you the smallest j possible and then the red case.

27
00:02:37,660 --> 00:02:40,660
‫It does not take constraints into account.

28
00:02:41,170 --> 00:02:46,300
‫However, the green case does take the constraints into consideration.

29
00:02:46,930 --> 00:02:56,230
‫So in green, this unique combination, it gives you the smallest cost function possible while respecting

30
00:02:56,230 --> 00:02:58,150
‫all your constraints at the same time.

31
00:02:58,630 --> 00:03:06,460
‫The red solution might give you a smaller j, but it's possible that it violates some constraints.

32
00:03:07,120 --> 00:03:13,960
‫And now, if we want to constrain our Delta, Delta and Delta values, then we did it like this.

33
00:03:14,590 --> 00:03:20,200
‫We constrained our Delta Delta between Delta Delta Minimum and Delta Delta Maximum.

34
00:03:20,830 --> 00:03:28,300
‫And in the same way, we constrained our Delta A between Delta Minimum and Delta a maximum.

35
00:03:28,840 --> 00:03:31,720
‫So we had a system of inequality constraints.

36
00:03:32,320 --> 00:03:40,070
‫We determined some kind of minimum and maximum bounds, and we wanted to keep our delta.

37
00:03:40,090 --> 00:03:44,710
‫Delta and Delta A between those bounds.

38
00:03:45,340 --> 00:03:53,110
‫But since your horizon period equals 10 and since in the cost function, you had 20 independent variables,

39
00:03:53,830 --> 00:03:56,830
‫then you had to have these constraints for all of them.

40
00:03:57,430 --> 00:04:02,290
‫And so you had here Delta Delta zero in Delta A0.

41
00:04:02,980 --> 00:04:14,310
‫Then you had those constraints for Delta Delta one end Delta A1 up until Delta Delta nine in Delta eight

42
00:04:14,320 --> 00:04:14,890
‫nine.

43
00:04:15,520 --> 00:04:17,950
‫So as you can see, we had a lot of constraints.

44
00:04:18,610 --> 00:04:25,330
‫When you don't have constraints, then finding the solution that minimizes your cost function was easy.

45
00:04:25,900 --> 00:04:28,000
‫We used the gradient method for that.

46
00:04:28,540 --> 00:04:33,550
‫We took the gradient of our cost function and we made it equal to zero.

47
00:04:34,060 --> 00:04:36,010
‫So this is your cost function here.

48
00:04:36,640 --> 00:04:40,930
‫And so that means that this one here, it looks like this.

49
00:04:41,650 --> 00:04:46,120
‫This is the gradient of the cost function and I make it equal to zero.

50
00:04:46,690 --> 00:04:50,180
‫And then from that, you could make some rearrangements.

51
00:04:50,860 --> 00:04:54,370
‫You would have a double bar times delta.

52
00:04:54,370 --> 00:05:00,160
‫You global equals minus F and that would give you Delta.

53
00:05:00,230 --> 00:05:07,790
‫Are your global equals minus h double bar, inverse times small F?

54
00:05:08,360 --> 00:05:09,740
‫That was your solution.

55
00:05:09,740 --> 00:05:17,120
‫Without the constraints, we could use the gradient method because the gradient means the change of

56
00:05:17,120 --> 00:05:23,060
‫the cost function with respect to all of its independent variables.

57
00:05:23,720 --> 00:05:30,710
‫When you're dealing with a quadratic cost function whose h double bar matrix is positive, definite

58
00:05:31,310 --> 00:05:41,510
‫and when all your NPC weights are positive, so CU S and R they all have to be positive, then the gradient

59
00:05:41,510 --> 00:05:43,310
‫of J equals zero.

60
00:05:43,910 --> 00:05:47,390
‫Where your Minion point is in the concourse.

61
00:05:47,630 --> 00:05:56,720
‫I treated the concept of positive definite matrices extensively, but in a nutshell you saw that if

62
00:05:56,720 --> 00:06:05,030
‫h double bar is quadratic and positive, definite with positive NPC weights, then your cost function

63
00:06:05,030 --> 00:06:05,950
‫looked like this.

64
00:06:06,410 --> 00:06:09,170
‫It only had one global minimum point.

65
00:06:09,860 --> 00:06:12,860
‫That's where your gradient of J equals zero.

66
00:06:13,460 --> 00:06:21,500
‫Your cost function j could range from this j midpoint up until plus infinity.

67
00:06:22,100 --> 00:06:29,060
‫So mathematically, you could write that J belongs to J Min and Plus Infinity.

68
00:06:29,720 --> 00:06:37,550
‫There was no way that this cost function could have a smaller value than this J Min value, but when

69
00:06:37,550 --> 00:06:43,010
‫your h double bar was not positive definite, then your cost function looked like this.

70
00:06:43,670 --> 00:06:46,040
‫You see that you don't have a minimum point there.

71
00:06:46,610 --> 00:06:52,190
‫Your cost function would go from minus infinity to plus infinity.

72
00:06:52,670 --> 00:06:59,570
‫So your j it would belong to this interval here from minus infinity to plus infinity.

73
00:07:00,170 --> 00:07:06,560
‫You did have a place where your gradient was zero, but that was not your minimal point.

74
00:07:07,100 --> 00:07:14,120
‫We called it cell point, and the same logic would apply in higher dimensions to in our car and run

75
00:07:14,120 --> 00:07:14,840
‫courses.

76
00:07:15,530 --> 00:07:20,340
‫The H double bar was quadratic and positive, definite.

77
00:07:20,960 --> 00:07:22,700
‫Also, it was symmetric.

78
00:07:22,850 --> 00:07:30,230
‫As we discussed in the very first car course, a symmetric matrix is like this one in blue.

79
00:07:30,860 --> 00:07:34,760
‫The side elements are mirrored around the diagonal.

80
00:07:34,790 --> 00:07:39,440
‫You see, you have four, four here, five, five here, six six here.

81
00:07:40,100 --> 00:07:41,570
‫That's a symmetric matrix.

82
00:07:42,260 --> 00:07:50,390
‫The cool thing about symmetric matrices was that they were equal to their transpose, so your h double

83
00:07:50,390 --> 00:07:53,930
‫bar transpose equals your h double bar.

84
00:07:54,560 --> 00:08:01,610
‫That fact allowed us to have this form for the cost function gradient.

85
00:08:02,240 --> 00:08:12,020
‫So in conclusion, our cost function was quadratic positive, definite symmetric and the NPC weights

86
00:08:12,020 --> 00:08:13,760
‫were positive.

87
00:08:14,360 --> 00:08:18,410
‫That's why we could use this gradient method here.

