This example is called Hostile Brothers in Rectangle.
Suppose we have and brothers and we want to find the location of them in a rectangle in a way that the
minimum distance between each pair of brothers is maximum.
OK, so the input parameters of this model is a dimension of the rectangle.
And for simplicity, we can assume that it has a square shape.
Hmm.
So, um.
Then we need to find out the location of each brother so EXI and why of each brother should be found.
And so in order to calculate the distance between each pair of brothers for every injury, we have to
calculate this expression X minus X squared plus and minus YJ Square should be bigger than our square
and also um, the X should be within zero and one which is the dimension of that rectangle and Y is
between zero and one.
OK, so why is moving from here to here on X is moved from here to here.
OK, so in order to find out what is the optimal decision for this, um, problem, we need to have
a look at the Python code.
So first of all, as usual, we have to import the required libraries as we did it here.
We have defined it as an abstract model and I have defined the number of, uh, borders as a parameter
and made it mutable because we can.
Be able to change it and update it and also, um, we are trying to find out how we define a set of
I have it an exact number of brothers.
So Range sets one and model and J is the alias of the previous sets.
I l is the dimension of the board, OK.
And I define this um by function and later.
OK, so um there are three variables in this model X, Y and R so X is defined over I, Y is defined
over ie the bounds of both are between zero and model L. And they are defined within an non-negative
real's and we initialize them using this function in it felt so uh uniform number between zero and one
will be assigned to each number, uh variable.
And then we have to calculate the distance between each pair of uh, variables.
OK, so in order to do that we have to create a constraint like see model that C is constraint.
It is defined over the model ion model J uh, following the rules C one rule, the C1 rule is defined,
um, for different situations.
If we already know that the distance should be defined for different brothers, not themselves.
OK, so it means that if I n g is not equal to each other, then it means that the distance will be
calculated that uh using model dot x are in the minus model S and model X squared plus model.
That's why I minus model dot y j squared bigger than model that are square OK, that are is the minimum
distance between them.
And um if they are equal to each other then we have to accept a constraint.
OK, and the next line is describing the.
Uh, objective function, which is the given by expression equal to model, are we are telling Palomo
that the objective function is model R and the sense of optimization is maximization.
We want to maximize the minimum distance between each pair and we choose the, um, solver as the EPUB.
Since it's non-linear programming, we follow the iPod and then we specify the model that NP we could
put this, um, data in it.
That's fine.
And call that while.
And the next step is creating the instance model, that creating stance will will feed the data into
the model and create the constraints and everything, then we can ask, uh, to solve the model solved
that a specific instance for us which will be done.
Let me run the code for you.
OK, so first stop.
Second tab.
The top.
And, um, this one this one will, uh, graphically show you what's happening.
OK, so if you want to test it for another set of numbers, for example, let's say twenty five brothers,
I rerun the section and the model will be run for a bigger number of brothers.
OK, you can still increase the number, let's say, 40 brothers.
So to see what's going on so it takes more time and then it's for 40 brothers.
OK, thank you very much for paying attention to this example.