.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/scalable/plot_diagonal_doe.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_examples_scalable_plot_diagonal_doe.py: Diagonal design of experiments ============================== Here is an illustration of the diagonal design of experiments (DOE) implemented by the :class:`.DiagonalDOE` class and used by the :class:`.ScalableDiagonalModel`. The idea is to sample the discipline by varying its inputs proportionally on one of the diagonals of its input space. .. GENERATED FROM PYTHON SOURCE LINES 31-42 .. code-block:: default from __future__ import annotations from gemseo import configure_logger from gemseo import create_design_space from gemseo import create_discipline from gemseo import create_scenario from gemseo.post.dataset.scatter_plot_matrix import ScatterMatrix configure_logger() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 43-48 Create the discipline --------------------- First, we create an :class:`.AnalyticDiscipline` implementing the function: :math:`f(x)=2x-3\sin(2\pi y)` and set its cache policy to :code:`"MemoryFullCache"`. .. GENERATED FROM PYTHON SOURCE LINES 48-53 .. code-block:: default discipline = create_discipline( "AnalyticDiscipline", expressions={"z": "2*x-3*sin(2*pi*y)"} ) .. GENERATED FROM PYTHON SOURCE LINES 54-58 Create the design space ----------------------- Then, we create a :class:`.DesignSpace` where :math:`x` and :math:`y` vary between 0 and 1. .. GENERATED FROM PYTHON SOURCE LINES 58-62 .. code-block:: default design_space = create_design_space() design_space.add_variable("x", l_b=0.0, u_b=1.0) design_space.add_variable("y", l_b=0.0, u_b=1.0) .. GENERATED FROM PYTHON SOURCE LINES 63-71 Sample with the default mode ---------------------------- Lastly, we create a :class:`.DOEScenario` and execute it with the :class:`.DiagonalDOE` algorithm to get 10 evaluations of :math:`f`. Note that we use the default configuration: all the disciplinary inputs vary proportionally from their lower bounds to their upper bounds. .. GENERATED FROM PYTHON SOURCE LINES 71-78 .. code-block:: default scenario = create_scenario( discipline, "DisciplinaryOpt", "z", design_space, scenario_type="DOE" ) scenario.execute({"algo": "DiagonalDOE", "n_samples": 10}) dataset = scenario.to_dataset(opt_naming=False) ScatterMatrix(dataset).execute(save=False, show=True) .. image-sg:: /examples/scalable/images/sphx_glr_plot_diagonal_doe_001.png :alt: plot diagonal doe :srcset: /examples/scalable/images/sphx_glr_plot_diagonal_doe_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 16:25:31: INFO - 16:25:31: *** Start DOEScenario execution *** INFO - 16:25:31: DOEScenario INFO - 16:25:31: Disciplines: AnalyticDiscipline INFO - 16:25:31: MDO formulation: DisciplinaryOpt INFO - 16:25:31: Optimization problem: INFO - 16:25:31: minimize z(x, y) INFO - 16:25:31: with respect to x, y INFO - 16:25:31: over the design space: INFO - 16:25:31: +------+-------------+-------+-------------+-------+ INFO - 16:25:31: | name | lower_bound | value | upper_bound | type | INFO - 16:25:31: +------+-------------+-------+-------------+-------+ INFO - 16:25:31: | x | 0 | None | 1 | float | INFO - 16:25:31: | y | 0 | None | 1 | float | INFO - 16:25:31: +------+-------------+-------+-------------+-------+ INFO - 16:25:31: Solving optimization problem with algorithm DiagonalDOE: INFO - 16:25:31: ... 0%| | 0/10 [00:00] .. GENERATED FROM PYTHON SOURCE LINES 79-88 Sample with reverse mode for :math:`y` -------------------------------------- We can also change the configuration in order to select another diagonal of the input space, e.g. increasing :math:`x` and decreasing :math:`y`. This configuration is illustrated in the new :class:`.ScatterMatrix` plot where the :math:`(x,y)` points follow the :math:`t\mapsto -t` line while the :math:`(x,y)` points follow the :math:`t\mapsto t` line with the default configuration. .. GENERATED FROM PYTHON SOURCE LINES 88-96 .. code-block:: default scenario = create_scenario( discipline, "DisciplinaryOpt", "z", design_space, scenario_type="DOE" ) scenario.execute( {"algo": "DiagonalDOE", "n_samples": 10, "algo_options": {"reverse": ["y"]}} ) dataset = scenario.to_dataset(opt_naming=False) ScatterMatrix(dataset).execute(save=False, show=True) .. image-sg:: /examples/scalable/images/sphx_glr_plot_diagonal_doe_002.png :alt: plot diagonal doe :srcset: /examples/scalable/images/sphx_glr_plot_diagonal_doe_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 16:25:32: INFO - 16:25:32: *** Start DOEScenario execution *** INFO - 16:25:32: DOEScenario INFO - 16:25:32: Disciplines: AnalyticDiscipline INFO - 16:25:32: MDO formulation: DisciplinaryOpt INFO - 16:25:32: Optimization problem: INFO - 16:25:32: minimize z(x, y) INFO - 16:25:32: with respect to x, y INFO - 16:25:32: over the design space: INFO - 16:25:32: +------+-------------+--------------------+-------------+-------+ INFO - 16:25:32: | name | lower_bound | value | upper_bound | type | INFO - 16:25:32: +------+-------------+--------------------+-------------+-------+ INFO - 16:25:32: | x | 0 | 0.2222222222222222 | 1 | float | INFO - 16:25:32: | y | 0 | 0.2222222222222222 | 1 | float | INFO - 16:25:32: +------+-------------+--------------------+-------------+-------+ INFO - 16:25:32: Solving optimization problem with algorithm DiagonalDOE: INFO - 16:25:32: ... 0%| | 0/10 [00:00] .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.093 seconds) .. _sphx_glr_download_examples_scalable_plot_diagonal_doe.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_diagonal_doe.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_diagonal_doe.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_