Closed jikuizhao closed 11 months ago
You can store the entire history and do something like this:
from pymoo.algorithms.moo.nsga2 import NSGA2
from pymoo.indicators.igd import IGD
from pymoo.optimize import minimize
from pymoo.problems import get_problem
problem = get_problem("zdt1")
algorithm = NSGA2(pop_size=100)
res = minimize(problem,
algorithm,
('n_gen', 10),
seed=1,
save_history=True,
verbose=True)
igd = IGD(problem.pareto_front())
for gen, snapshot in enumerate(res.history):
print(gen, igd.do(snapshot.pop.get("F")))
Dear,
I am a new learner, a simple question. How to produce IGD and Hypervolume performance statistics base on your current code?
from pymoo.algorithms.moo.nsga2 import NSGA2 from pymoo.problems import get_problem from pymoo.optimize import minimize from pymoo.visualization.scatter import Scatter
problem = get_problem("zdt1")
algorithm = NSGA2(pop_size=100)
res = minimize(problem, algorithm, ('n_gen', 200), seed=1, verbose=True)
plot = Scatter() plot.add(problem.pareto_front(), plot_type="line", color="black", alpha=0.7) plot.add(res.F, color="red") plot.show()