Run this example in your browser
Solving the cylinder problem using NIMBUS¶
Let’s consider a cell shaped like a cylinder, that is, a circular cross-sectional prism. The shape of the cell is here determined by two quantities, its radius \(x_1\) and its height \(x_2\). We want to maximize the volume of the cylinder and minimize the surface area. In addition to this, cylinder’s height should be close to 15 units.
The volume of a cylinder is the product of its base area and height. A cylinder can be cut and unrolled into a rectangle and the surface area of this rectangle is the product of its height and the perimeter of the circle \(2\pi x_1 x_2\). The sum of the cylinder’s two flat circular caps is \(2\pi x_1^2\). The total surface area of the cylinder with flat circular ends is then \(2\pi x_1^2 + 2\pi x_1 x_2\).
Three functions can be made from the above information: the one describing the volume of the cylinder, the other telling the surface area and the last measuring the height difference.
So the problem is:
Let’s assume that the cylinder’s height must be greater or equal to its width. This information gives us the following constraint:
\(g(x) = 2x_1 - x_2 \leq 0\)
To run this example, you need to run each individual code block (the
ones saying In [ ]:
to their left) by clicking on each one and then
clicking “Run”. Please refer to the background section of the
documentation
for information about NIMBUS.
Imports¶
This first code snippet simply imports the parts of DESDEO we need for this notebook. We import optimisation methods, NIMBUS and the CylinderProblem problem definition from the desdeo module, and visualisation and preference selection tools and widgets from the desdeo_vis module.
In [1]:
from desdeo.method.NIMBUS import NIMBUS
from desdeo.optimization import SciPyDE
from desdeo.problem.toy import CylinderProblem
from desdeo_vis.widget import NimbusPrefWidget, ParplotWidget
Getting a solutions based on a preference¶
First we initialise the CylinderProblem
problem and the NIMBUS
solution method. Then we get an initial result. We can plot solutions at
any time using ParplotWidget
.
In [2]:
problem = CylinderProblem()
method = NIMBUS(problem, SciPyDE)
results = method.init_iteration()
ParplotWidget(results.objective_vars, problem)
The first solution we get from NIMBUS is reasonable. However, we want to increase the cylinder’s volume as much as possible, still keeping the surface area and height difference low.
To do this, first display a NimbusPrefWidget
. After executing the
cell, a widget will display which you can use as follows: * For now we
let the volume vary freely by selecting <>
from the leftmost
dropdown. * The next column has the preferences for the surface area
function. We want to know how much the volume will be when the surface
area is less than 1900, so we set the dropdown to >=
and type
1900
into the textbox next to it. * For height difference, we won’t
accept a worse solution than the current one, so we set the dropdown to
<=
.
In [3]:
pref = NimbusPrefWidget(results.objective_vars, problem)
pref
Now we can plot the solutions given by NIMBUS.
In [5]:
results2 = method.next_iteration(preference=pref.nimbus_clf(method))
ParplotWidget(results2.objective_vars, problem)
INFEASIBLE 277.360873