<jupyter_start><jupyter_text>.. _nb_decomposition:<jupyter_code>## Decomposition
Also, multi-objective problems can be decomposed using a scalarization function.
In the following, the contour lines of different methods are shown.

Let us first make the necessary imports and define the points in the design space:<jupyter_output><empty_output><jupyter_text>import matplotlib.pyplot as pltimport numpy as npfrom pymoo.factory import get_decompositionfrom pymoo.util.misc import all_combinations number of points to be used for plottingn_points = 100 the xlimP = np.linspace(0, 3, n_points) used for the meshgridX = all_combinations(P,P)<jupyter_code>A method to plot the contours:<jupyter_output><empty_output><jupyter_text>def plot_contour(X, F):    _X = X[:, 0].reshape((n_points,n_points))    _Y = X[:, 1].reshape((n_points,n_points))    _Z = F.reshape((n_points,n_points))        fig, ax = plt.subplots()    ax.contour(_X,_Y, _Z, colors='black')    ax.arrow(0, 0, 2.5, 2.5, color='blue', head_width=0.1, head_length=0.1, alpha=0.4)    ax.set_aspect('equal')<jupyter_code>And then define the weights to be used by the decomposition functions:<jupyter_output><empty_output><jupyter_text>weights = [0.5, 0.5]<jupyter_code>.. _nb_weighted_sum:<jupyter_output><empty_output><jupyter_text>Weighted Sum<jupyter_code>plot_contour(X, get_decomposition("weighted-sum").do(X, weights=weights))<jupyter_output><empty_output><jupyter_text>.. _nb_tchebyshev:<jupyter_code>### Tchebysheff<jupyter_output><empty_output><jupyter_text>plot_contour(X, get_decomposition("tchebi").do(X, weights=weights))<jupyter_code>.. _nb_asf:<jupyter_output><empty_output><jupyter_text>Achievement Scalarization Function (ASF) Details can be found in .<jupyter_code>plot_contour(X, get_decomposition("asf", eps=0).do(X, weights=weights))<jupyter_output><empty_output><jupyter_text>.. _nb_aasf:<jupyter_code>### Augmented Achievement Scalarization Function (AASF)
Details can be found in <cite data-cite="aasf"></cite>.<jupyter_output><empty_output><jupyter_text>plot_contour(X, get_decomposition("aasf", eps=0, beta=5).do(X, weights=weights)) plot_contour(X, get_decomposition("aasf", eps=0, beta=25).do(X, weights=weights))<jupyter_code>.. _nb_pbi:<jupyter_output><empty_output><jupyter_text>PBI<jupyter_code>plot_contour(X, get_decomposition("pbi", theta=0.5, eps=0).do(X, weights = weights))
plot_contour(X, get_decomposition("pbi", theta=1, eps=0).do(X, weights = weights))
plot_contour(X, get_decomposition("pbi", theta=5, eps=0).do(X, weights = weights))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.137890625, 'fraction_numerical': 0.0140625, 'mean_word_length': 8.888030888030888, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '289479', 'license': 'Apache-2.0', 'n_tokens_mistral': 1007, 'n_tokens_neox': 968, 'n_words': 174, 'path': 'doc/source/misc/decomposition.ipynb', 'repo_name': 'gemsanyu/pymoo', 'size': '2560'}