This example is referring to a spanning three with degree constraint, so, um, as you might have seen
in the example of expanding tree, um, we define some, um, virtual demand for each node and then
try to find out how we can create a graph, which is a tree.
A connected one, but without any kind of loop.
So, um, now we want to find out more characteristics of the graph and for some additional constraints.
So if you look at this graph, which is a tree, um, we can easily calculate the degree of each node.
For example, um, the degree of Node six is one because it has only one edge connected to it.
Uh, degree of No.
One is two.
It has two edges connected to this note and the degree of node nine is three and so on and so on.
OK, so maybe in some cases we want to uh, limit the degree of, uh, each node.
So in order to do so, um, we have to, um, limit the number of edges that can be connected to a graph
to to each node so we can write down for each eye.
We can write down such an equation or constrain UIC.
Plus, um, you see I should be less than end degree and the summation should be done over all the C
except I uh.
So we add this constraint to the formulation and see the results.
So you can see here, if I limit the degree of each node to for example, two, then the same connection,
the same dots are connected to each other in a different way.
So here you can see that the maximum degree is two.
What how should I write it down?
Um, let me show you the.
And page code.
OK, so, um, here you can see the Python code and initially I import every required package and then
I define the required variable.
So the variables are the same as the example, um, minimum spanning tree.
And, um, but we have to add, uh, new parameter called maximum degree.
So a max degree is apparently is immutable, Pouncer, you can specify a default value for a.
Or not.
And also, um, the variables are exactly the same, then I create some random locations for those dots.
Hmm.
And, um, calculate the distance between each pair of them.
OK.
Then, um.
There are some constraints for this model, and as we discussed before in the previous example, and
each node, um, should follow the balanced rule.
So how much we have generated is equal to how much we are consuming or exporting.
So here only for node one, we have a production or generation, and at each node we have some amount
of demand.
Let's say I divide it by.
And all of that in our region, especially something else or a constant number or whatever you want,
and then how much exporting, how much importing from the other nodes do the summation and, uh, this
constraint will create the balance at all.
And then and the other constraint is telling us that if, um, no, it is connected to each other with
two nodes are connected to each other, then a flow can exist between those two nodes.
And these, um, and this one is, uh, telling us.
The maximum degree of each note how should be specified.
OK, so model UIC plus model, you see, I, um, summation oversee but for some specifics, not all
the CS if I is different with C because we are not connected to each other, to ourselves and it should
be less than one degree.
And the objective function is as is the same as before.
You multiply by the summation overall I can see.
Mm hmm.
Um, so here, let me give you a point here.
So here you can see that.
And in the if you write down this, uh, the code in this way, what will happen and it will put the
RNC for every possible combination of RNC or in I and C J.
OK, and.
This way will also create some additional you when the RNC are also equal to each other.
So to avoid that situation and I add an extra kind of, um.
Specification.
Yeah, so here, um, if R and C are, uh, exactly equal to each other, then.
So if RNC are not equal to each other, then, um, the summation should take place.
Otherwise it will create some situation that, um, you, um, are an R for example, you know, you
want and want you to unter.
So to avoid that we have to add this extra constraint.
OK.
Um, let's I should write off.
OK, so, uh, this will create this will finish the definition of the constraints and we choose the
solver as the GOP and we can specify the and and max degree.
So let's, um, run the code with each other.
So I run the first tab.
OK.
It is run successfully and also the second tab is done.
OK.
And the third type um is uh specify any equal to ten and max degrees for.
So it takes time to finish to solve the statement, because, um, for example, if you have 10, um,
nodes, then ten multiplied by nine is is telling you how many binary variables it will be.
Nineteen, ninety and, uh, binary variables true to the power, 90 will be, uh, the number of combination
that you might have.
OK, so and finally I run this, you can get this graph you can see here.
So initially, uh, as you can see here, the degree of the nose is the maximum degrees, three, for
example.
Here is three.
Uh, but if you add that constraint and consider that, then it means that, um, a new, uh, tree
will be created and, uh, you can see it here.
So I want the final time for you.
You can do it as well.
So, um, so this way it has to, uh, recalculate how they are.
They should be connected to each other.
So you can see here that this same location of the nodes, but different way of connecting them together.
OK.
Thank you very much.