1 00:00:00,060 --> 00:00:03,280 This example is called Hostile Brothers in Rectangle. 2 00:00:03,750 --> 00:00:11,850 Suppose we have and brothers and we want to find the location of them in a rectangle in a way that the 3 00:00:12,060 --> 00:00:16,610 minimum distance between each pair of brothers is maximum. 4 00:00:16,920 --> 00:00:22,020 OK, so the input parameters of this model is a dimension of the rectangle. 5 00:00:23,400 --> 00:00:28,260 And for simplicity, we can assume that it has a square shape. 6 00:00:28,500 --> 00:00:28,800 Hmm. 7 00:00:29,340 --> 00:00:30,600 So, um. 8 00:00:31,630 --> 00:00:39,250 Then we need to find out the location of each brother so EXI and why of each brother should be found. 9 00:00:40,310 --> 00:00:46,150 And so in order to calculate the distance between each pair of brothers for every injury, we have to 10 00:00:46,150 --> 00:00:55,030 calculate this expression X minus X squared plus and minus YJ Square should be bigger than our square 11 00:00:55,930 --> 00:01:06,400 and also um, the X should be within zero and one which is the dimension of that rectangle and Y is 12 00:01:06,400 --> 00:01:07,610 between zero and one. 13 00:01:07,630 --> 00:01:11,750 OK, so why is moving from here to here on X is moved from here to here. 14 00:01:11,820 --> 00:01:21,880 OK, so in order to find out what is the optimal decision for this, um, problem, we need to have 15 00:01:21,880 --> 00:01:23,920 a look at the Python code. 16 00:01:24,280 --> 00:01:29,440 So first of all, as usual, we have to import the required libraries as we did it here. 17 00:01:30,290 --> 00:01:38,650 We have defined it as an abstract model and I have defined the number of, uh, borders as a parameter 18 00:01:38,650 --> 00:01:40,990 and made it mutable because we can. 19 00:01:41,940 --> 00:01:54,450 Be able to change it and update it and also, um, we are trying to find out how we define a set of 20 00:01:54,450 --> 00:01:57,630 I have it an exact number of brothers. 21 00:01:58,170 --> 00:02:04,440 So Range sets one and model and J is the alias of the previous sets. 22 00:02:04,440 --> 00:02:09,030 I l is the dimension of the board, OK. 23 00:02:09,360 --> 00:02:15,230 And I define this um by function and later. 24 00:02:15,480 --> 00:02:26,670 OK, so um there are three variables in this model X, Y and R so X is defined over I, Y is defined 25 00:02:26,670 --> 00:02:33,840 over ie the bounds of both are between zero and model L. And they are defined within an non-negative 26 00:02:33,840 --> 00:02:43,590 real's and we initialize them using this function in it felt so uh uniform number between zero and one 27 00:02:43,590 --> 00:02:46,920 will be assigned to each number, uh variable. 28 00:02:47,790 --> 00:02:53,160 And then we have to calculate the distance between each pair of uh, variables. 29 00:02:53,190 --> 00:03:01,020 OK, so in order to do that we have to create a constraint like see model that C is constraint. 30 00:03:01,260 --> 00:03:09,780 It is defined over the model ion model J uh, following the rules C one rule, the C1 rule is defined, 31 00:03:09,960 --> 00:03:11,910 um, for different situations. 32 00:03:12,390 --> 00:03:21,060 If we already know that the distance should be defined for different brothers, not themselves. 33 00:03:21,100 --> 00:03:29,370 OK, so it means that if I n g is not equal to each other, then it means that the distance will be 34 00:03:29,370 --> 00:03:38,710 calculated that uh using model dot x are in the minus model S and model X squared plus model. 35 00:03:38,730 --> 00:03:47,460 That's why I minus model dot y j squared bigger than model that are square OK, that are is the minimum 36 00:03:47,460 --> 00:03:48,270 distance between them. 37 00:03:48,720 --> 00:03:52,780 And um if they are equal to each other then we have to accept a constraint. 38 00:03:52,870 --> 00:03:56,670 OK, and the next line is describing the. 39 00:03:57,640 --> 00:04:05,170 Uh, objective function, which is the given by expression equal to model, are we are telling Palomo 40 00:04:05,170 --> 00:04:10,640 that the objective function is model R and the sense of optimization is maximization. 41 00:04:10,660 --> 00:04:19,240 We want to maximize the minimum distance between each pair and we choose the, um, solver as the EPUB. 42 00:04:19,240 --> 00:04:27,250 Since it's non-linear programming, we follow the iPod and then we specify the model that NP we could 43 00:04:27,250 --> 00:04:30,310 put this, um, data in it. 44 00:04:30,310 --> 00:04:31,060 That's fine. 45 00:04:31,300 --> 00:04:32,680 And call that while. 46 00:04:34,640 --> 00:04:42,680 And the next step is creating the instance model, that creating stance will will feed the data into 47 00:04:42,680 --> 00:04:52,140 the model and create the constraints and everything, then we can ask, uh, to solve the model solved 48 00:04:52,140 --> 00:04:55,820 that a specific instance for us which will be done. 49 00:04:56,000 --> 00:04:57,830 Let me run the code for you. 50 00:04:57,890 --> 00:04:59,630 OK, so first stop. 51 00:05:00,200 --> 00:05:01,280 Second tab. 52 00:05:02,200 --> 00:05:03,130 The top. 53 00:05:04,100 --> 00:05:10,880 And, um, this one this one will, uh, graphically show you what's happening. 54 00:05:14,190 --> 00:05:25,080 OK, so if you want to test it for another set of numbers, for example, let's say twenty five brothers, 55 00:05:25,320 --> 00:05:34,370 I rerun the section and the model will be run for a bigger number of brothers. 56 00:05:34,380 --> 00:05:38,460 OK, you can still increase the number, let's say, 40 brothers. 57 00:05:39,690 --> 00:05:48,210 So to see what's going on so it takes more time and then it's for 40 brothers. 58 00:05:48,600 --> 00:05:53,310 OK, thank you very much for paying attention to this example.