# NAUTILUS basic example

Suppose we have the problem defined in the analytical problem example:

\begin{equation}
\begin{aligned}
& \underset{\mathbf x}{\text{min}}
& & x_1^2 - x_2; x_2^2 - 3x_1 \\
& \text{s.t.} & &  x_1 + x_2 \leq 10 \\
& & &  \mathbf{x} \; \in S, \\
\end{aligned}
\end{equation}

where the feasible region is

\begin{equation}
x_i \in \left[-5, 5\right] \; \forall i \;\in \left[1,2\right].
\end{equation}


```python
from desdeov2.problem.Problem import ScalarMOProblem
from desdeov2.problem.Objective import ScalarObjective
from desdeov2.problem.Variable import Variable
from desdeov2.problem.Constraint import ScalarConstraint

# Args: name, starting value, lower bound, upper bound
x1 = Variable("x_1", 0, -0.5, 0.5)
x2 = Variable("x_2", 0, -0.5, 0.5)

# Args: name, callable
obj1 = ScalarObjective("f_1", lambda x: x[0]**2 - x[1])
obj2 = ScalarObjective("f_2", lambda x: x[1]**2 - 3*x[0])

# Args: name, n of variables, n of objectives, callable
cons1 = ScalarConstraint("c_1", 2, 2, lambda x, _: 10 - (x[0] + x[1]))

# Args: list of objevtives, variables and constraints
problem = ScalarMOProblem([obj1, obj2]
                         ,[x1, x2]
                         ,[cons1])
```

To solve it using ENAUTILUS is simple. Begin by importing and defining the method.


```python
from desdeov2.methods.Nautilus import Nautilus

method = Nautilus(problem)
```

Next, the method must be initialized by supplying it with a desired number of iterations. Let's choose 5 iterations for the sake of the example.


```python
(fs, bounds, d) = method.initialize(5)
print("Current objective values", fs)
print("Lower (worse) and upper (better) bounds of the reachable solutions from the current objective values", bounds)
print("Distance to the Pareto front from the current iteration (0: farthest, 100: closest):", d)
```

Preferences can be expressed in two way. The first way is to simply divide 100 points between all objectives, the more points, the more important it is to improve that objective.


```python
import numpy as np

points = np.array([30, 70])
remaining_iters = method.interact(percentages=points)

(fs, bounds, d) = method.iterate()

print("Objectives: ", fs)
```

Notice how the objectives have both improved. The other way to indicate preference, is to use indexing. Say, we deem objective 1 to be more important, then


```python
index_set = np.array([2, 1])
remaining_iters = method.interact(index_set=index_set)

(fs, bounds, d) = method.iterate()

print("Objectives: ", fs)
```

Again, the objectives have decreased. This is the basic usage of the algorithm. It can support more advanced stuff. like taking steps back or taking shorter steps. Refer to the documentation and other examples.

0783ac609b775abc97cb96e5ee36de018d95896b
ipynb
Jupyter Notebook
notebooks/nautilus.ipynb
gialmisi/DESDEOv2
0eeb4687d2e539845ab86a5018ff99b92e4ca5cf
MIT
2019-08-08T05:11:21.000Z
2019-08-08T05:11:21.000Z
notebooks/nautilus.ipynb
gialmisi/DESDEOv2
0eeb4687d2e539845ab86a5018ff99b92e4ca5cf
MIT
2019-08-25T08:49:33.000Z
2019-09-06T08:06:46.000Z
notebooks/nautilus.ipynb
gialmisi/DESDEOv2
0eeb4687d2e539845ab86a5018ff99b92e4ca5cf
MIT
2019-11-07T14:42:29.000Z
2019-11-07T14:42:29.000Z
Qwen/Qwen-72B
1. YES
2. YES