# R-NSGA-III¶

Implementation details of this algorithm can be found in [8]. The reference lines that should be used by this algorithm must be defined before it is executed. Commonly, the Das-Dennis method (implemented in UniformReferenceDirectionFactory) is used to sample reference directions uniformly.

To generate the reference directions refer to the R-NSGA-III paper where the following procedure is laid out in detail.

The algorithm follows the general NSGA-III procedure with a modified survival selection operator. First, the non-dominated sorting is done as in NSGA-III.

Second, from the splitting front (final front) some solutions need to be selected. Solutions are associated to reference directions based on perpendicular distance, then solutions with smaller ASF values are preferred by selecting solutions from the underrepresented reference direction first. For this reason, when this algorithm converges each reference line seeks to find a good representative non-dominated solution.

## Example¶

```
[1]:
```

```
import numpy as np
from pymoo.algorithms.rnsga3 import rnsga3
from pymoo.optimize import minimize
from pymoo.util import plotting
from pymop.factory import get_problem
# Get problem
problem = get_problem("zdt1")
pf = problem.pareto_front()
# Define reference points
ref_points = np.array([[0.3, 0.4], [0.8, 0.5]])
# Get Algorithm
method = rnsga3(
ref_points=ref_points,
pop_per_ref_point=50,
mu=0.1)
res = minimize(problem,
method=method,
termination=('n_gen', 300),
pf=pf,
disp=False)
reference_directions = res.algorithm.survival.ref_dirs
plotting.plot(pf, res.F, ref_points, reference_directions, show=True,
labels=['pf', 'F', 'ref_points', 'ref_dirs'])
```

```
[2]:
```

```
from pymop.factory import UniformReferenceDirectionFactory
import matplotlib.pyplot as plt
# Get problem
problem = get_problem("dtlz4", n_var=12, n_obj=3)
# Define reference points and reference directions
ref_points = np.array([[1.0, 0.5, 0.2], [0.3, 0.2, 0.6]])
ref_dirs = UniformReferenceDirectionFactory(3, n_points=91).do()
pf = problem.pareto_front(ref_dirs)
# Get Algorithm
method = rnsga3(
ref_points=ref_points,
pop_per_ref_point=91,
mu=0.1)
res = minimize(problem,
method=method,
termination=('n_gen', 300),
pf=pf,
disp=False)
```

```
[3]:
```

```
ax = plotting.plot(res.F, pf, ref_points, show=False,
labels=['F', 'pf', 'ref_points'])
ax.view_init(45, 45)
plt.legend()
plt.show()
```