.. 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-49 .. code-block:: default from __future__ import absolute_import, division, unicode_literals from future import standard_library from gemseo.api import ( configure_logger, create_design_space, create_discipline, create_scenario, ) configure_logger() standard_library.install_aliases() .. GENERATED FROM PYTHON SOURCE LINES 50-55 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 55-61 .. 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 62-66 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 66-70 .. 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 71-79 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 79-87 .. 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=True) .. 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 .. GENERATED FROM PYTHON SOURCE LINES 88-97 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 97-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=True) .. 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 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.278 seconds) .. _sphx_glr_download_examples_scalable_plot_diagonal_doe.py: .. only :: html .. container:: sphx-glr-footer :class: 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 `_