Configuring the NSGA-II algorithm

This quick-start tutorial demonstrates how to configure the NSGA-II algorithm and apply it to the DTLZ2 problem with two objectives. Furthermore, it is demonstrated how numerical results can be reported and how the visualization of the final population can be performed. The complete source code for this tutorial can be found here: TODO — will be published soon (framework’s version at least TODO). In what follows, the relevant commented code blocks are presented, and the expected results are visualized for convenience.

The overview of the source code:

Let us start with defininf the criteria/objectives:

Now, we can define the problem-specifica data:

Then, we can proceed to instantiating the NSGA-II algorithm:

Now, we can execute the method. Two means of doing that are presented:

The following piece of code accesses the specimens and prints the information on their objective and decision vectors:

Expected first lines of the console output:

1.023 0.000 : 0.000 0.495 0.516 0.491 0.519 0.518 0.480 0.500 0.499 0.564 0.502 0.632
0.000 1.046 : 1.000 0.493 0.468 0.492 0.394 0.477 0.430 0.523 0.483 0.485 0.335 0.487
1.023 0.000 : 0.000 0.495 0.516 0.491 0.519 0.518 0.480 0.500 0.499 0.564 0.502 0.632
0.000 1.046 : 1.000 0.493 0.468 0.492 0.394 0.477 0.430 0.523 0.483 0.485 0.335 0.487
0.690 0.727 : 0.517 0.498 0.470 0.487 0.516 0.478 0.503 0.509 0.525 0.506 0.503 0.499

Additionally, we can calculate the hypervolume attained by the final population and compare it with the easy-to-calculate optimum:

Expected console output:

HV = 0.40047534244224003
Optimal HV = 0.4246018366025519
Difference = 0.024126494160311873

We can finally visualize the last population constructed by NSGA-II. It begins by creating the plot:

Then, a dedicated Frame object (extends the Java Swing’s Frame class) must be instantiated:

After instantiating the plot and the frame, we can start preparing the data sets to be visualized:

The following piece of code displays the rendered plot:

Lastly, this tutorial showcases how to create the plot’s screenshot that can be then used, e.g., in one’s publication:

The expected final render is provided below. Note the poor performance in terms of distribution, which is often attributed to the classic NSGA-II algorithm.