1 00:00:00,580 --> 00:00:07,630 OK, this example is, um, referring to the connected to so suppose we want to start from one given 2 00:00:07,630 --> 00:00:08,190 point. 3 00:00:08,320 --> 00:00:16,120 Let's assume it's a starting point is, uh, point one, and we want to find out how we can travel to 4 00:00:16,120 --> 00:00:19,810 different nodes and come back to the same node. 5 00:00:20,720 --> 00:00:28,250 Without, um, creating a loop or passing any of these notes more than one time. 6 00:00:28,630 --> 00:00:29,000 OK. 7 00:00:30,470 --> 00:00:39,350 Now, in order to model that again, I put a virtual demand on each node and I put that generation here 8 00:00:39,350 --> 00:00:43,940 as well, and then try to supply every demand in the system. 9 00:00:44,630 --> 00:00:45,230 Um. 10 00:00:46,670 --> 00:00:53,870 And the objective function is defined as the UI multiplied by Deji, you multiply by the age are or 11 00:00:53,870 --> 00:01:03,410 the binary variables, and the flow will determine from, um, how the production is flowing to the 12 00:01:03,410 --> 00:01:04,340 demand points. 13 00:01:05,060 --> 00:01:11,780 And also the flow should be less than you are and multiply by a big M, uh, in order to make it connected 14 00:01:11,780 --> 00:01:24,180 to it means that um, at each node, let's call it I the there is only one um flow going out. 15 00:01:24,620 --> 00:01:24,940 Mm hmm. 16 00:01:25,280 --> 00:01:30,920 And also the uh at each node there's only one flow is coming in. 17 00:01:31,490 --> 00:01:32,010 OK. 18 00:01:32,480 --> 00:01:39,410 So in this way we can make sure that, um, we have uh, connected to. 19 00:01:39,570 --> 00:01:45,410 OK, so let's have a look at the code, the import, the required packages. 20 00:01:46,160 --> 00:01:48,560 And also we go forward. 21 00:01:49,280 --> 00:01:55,070 Um, you can see here that, um, the model abstract is created. 22 00:01:56,390 --> 00:02:06,660 And also, um, we do need to specify the number of, um, nodes said I is representing each node and 23 00:02:06,660 --> 00:02:13,820 J is the alias of any of you is, uh, binary variable, uh, defined Overset I and J. 24 00:02:15,810 --> 00:02:25,740 Uh, flow is a real variable, um, it's always good to specify the bounds for your, um, variable 25 00:02:25,740 --> 00:02:28,690 so I can put it down for you. 26 00:02:30,060 --> 00:02:38,700 And I tell your mom that it's a non negative real number is a positive one and variable G is also between 27 00:02:38,700 --> 00:02:39,510 zero and well. 28 00:02:39,510 --> 00:02:46,520 And and also, um, the objective function is, um, not negative real. 29 00:02:47,310 --> 00:02:53,670 So, uh, we can initialize any uh valuable as well. 30 00:02:53,850 --> 00:02:58,980 And also the locations of these, these nodes are randomly allocated. 31 00:02:59,970 --> 00:03:08,760 The second rule is calculating the distances between different nodes for each pair of nodes and parameter, 32 00:03:09,180 --> 00:03:16,620 um, is defined for that and also the node all balance is defined here for only node one, it has a 33 00:03:16,620 --> 00:03:19,890 G, but the rest of them are only pillow's. 34 00:03:21,690 --> 00:03:28,860 Um, the next rule is telling us and flow is less than you multiply by and a big number. 35 00:03:29,130 --> 00:03:32,100 I chose that big number equal to number of nodes. 36 00:03:33,340 --> 00:03:36,130 So this constraint is defined over in Jay. 37 00:03:38,670 --> 00:03:44,550 Um, it's definitely better if we, um. 38 00:03:46,300 --> 00:03:56,950 Define this rule in a way that it doesn't and it it's not calculated for the cases where I and J are, 39 00:03:57,310 --> 00:03:59,440 um, equal to each other. 40 00:03:59,450 --> 00:04:03,920 So let me modify this code for you. 41 00:04:03,940 --> 00:04:05,140 OK, so I put her. 42 00:04:06,020 --> 00:04:20,420 If yeah, OK, so here you can see that if, um, I is not equal to Jipé, then return this, OK, or 43 00:04:21,130 --> 00:04:29,480 else, uh, else return to what? 44 00:04:30,020 --> 00:04:34,640 I have to skip that constraint in case that, um. 45 00:04:36,580 --> 00:04:40,970 Um, these two are equal to each other, so, um. 46 00:04:42,990 --> 00:04:46,050 Consecrates dance. 47 00:04:48,230 --> 00:04:48,620 OK. 48 00:04:48,840 --> 00:04:50,330 I hope it's correct. 49 00:04:51,360 --> 00:04:56,760 OK, so I will check it for you next and then, um. 50 00:04:58,190 --> 00:05:00,710 Let's have a look at the other code. 51 00:05:01,010 --> 00:05:07,640 The other constraint, this constraint is telling us that, um, summation or, um, summation of UIGEA 52 00:05:07,670 --> 00:05:10,330 over J should be one. 53 00:05:10,340 --> 00:05:14,180 It means that the outgoing pages should be only one. 54 00:05:15,050 --> 00:05:18,950 And also, this one is telling umpire more to say. 55 00:05:19,340 --> 00:05:21,500 And the incoming, um. 56 00:05:22,390 --> 00:05:27,610 As to each node should be only one and the objective function is. 57 00:05:28,490 --> 00:05:35,000 And doing this summation where you are, you are seeing multiply by D.R.C. and so on. 58 00:05:35,030 --> 00:05:38,570 OK, so let me run the code. 59 00:05:39,030 --> 00:05:40,180 Uh, OK. 60 00:05:40,190 --> 00:05:42,670 And this one, OK. 61 00:05:42,830 --> 00:05:44,480 It is also correct. 62 00:05:45,260 --> 00:05:49,890 And, uh, the software is chosen by Rhonda. 63 00:05:50,690 --> 00:05:51,440 Mm hmm. 64 00:05:52,450 --> 00:05:54,370 It says constraint has no escape. 65 00:05:54,400 --> 00:06:03,440 Maybe I have made a mistake the way I approach to skip a skip should as should be capitalized on. 66 00:06:03,730 --> 00:06:04,300 But no. 67 00:06:05,980 --> 00:06:11,520 So I run into again, um, check the result. 68 00:06:16,930 --> 00:06:22,320 So I'm waiting for the model to, um, give me the solution. 69 00:06:22,380 --> 00:06:33,160 OK, so here you can see we have a connected to OK, so as you can see, all the nodes are connected 70 00:06:33,160 --> 00:06:37,230 to each other and the degree of each node is two. 71 00:06:37,480 --> 00:06:40,260 So you could write it down in a different way. 72 00:06:40,570 --> 00:06:48,460 So instead of writing it as two separate concentrate like uh well let's see three and C four, you could 73 00:06:48,460 --> 00:06:54,160 say degree of each node should be exactly equal to two. 74 00:06:54,580 --> 00:06:57,230 That should give you the same kind of result. 75 00:06:58,060 --> 00:06:58,960 Thank you very much.