<jupyter_start><jupyter_text>.. _nb_custom_output:  Display When running the code, you might have seen some printouts (when using `verbose=True`), which might or might not have made a lot of sense to you. Below, a quick summary of possible printouts you might encounter is provided.<jupyter_code>.. csv-table:: Types of Output
   :header: "Name", "Description"
   :widths: 5, 30

   **n_gen**, "The current number of generations or iterations until this point."
   **n_eval**, "The number of function evaluations so far."
   **n_nds**, "For multi-objective problems, the number of *non-dominated* solutions of the optima found."
   **cv (min)**,  "The minimum constraint violation (CV) in the current population"
   **cv (avg)**,  "The average constraint violation (CV) of the current population"
   **f_opt**,  "For single-objective problems, the best function value found so far."
   **f_gap**,  "For single-objective problems, the best gap to the optimum (only printed if the optimum is *known*)."
   **eps/indicator**, "For multi-objective problems, the change of the indicator (ideal, nadir, f) over the last few generations (only printed if the Pareto-front is *unknown*). For more information we encourage you to have a look at the corresponding publication (:cite:`running`, `pdf <https://www.egr.msu.edu/~kdeb/papers/c2020003.pdf>`_)."
   **igd/gd/hv**, "For multi-objective problems, the performance indicator (only printed if the Pareto-front is *known*)."<jupyter_output><empty_output><jupyter_text>The default printouts can vary from algorithm to algorithm and from problem to problem. The type of printout is based on an implementation of the `Display` object. If you like to customize the output, you can also write your own, as shown below:<jupyter_code>from pymoo.algorithms.moo.nsga2 import NSGA2
from pymoo.factory import get_problem
from pymoo.optimize import minimize
from pymoo.util.display import Display
import numpy as np


class MyDisplay(Display):

    def _do(self, problem, evaluator, algorithm):
        super()._do(problem, evaluator, algorithm)
        self.output.append("metric_a", np.mean(algorithm.pop.get("X")))
        self.output.append("metric_b", np.mean(algorithm.pop.get("F")))


problem = get_problem("zdt2")

algorithm = NSGA2(pop_size=100)

res = minimize(problem,
               algorithm,
               ('n_gen', 10),
               seed=1,
               display=MyDisplay(),
               verbose=True)<jupyter_output>Compiled modules for significant speedup can not be used!
https://pymoo.org/installation.html#installation

To disable this warning:
from pymoo.config import Config
Config.show_compile_hint = False

=============================================
n_gen |  n_eval |   metric_a   |   metric_b  
=============================================
    1 |     100 |  0.500122773 |  2.958637098
    2 |     200 |  0.457137310 |  2.716284231
    3 |     300 |  0.424878151 |  2.540654646
    4 |     400 |  0.394032982 |  2.404824717
    5 |     500 |  0.370407264 |  2.295560288
    6 |     600 |  0.352432747 |  2.213395359
    7 |     700 |  0.328691523 |  2.099318577
{'fraction_non_alphanumeric': 0.13043478260869565, 'fraction_numerical': 0.06010230179028133, 'mean_word_length': 3.726586102719033, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '236746', 'license': 'Apache-2.0', 'n_tokens_mistral': 1064, 'n_tokens_neox': 936, 'n_words': 326, 'path': 'source/interface/display.ipynb', 'repo_name': 'zhaofeng-shu33/pymoo-doc', 'size': '3128'}