OK, this example is called the maximum flow, and we want to find out if how much is the maximum flow
we can have between two specific notes in a graph.
For example, if the amount of product or power or whatever is entering the node zero, um, and we
are expecting that there is no loss as is happening in the system.
I repeat, is not an electrical engineering kind of system, but it's a general form.
And we want to know if we enter G to the node zero, is it possible to take out G from Node six or any
other node?
Without violating the capacity of these lines or these routes.
OK, so in order to do so, we have to write down the balanced equation for every node.
So as you can see, only one node has generation, which is not zero.
For example, in this example, and the rest of them has to have them.
They have no generation.
But and I know demand and also only one node has demand, which is node six.
OK, so and it's equal to G.
So we want to know, um, how can we, uh, formulate it as a, um, optimization problem in Payam?
OK, so here you can see that we import the required packages.
Hmm.
And then I create the model abstract model and.
So this is the set.
It is initialized with the range between zero and seven, so it will create a zero one, two, three,
four, five and six G is the radius of that.
Flo is telling us how much flow is happening between I and J.
It's a positive number and also the capacity of each route is also specified by parameter ACAP.
She is a valuable telling us how much we can inject.
To one note, an extract from the other note, an objective function is, um, defined as G OK.
So, uh.
Here, let me continue, um.
So I have to write down the balanced equation for every note.
So the first note, which has generation, is written this way.
So if I zero this is this way.
And if it's the receiving point, this is written this way.
But if it's none of any of those two types, then the there is no generation, no load.
And that's the concern for every node.
And also, the flow should be always less than the capacity.
And the constraint is the final I think the rule is key to.
And the objective function is expression, uh, model.
So this way you can see that I don't need to define an extra variable called off.
OK, does it give me anything else so I can remove it for simplicity and I choose the solver as the
GOP.
OK, so the the unknown, uh, I haven't discussed it so far is the capacity.
So the capacity should be specified in the data file.
So you can see it here.
Um, it's a kind of table specifying how much is the capacity between each pair of nodes.
And you can see that in this specific example, uh, it's not symmetrical.
So the capacity between two and one is ten, but between one and two is zero.
So it's a direct kind of graph.
OK, um, you can change the numbers if you want.
And see the impact, so, uh, it will read that, uh, data file and put it into the, uh, payable
and assets to solve it.
OK.
And so you can see here that the eye can plot the results and show you what's happening, so ironic.
And I explain what's happening at each stage.
OK, so the model is solved here and the data is given here.
So I want to plot that graph.
So I put a circle and connect the connected points and the capacities are somehow graphically shown
here.
The roots with higher capacity are a bit thicker kind of lines.
Uh, and also, you can see the objective function is seven, OK, so this is the maximum amount of
energy that is, uh, capable of passing from zero to six.
And there are some, uh, useful information regarding the, um, solid example.
So just have a look at the, uh, this instance that display we want to find out if or modeling approach
is efficient or not.
OK, so, um.
OK, so how much is the maximum capacity?
It's, um, it was ten in the data to fight.
OK, so we could also specify before I explain that, I just have a look at the variable.
The variable is flow.
Flo Gee, and, uh, what else, um, objective, objective function is something else.
OK, so there are two main variables G and, uh, flow.
So just have a look at the, uh, status of each variable.
OK.
So as you can see here that we have a variable called zero and zero.
It means that the flow between nodes zero and node zero, which is not going to be true because I don't
need that kind of variable in my model.
OK, so why is it created?
Let's have a look at the model the way I wrote it.
So here you can see that I have a condition that I should be, um, different with is the same here.
So this constraint is not creating a problem for me.
This is the one.
OK, so because I am defining it for every pair of, uh, i n j.
For a small problems, um, it doesn't create that much hassle, but, uh, for larger kind of, uh,
programming, it should be definitely avoided.
So, uh, let's put a condition here.
Let's say if I is not equal to Jay, then return this or else return
counseling's.
Dogs screamed.
OK, so if I run the code again.
Oh, I hope I, um, avoid that, um.
What happened?
OK, OK, so the problem is solved, but here, let me check.
So there is no combination of zero and zero and, um, one on one and so on and so on.
OK, so, um, in order to check what is happening here, I have to see, um, this line.
OK, so let's have a look.
And.
Mm hmm.
So it is telling me that it is trying to access one specific, um, components of air flow, which doesn't
exist, it can be understandable because and now, um, let me, um.
To this in this way.
OK, so I put it here, it is bigger than the plot.
OK.
I hope this time it resolved the problem.
Yeah.
A good and one the last tab and see the results.
So you can see here that um yeah.
It doesn't exist in the model.
The stall is uh now true.
It means that it doesn't um.
It's not included in the wall.
OK.
And and it doesn't have any value, as you can see here, and also there is another point that can be
considered, and it's the fact that there is no upper bound for the flow.
OK, so it's not so it's always, as I said before, and it's always good to have a bound for your valuables.
So I even if it's not very tight, but at least it's something like that.
So if I run the code again and, um, let's run all the tabs and see the results.
OK, so as you can see here, the upper bound of the valuable flow is now determined.
OK, so, um, these are the steps that you can follow to improve the way you.