.. 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 :ref:`Go to the end ` 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-42 .. code-block:: default from __future__ import annotations from gemseo import configure_logger from gemseo import create_discipline from gemseo import create_scalable from gemseo import create_scenario from gemseo.problems.sobieski.core.problem import SobieskiProblem .. GENERATED FROM PYTHON SOURCE LINES 43-45 Import ------ .. GENERATED FROM PYTHON SOURCE LINES 45-49 .. code-block:: default configure_logger() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 50-54 Learning dataset ---------------- The first step is to build an :class:`.AbstractFullCache` dataset from a :class:`.DiagonalDOE`. .. GENERATED FROM PYTHON SOURCE LINES 56-61 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 61-63 .. code-block:: default discipline = create_discipline("SobieskiAerodynamics") .. GENERATED FROM PYTHON SOURCE LINES 64-67 Get the input space ~~~~~~~~~~~~~~~~~~~ We also define the input space on which to sample the discipline. .. GENERATED FROM PYTHON SOURCE LINES 67-71 .. 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) .. raw:: html
Design space:
name lower_bound value upper_bound type
x_shared[0] 0.01 0.05 0.09 float
x_shared[1] 30000 45000 60000 float
x_shared[2] 1.4 1.6 1.8 float
x_shared[3] 2.5 5.5 8.5 float
x_shared[4] 40 55 70 float
x_shared[5] 500 1000 1500 float
x_2 0.75 1 1.25 float
y_32 0.235 0.5027962499999999 0.795 float
y_12[0] 24850 50606.9742 77250 float
y_12[1] 0.45 0.95 1.5 float


.. GENERATED FROM PYTHON SOURCE LINES 72-78 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 78-86 .. 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 .. code-block:: none INFO - 13:51:43: INFO - 13:51:43: *** Start DOEScenario execution *** INFO - 13:51:43: DOEScenario INFO - 13:51:43: Disciplines: SobieskiAerodynamics INFO - 13:51:43: MDO formulation: DisciplinaryOpt INFO - 13:51:43: Optimization problem: INFO - 13:51:43: minimize y_2(x_shared, x_2, y_32, y_12) INFO - 13:51:43: with respect to x_2, x_shared, y_12, y_32 INFO - 13:51:43: over the design space: INFO - 13:51:43: +-------------+-------------+--------------------+-------------+-------+ INFO - 13:51:43: | name | lower_bound | value | upper_bound | type | INFO - 13:51:43: +-------------+-------------+--------------------+-------------+-------+ INFO - 13:51:43: | x_shared[0] | 0.01 | 0.05 | 0.09 | float | INFO - 13:51:43: | x_shared[1] | 30000 | 45000 | 60000 | float | INFO - 13:51:43: | x_shared[2] | 1.4 | 1.6 | 1.8 | float | INFO - 13:51:43: | x_shared[3] | 2.5 | 5.5 | 8.5 | float | INFO - 13:51:43: | x_shared[4] | 40 | 55 | 70 | float | INFO - 13:51:43: | x_shared[5] | 500 | 1000 | 1500 | float | INFO - 13:51:43: | x_2 | 0.75 | 1 | 1.25 | float | INFO - 13:51:43: | y_32 | 0.235 | 0.5027962499999999 | 0.795 | float | INFO - 13:51:43: | y_12[0] | 24850 | 50606.9742 | 77250 | float | INFO - 13:51:43: | y_12[1] | 0.45 | 0.95 | 1.5 | float | INFO - 13:51:43: +-------------+-------------+--------------------+-------------+-------+ INFO - 13:51:43: Solving optimization problem with algorithm DiagonalDOE: INFO - 13:51:43: ... 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 `_