This example is called the facility allocation, and I suppose we are about to allocate some facilities
in a network and each node should have that specific facility or at least one of its neighbors or connected
nodes has that facility.
So we want to find out the minimum required number of nodes to allocate these facilities.
So here you can see a given graph with, um, if I'm right and there are 19, uh, number of nodes and
we want to find out what is the minimum required facilities and which one of them are the best one to
allocate that facilities.
So, um, I define a binary variable called EXI.
And we want to minimize the summation of that.
And for each I x plus assumption of X should be bigger than one, but some of X is done in a specific
way.
The only doges that are connected to AI.
So we are doing the summation over the neighbor notes.
OK, so um, let's have a look at the code.
So here I import the required packages like networks matplotlib and these two are required for plotting
this graph.
So the one random graph is plotted here and then the other packages are, um, important here.
So since we have already imported that one is not needed again.
And also I run this one as well and then I will create the abstract model and is the number of node
which is in the genome of Node I and J are set representing the nodes.
L is the connection Matrix X and Y are by the decision variables and Y is actually the objective function
as well.
X is a binary variable and this constraint is created, as you can see.
Hmm.
Look at this one.
If l i j it has value equal to one then the summation is going to happen.
Um so um you can see that.
And the model also the final one y is bigger than summation of X, I could say equal to that, but that
will give the same results.
So in these type I am feeding the data into the model.
OK, so I run this uh here I do have the edges in the graph, so I create the lines and the lines will
be fed in that dictionary which is going to construct the data for me.
OK.
And it's always Golfweek because it's a linear kind of programming and then we can print that.
It means that the nodes, uh, there are seven nodes required for this specific graph on the the chosen
nodes are like this here.
You can get some information regarding how the model is is feasible or not.
And finally, the final solution is given here.
So you can see that at the selected nodes are a specified, uh, yellow color.
For example, if you look at the node to the neighbor, node has a facility, Node seven, the same
node 14, the same node 12 the same.
So 16 the same and so on and so on.
OK, and that's it for this example.
Thank you very much.