.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/scalable/plot_diagonal.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.py: Scalable diagonal discipline ============================ Let us consider the :class:`~gemseo.problems.sobieski.wrappers.SobieskiAerodynamics` discipline. We want to build its :class:`.ScalableDiscipline` counterpart, using a :class:`.ScalableDiagonalModel` For that, we can use a 20-length :class:`.DiagonalDOE` and test different sizes of variables or different settings for the scalable diagonal discipline. .. GENERATED FROM PYTHON SOURCE LINES 36-40 .. code-block:: default from __future__ import division, unicode_literals from matplotlib import pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 41-43 Import ------ .. GENERATED FROM PYTHON SOURCE LINES 43-54 .. code-block:: default from gemseo.api import ( configure_logger, create_discipline, create_scalable, create_scenario, ) from gemseo.problems.sobieski.core import SobieskiProblem configure_logger() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 55-59 Learning dataset ---------------- The first step is to build an :class:`.AbstractFullCache` dataset from a :class:`.DiagonalDOE`. .. GENERATED FROM PYTHON SOURCE LINES 61-66 Instantiate the discipline ~~~~~~~~~~~~~~~~~~~~~~~~~~ For that, we instantiate the :class:`~gemseo.problems.sobieski.wrappers.SobieskiAerodynamics` discipline and set it up to cache all evaluations. .. GENERATED FROM PYTHON SOURCE LINES 66-69 .. code-block:: default discipline = create_discipline("SobieskiAerodynamics") discipline.set_cache_policy(discipline.MEMORY_FULL_CACHE) .. GENERATED FROM PYTHON SOURCE LINES 70-73 Get the input space ~~~~~~~~~~~~~~~~~~~ We also define the input space on which to sample the discipline. .. GENERATED FROM PYTHON SOURCE LINES 73-76 .. code-block:: default input_space = SobieskiProblem().read_design_space() input_space.filter(discipline.get_input_data_names()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 77-83 Build the DOE scenario ~~~~~~~~~~~~~~~~~~~~~~ Lastly, we sample the discipline by means of a :class:`.DOEScenario` relying on both discipline and input space. In order to build a diagonal scalable discipline, a :class:`.DiagonalDOE` must be used. .. GENERATED FROM PYTHON SOURCE LINES 83-88 .. code-block:: default scenario = create_scenario( [discipline], "DisciplinaryOpt", "y_2", input_space, scenario_type="DOE" ) scenario.execute({"algo": "DiagonalDOE", "n_samples": 20}) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none INFO - 12:58:29: INFO - 12:58:29: *** Start DOE Scenario execution *** INFO - 12:58:29: DOEScenario INFO - 12:58:29: Disciplines: SobieskiAerodynamics INFO - 12:58:29: MDOFormulation: DisciplinaryOpt INFO - 12:58:29: Algorithm: DiagonalDOE INFO - 12:58:29: Optimization problem: INFO - 12:58:29: Minimize: y_2(x_shared, x_2, y_32, y_12) INFO - 12:58:29: With respect to: x_shared, x_2, y_32, y_12 INFO - 12:58:29: DOE sampling: 0%| | 0/20 [00:00` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_diagonal.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_