.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_numerical_methods/general_methods/plot_combinatorial_generator.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_numerical_methods_general_methods_plot_combinatorial_generator.py: Combinatorial generators ======================== .. GENERATED FROM PYTHON SOURCE LINES 6-20 In this example we are going to expose the various design of experiments that allow one to generate all the integer collections satisfying a given combinatorial constraint: - The Tuples generator, which allows one to generate all the elements of a Cartesian product :math:`E=\{0,\dots,n_0-1\}\times\dots\times\{0,\dots,n_{d-1}-1\}`. The total number of generated points is :math:`N=\prod_{k=0}^{d-1}n_k`. - The K-permutations generator, which allows one to generate all the injective functions from :math:`\{0,\dots,k-1\}` into :math:`\{0,\dots,n-1\}` The total number of generated points is :math:`N=\dfrac{n!}{(n-k)!}`. - The Combinations generator, which allows one to generate all the subsets of size :math:`k` of :math:`\{0,\dots,n-1\}` The total number of generated points is :math:`N=\dfrac{n!}{k!(n-k)!}`. .. GENERATED FROM PYTHON SOURCE LINES 22-26 .. code-block:: Python import openturns as ot ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 27-29 Tuples ------ .. GENERATED FROM PYTHON SOURCE LINES 29-32 .. code-block:: Python experiment = ot.Tuples([2, 3, 5]) print(experiment.generate()) .. rst-class:: sphx-glr-script-out .. code-block:: none [[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,2,0],[1,2,0],[0,0,1],[1,0,1],[0,1,1],[1,1,1],[0,2,1],[1,2,1],[0,0,2],[1,0,2],[0,1,2],[1,1,2],[0,2,2],[1,2,2],[0,0,3],[1,0,3],[0,1,3],[1,1,3],[0,2,3],[1,2,3],[0,0,4],[1,0,4],[0,1,4],[1,1,4],[0,2,4],[1,2,4]]#30 .. GENERATED FROM PYTHON SOURCE LINES 33-35 K-permutations -------------- .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: Python experiment = ot.KPermutations(3, 4) print(experiment.generate()) .. rst-class:: sphx-glr-script-out .. code-block:: none [[0,1,2],[0,2,1],[1,0,2],[1,2,0],[2,0,1],[2,1,0],[0,1,3],[0,3,1],[1,0,3],[1,3,0],[3,0,1],[3,1,0],[0,2,3],[0,3,2],[2,0,3],[2,3,0],[3,0,2],[3,2,0],[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]#24 .. GENERATED FROM PYTHON SOURCE LINES 39-41 Combinations ------------ .. GENERATED FROM PYTHON SOURCE LINES 41-43 .. code-block:: Python experiment = ot.Combinations(4, 6) print(experiment.generate()) .. rst-class:: sphx-glr-script-out .. code-block:: none [[0,1,2,3],[0,1,2,4],[0,1,2,5],[0,1,3,4],[0,1,3,5],[0,1,4,5],[0,2,3,4],[0,2,3,5],[0,2,4,5],[0,3,4,5],[1,2,3,4],[1,2,3,5],[1,2,4,5],[1,3,4,5],[2,3,4,5]]#15 .. _sphx_glr_download_auto_numerical_methods_general_methods_plot_combinatorial_generator.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_combinatorial_generator.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_combinatorial_generator.py `