.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/scalable/scalable_study.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_scalable_study.py: Scalable study ============== We want to compare :class:`.IDF` and :class:`.MDF` formulations with respect to the problem dimension for the aerostructure problem. For that, we use the :class:`.ScalabilityStudy` and :class:`.PostScalabilityStudy` classes. .. GENERATED FROM PYTHON SOURCE LINES 30-44 .. code-block:: default from __future__ import annotations from gemseo.api import configure_logger from gemseo.api import create_discipline from gemseo.api import create_scenario from gemseo.problems.aerostructure.aerostructure_design_space import ( AerostructureDesignSpace, ) from gemseo.problems.scalable.data_driven.api import create_scalability_study from gemseo.problems.scalable.data_driven.api import plot_scalability_results configure_logger() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 45-49 Create the disciplinary datasets -------------------------------- First of all, we create the disciplinary :class:`.Dataset` datasets based on a :class:`.DiagonalDOE`. .. GENERATED FROM PYTHON SOURCE LINES 49-69 .. code-block:: default datasets = {} disciplines = create_discipline(["Aerodynamics", "Structure", "Mission"]) for discipline in disciplines: design_space = AerostructureDesignSpace() design_space.filter(discipline.get_input_data_names()) output_names = iter(discipline.get_output_data_names()) scenario = create_scenario( discipline, "DisciplinaryOpt", next(output_names), design_space, scenario_type="DOE", ) for output_name in output_names: scenario.add_observable(output_name) scenario.execute({"algo": "DiagonalDOE", "n_samples": 10}) datasets[discipline.name] = scenario.export_to_dataset( name=discipline.name, opt_naming=False ) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/4.3.0.post0/lib/python3.9/site-packages/gemseo/algos/design_space.py:458: ComplexWarning: Casting complex values to real discards the imaginary part self.__current_value[name] = array_value.astype( INFO - 16:57:18: INFO - 16:57:18: *** Start DOEScenario execution *** INFO - 16:57:18: DOEScenario INFO - 16:57:18: Disciplines: Aerodynamics INFO - 16:57:18: MDO formulation: DisciplinaryOpt INFO - 16:57:18: Optimization problem: INFO - 16:57:18: minimize drag(thick_airfoils, sweep, displ) INFO - 16:57:18: with respect to displ, sweep, thick_airfoils INFO - 16:57:18: over the design space: INFO - 16:57:18: +----------------+-------------+-------+-------------+-------+ INFO - 16:57:18: | name | lower_bound | value | upper_bound | type | INFO - 16:57:18: +----------------+-------------+-------+-------------+-------+ INFO - 16:57:18: | thick_airfoils | 5 | 15 | 25 | float | INFO - 16:57:18: | sweep | 10 | 25 | 35 | float | INFO - 16:57:18: | displ | -1000 | -700 | 1000 | float | INFO - 16:57:18: +----------------+-------------+-------+-------------+-------+ INFO - 16:57:18: Solving optimization problem with algorithm DiagonalDOE: INFO - 16:57:18: ... 0%| | 0/10 [00:00, , , , , , , ] .. GENERATED FROM PYTHON SOURCE LINES 160-176 Look at the dependency matrices ------------------------------- Here are the dependency matrices obtained with the 1st replicate when :code:`design_size=10`. Aerodynamics ~~~~~~~~~~~~ .. image:: /_images/scalable_example/2_1_sdm_Aerodynamics_dependency-1.png Structure ~~~~~~~~~~~~ .. image:: /_images/scalable_example/2_1_sdm_Structure_dependency-1.png Mission ~~~~~~~ .. image:: /_images/scalable_example/2_1_sdm_Mission_dependency-1.png .. GENERATED FROM PYTHON SOURCE LINES 178-215 Look at optimization histories ------------------------------ Here are the optimization histories obtained with the 1st replicate when :code:`design_size=10`, where the left side represents the :class:`.MDF` formulation while the right one represents the :class:`.IDF` formulation. Objective function ~~~~~~~~~~~~~~~~~~ .. image:: /_images/scalable_example/MDF_2_1_obj_history-1.png :width: 45% .. image:: /_images/scalable_example/IDF_2_1_obj_history-1.png :width: 45% Design variables ~~~~~~~~~~~~~~~~ .. image:: /_images/scalable_example/MDF_2_1_variables_history-1.png :width: 45% .. image:: /_images/scalable_example/IDF_2_1_variables_history-1.png :width: 45% Equality constraints ~~~~~~~~~~~~~~~~~~~~ .. image:: /_images/scalable_example/MDF_2_1_eq_constraints_history-1.png :width: 45% .. image:: /_images/scalable_example/IDF_2_1_eq_constraints_history-1.png :width: 45% Inequality constraints ~~~~~~~~~~~~~~~~~~~~~~ .. image:: /_images/scalable_example/MDF_2_1_ineq_constraints_history-1.png :width: 45% .. image:: /_images/scalable_example/IDF_2_1_ineq_constraints_history-1.png :width: 45% .. GENERATED FROM PYTHON SOURCE LINES 217-229 Post-process the results ------------------------ Lastly, we plot the results. Because of the replicates, the latter are not displayed as one line per optimization strategy w.r.t. scaling strategy, but as one series of boxplots per optimization strategy w.r.t. scaling strategy, where the boxplots represents the variability due to the 10 replicates. In this case, it seems that the :class:`.MDF` formulation is more expensive than the :class:`.IDF` one when the design space dimension increases while they seems to be the same when each design parameter has a size equal to 1. .. GENERATED FROM PYTHON SOURCE LINES 229-233 .. code-block:: default post = plot_scalability_results("study") post.labelize_scaling_strategy("Number of design parameters per type.") post.plot(xmargin=3.0, xticks=[1.0, 20.0], xticks_labels=["1", "20"], widths=1.0) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/scalable/images/sphx_glr_scalable_study_001.png :alt: scalable study :srcset: /examples/scalable/images/sphx_glr_scalable_study_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_scalable_study_002.png :alt: scalable study :srcset: /examples/scalable/images/sphx_glr_scalable_study_002.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_scalable_study_003.png :alt: scalable study :srcset: /examples/scalable/images/sphx_glr_scalable_study_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_scalable_study_004.png :alt: scalable study :srcset: /examples/scalable/images/sphx_glr_scalable_study_004.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_scalable_study_005.png :alt: scalable study :srcset: /examples/scalable/images/sphx_glr_scalable_study_005.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 16:57:53: Post-process for scalability study INFO - 16:57:53: Working directory: study INFO - 16:57:53: Save exec_time plot in study/visualization/scalability_study/exec_time.png INFO - 16:57:54: Save n_calls plot in study/visualization/scalability_study/n_calls.png INFO - 16:57:54: Save n_calls_linearize plot in study/visualization/scalability_study/n_calls_linearize.png INFO - 16:57:54: Save total_calls plot in study/visualization/scalability_study/total_calls.png INFO - 16:57:54: Save is_feasible plot in study/visualization/scalability_study/is_feasible.png INFO - 16:57:54: Execute post-processing INFO - 16:57:54: Type: replicate .. GENERATED FROM PYTHON SOURCE LINES 234-236 .. image:: /_images/scalable_example/exec_time-1.png .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 36.660 seconds) .. _sphx_glr_download_examples_scalable_scalable_study.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: scalable_study.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: scalable_study.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_