In this optimization problem, we are going to solve the problem of biggest rectangle inside a circle.
So, um, we do have a rectangle with radius R and we want to find out what is the maximum area of a
rectangle inside that circle.
So in order to solve the problem, we have to formulate it mathematically.
Now let's talk about how we can do this.
Suppose this side of the big rectangle is X. This one is X, this one is Y, OK?
And then the air the surface of that rectangle will become four times X multiplied by Y.
And also we do have some other constraints that should be written.
The X value is something between minus R and R.
Hmm.
And also Y and squared plus X squared is equal to our square.
OK, now we want to find out how can we solve this problem.
Hello, everybody, this lecture is going to be talking about the problem of biggest rectangle inside
a circle.
Suppose we have the following optimization problem and we want to formulate it as an optimization problem.
We want to know what is the maximum area of a rectangle inside a circle.
So suppose we do have this graph.
We do have a circle with Radius R and we want to know how can we find a maximum area of that rectangle?
This side is X, this side is Y, and now we want to find out what is the area of the whole rectangle.
So it will be obviously four times one of these small rectangles.
So four times X multiplied by Y.
Obviously you can see on this graph X can move between zero and R at maximum and also Y is doing the
same.
It is moving from zero to R, then we do have a relation between X and R because they are all on the
um.
Circle, then X squared plus Y square is our square, and the other two constraints are given as follows.
Um, X is between zero and Y is between zero and ah, OK.
In order to solve it in Python, we need to define some, uh, input data and also some decision variables.
Now you can imagine what are the decision variables here.
So we have two decision variables, X and Y and also one objective function, which is called off here,
then we need to find out how can you write down the equations describing the objective function?
How can we define the decision variables and how should we define the limits of the variables and how
can we finally solve it?
So please refer to your Python code, as you can see in the attachment.
Then let's solve this all together.
OK, so here you can see that we have formulated the pro problem.
And here in Palermo, let's start with the first stop.
The code is written in Jupiter notebook and it can be easily run on your machine.
It can be a MacBook or a Windows based kind of, um, machine.
So first of all, we import plomo package using this.
Um, come on from plomo.
Don't environ import.
Uh, Astrachan.
It means import everything.
So these are the comments.
And to find out what's going on.
OK, so these these are not going to change anything on your formulation, but just give you some hints
what's happening.
OK, so for this example, I'm going to use the concrete model.
Then using the data that we have for this problem, I'm going to initialize it then, for example,
are is a perimeter because we know the value of it initially and we initialise it with number 10.
You can choose any other number that you want.
And then X is a variable.
So model that X is equal to where, um, bounds are specified here.
It's moving between zero and model that are don't write down R because it doesn't recognize R, it only
recognizes model that are which is already defined and we can initialize it with some value.
I have chosen models that are as the initial value model dot and y variable again and the bounds are
the same between zero and R and we have initialize that with models.
Those are then are you do have a constraint.
C One constraint is equal to constraint.
Expression is and which is describing the model is equal to Model X and square.
I've written this square in this way and also model that Y square is equal to model not R and square.
And finally, the objective function is equal to expression four times Model X multiplied by Model Y
and with a sense of maximization because we want to maximize the objective function.
Then on the next top, let's broaden the tabs individually.
The first top is drawn, ok?
The second type is done.
The same on the third top.
I'm going to define the solver I'm going to use for solving the problem.
Let's have a look at the shape of the optimization problem.
It has a multiplication of X by Y and it becomes nonlinear.
So I have to use a non-linear kind of solver.
So for this purpose I have use EPOP solver is a specified here.
Solver is equal to solve factory EPOP and the results is equal to solving that.
Solve the name of the model B and I have chosen the model.
You can't you could use any other kind of A naming and then let's run these top.
So this tab is already drawn and then the simulation is finished and I do have the values for the X
and Y, so if I run it again, you can see the values of X and Y equal to each other equal to seven
point zero seven one and the amount of objective function is two hundred.
And also I can get some other results from the simulation.
If I run this, I can get some other results and I can fix one of the variables.
For example, I can fix and one of the variables like X equal to something which is one here which can
happen for you.
And for example, you want to have a fixed variable in your model and you already know the value so
you can fix it and solve the rest of the problem.
So with X equal to one, Y becomes something else.
An objective function is something else.
So by comparing these to a simulation, you can see by manipulating the decision variables, you are
you are getting them far away from the optimal value they can get.
Some of the optimum value for X and Y are equal to each other, equal to seven point zero seven one.
But if you change that and fixed some of them, the results become something else.
OK, so, um, for in order to on fix the decision valuable and fixed something else, you can use this
command model that x that on fix.
It means that the variable X is no longer a fixed value and you can fix something else or you can,
you can do nothing, OK, and then solve it again and you can see the results here.
This time Y is equal to one and X is something else, OK?
And the objective function is found.
You can fix everything OK and then solve the problem again and see the results.
OK, so here you can see that there are some um, useful information regarding the model.
You have solved the number of constraints, the number of variables, the objective function, the balance
for everything is found.
And also it tells you that the solver has been successful in finding the optimal solution or not.
OK, so you can expand this model to any other application if you want.
And that's it for this session.