.. 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 33-47 .. code-block:: default from __future__ import division, unicode_literals from matplotlib import pyplot as plt from gemseo.api import ( configure_logger, create_design_space, create_discipline, create_scenario, ) configure_logger() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 48-53 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 53-59 .. code-block:: default discipline = create_discipline( "AnalyticDiscipline", expressions_dict={"z": "2*x-3*sin(2*pi*y)"} ) discipline.set_cache_policy("MemoryFullCache") .. GENERATED FROM PYTHON SOURCE LINES 60-64 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 64-68 .. 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 69-77 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 77-85 .. code-block:: default scenario = create_scenario( discipline, "DisciplinaryOpt", "z", design_space, scenario_type="DOE" ) scenario.execute({"algo": "DiagonalDOE", "n_samples": 10}) dataset = discipline.cache.export_to_dataset() dataset.plot("ScatterMatrix", save=False, show=False) .. image:: /examples/scalable/images/sphx_glr_plot_diagonal_doe_001.png :alt: plot diagonal doe :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none INFO - 09:23:34: INFO - 09:23:34: *** Start DOE Scenario execution *** INFO - 09:23:34: DOEScenario INFO - 09:23:34: Disciplines: AnalyticDiscipline INFO - 09:23:34: MDOFormulation: DisciplinaryOpt INFO - 09:23:34: Algorithm: DiagonalDOE INFO - 09:23:34: Optimization problem: INFO - 09:23:34: Minimize: z(x, y) INFO - 09:23:34: With respect to: x, y INFO - 09:23:34: DOE sampling: 0%| | 0/10 [00:00 .. GENERATED FROM PYTHON SOURCE LINES 86-95 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 95-107 .. code-block:: default discipline.cache.clear() scenario = create_scenario( discipline, "DisciplinaryOpt", "z", design_space, scenario_type="DOE" ) scenario.execute( {"algo": "DiagonalDOE", "n_samples": 10, "algo_options": {"reverse": ["y"]}} ) dataset = discipline.cache.export_to_dataset() dataset.plot("ScatterMatrix", save=False, show=False) # Workaround for HTML rendering, instead of ``show=True`` plt.show() .. image:: /examples/scalable/images/sphx_glr_plot_diagonal_doe_002.png :alt: plot diagonal doe :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none INFO - 09:23:35: INFO - 09:23:35: *** Start DOE Scenario execution *** INFO - 09:23:35: DOEScenario INFO - 09:23:35: Disciplines: AnalyticDiscipline INFO - 09:23:35: MDOFormulation: DisciplinaryOpt INFO - 09:23:35: Algorithm: DiagonalDOE INFO - 09:23:35: Optimization problem: INFO - 09:23:35: Minimize: z(x, y) INFO - 09:23:35: With respect to: x, y INFO - 09:23:35: DOE sampling: 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 `_