mdolab / pyoptsparse

pyOptSparse is an object-oriented framework for formulating and solving nonlinear constrained optimization problems in an efficient, reusable, and portable manner.
https://mdolab-pyoptsparse.readthedocs-hosted.com/en/latest/
GNU Lesser General Public License v3.0
223 stars 108 forks source link

How to obtain the Pareto front via NSGA-II #400

Closed Zcaic closed 4 months ago

Zcaic commented 4 months ago

I have a multi-objective problem and I found that when I optimize with NSGA-II, I get only one solution, how can I get the whole one Pareto front? thanks!!!

ewu63 commented 4 months ago

This information is provided in the files written out by NSGA2.

  1. Make sure PrintOut is set appropriately (say 1)
  2. The information is encoded in nsga2_best_pop.out but several other files are available with other information you may find useful.

Sample snippet for the example script nsga2_multi_objective.py:

import matplotlib.pyplot as plt
import numpy as np
x = np.loadtxt("nsga2_best_pop.out")
plt.plot(x[:,0], x[:,1], '.')
plt.show()

This plots the Pareto front for this simple 2-objective problem. image