.. 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 Click :ref:`here ` 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-40 .. code-block:: default from gemseo.api import configure_logger from gemseo.api import create_design_space from gemseo.api import create_discipline from gemseo.api import create_scenario from matplotlib import pyplot as plt configure_logger() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 41-46 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 46-51 .. code-block:: default discipline = create_discipline( "AnalyticDiscipline", expressions={"z": "2*x-3*sin(2*pi*y)"} ) .. GENERATED FROM PYTHON SOURCE LINES 52-56 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 56-60 .. 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 61-69 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 69-77 .. code-block:: default scenario = create_scenario( discipline, "DisciplinaryOpt", "z", design_space, scenario_type="DOE" ) scenario.execute({"algo": "DiagonalDOE", "n_samples": 10}) dataset = scenario.export_to_dataset(opt_naming=False) dataset.plot("ScatterMatrix", save=False, show=False) .. 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 Out: .. code-block:: none INFO - 10:03:50: INFO - 10:03:50: *** Start DOEScenario execution *** INFO - 10:03:50: DOEScenario INFO - 10:03:50: Disciplines: AnalyticDiscipline INFO - 10:03:50: MDO formulation: DisciplinaryOpt INFO - 10:03:50: Optimization problem: INFO - 10:03:50: minimize z(x, y) INFO - 10:03:50: with respect to x, y INFO - 10:03:50: over the design space: INFO - 10:03:50: +------+-------------+-------+-------------+-------+ INFO - 10:03:50: | name | lower_bound | value | upper_bound | type | INFO - 10:03:50: +------+-------------+-------+-------------+-------+ INFO - 10:03:50: | x | 0 | None | 1 | float | INFO - 10:03:50: | y | 0 | None | 1 | float | INFO - 10:03:50: +------+-------------+-------+-------------+-------+ INFO - 10:03:50: Solving optimization problem with algorithm DiagonalDOE: INFO - 10:03:50: ... 0%| | 0/10 [00:00 .. GENERATED FROM PYTHON SOURCE LINES 78-87 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 87-98 .. 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.export_to_dataset(opt_naming=False) dataset.plot("ScatterMatrix", save=False, show=False) # Workaround for HTML rendering, instead of ``show=True`` plt.show() .. 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 Out: .. code-block:: none INFO - 10:03:51: INFO - 10:03:51: *** Start DOEScenario execution *** INFO - 10:03:51: DOEScenario INFO - 10:03:51: Disciplines: AnalyticDiscipline INFO - 10:03:51: MDO formulation: DisciplinaryOpt INFO - 10:03:51: Optimization problem: INFO - 10:03:51: minimize z(x, y) INFO - 10:03:51: with respect to x, y INFO - 10:03:51: over the design space: INFO - 10:03:51: +------+-------------+--------------------+-------------+-------+ INFO - 10:03:51: | name | lower_bound | value | upper_bound | type | INFO - 10:03:51: +------+-------------+--------------------+-------------+-------+ INFO - 10:03:51: | x | 0 | 0.2222222222222222 | 1 | float | INFO - 10:03:51: | y | 0 | 0.2222222222222222 | 1 | float | INFO - 10:03:51: +------+-------------+--------------------+-------------+-------+ INFO - 10:03:51: Solving optimization problem with algorithm DiagonalDOE: INFO - 10:03:51: ... 0%| | 0/10 [00:00` .. 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 `_