.. 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.disciplines.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 34-41 .. code-block:: default from gemseo.api import configure_logger from gemseo.api import create_discipline from gemseo.api import create_scalable from gemseo.api import create_scenario from gemseo.problems.sobieski.core.problem import SobieskiProblem from matplotlib import pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 42-44 Import ------ .. GENERATED FROM PYTHON SOURCE LINES 44-48 .. code-block:: default configure_logger() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 49-53 Learning dataset ---------------- The first step is to build an :class:`.AbstractFullCache` dataset from a :class:`.DiagonalDOE`. .. GENERATED FROM PYTHON SOURCE LINES 55-60 Instantiate the discipline ~~~~~~~~~~~~~~~~~~~~~~~~~~ For that, we instantiate the :class:`~gemseo.problems.sobieski.disciplines.SobieskiAerodynamics` discipline and set it up to cache all evaluations. .. GENERATED FROM PYTHON SOURCE LINES 60-62 .. code-block:: default discipline = create_discipline("SobieskiAerodynamics") .. GENERATED FROM PYTHON SOURCE LINES 63-66 Get the input space ~~~~~~~~~~~~~~~~~~~ We also define the input space on which to sample the discipline. .. GENERATED FROM PYTHON SOURCE LINES 66-70 .. code-block:: default input_space = SobieskiProblem().design_space input_names = [name for name in discipline.get_input_data_names() if name != "c_4"] input_space.filter(input_names) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 71-77 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 77-85 .. code-block:: default scenario = create_scenario( [discipline], "DisciplinaryOpt", "y_2", input_space, scenario_type="DOE" ) for output_name in discipline.get_output_data_names(): if output_name != "y_2": scenario.add_observable(output_name) scenario.execute({"algo": "DiagonalDOE", "n_samples": 20}) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none INFO - 10:03:54: INFO - 10:03:54: *** Start DOEScenario execution *** INFO - 10:03:54: DOEScenario INFO - 10:03:54: Disciplines: SobieskiAerodynamics INFO - 10:03:54: MDO formulation: DisciplinaryOpt INFO - 10:03:54: Optimization problem: INFO - 10:03:54: minimize y_2(x_shared, x_2, y_32, y_12) INFO - 10:03:54: with respect to x_2, x_shared, y_12, y_32 INFO - 10:03:54: over the design space: INFO - 10:03:54: +----------+-------------+--------------------+-------------+-------+ INFO - 10:03:54: | name | lower_bound | value | upper_bound | type | INFO - 10:03:54: +----------+-------------+--------------------+-------------+-------+ INFO - 10:03:54: | x_shared | 0.01 | 0.05 | 0.09 | float | INFO - 10:03:54: | x_shared | 30000 | 45000 | 60000 | float | INFO - 10:03:54: | x_shared | 1.4 | 1.6 | 1.8 | float | INFO - 10:03:54: | x_shared | 2.5 | 5.5 | 8.5 | float | INFO - 10:03:54: | x_shared | 40 | 55 | 70 | float | INFO - 10:03:54: | x_shared | 500 | 1000 | 1500 | float | INFO - 10:03:54: | x_2 | 0.75 | 1 | 1.25 | float | INFO - 10:03:54: | y_32 | 0.235 | 0.5027962499999999 | 0.795 | float | INFO - 10:03:54: | y_12 | 24850 | 50606.9742 | 77250 | float | INFO - 10:03:54: | y_12 | 0.45 | 0.95 | 1.5 | float | INFO - 10:03:54: +----------+-------------+--------------------+-------------+-------+ INFO - 10:03:54: Solving optimization problem with algorithm DiagonalDOE: INFO - 10:03:54: ... 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 `_