.. 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-42 .. code-block:: default 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 Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 43-47 Create the disciplinary datasets -------------------------------- First of all, we create the disciplinary :class:`.Dataset` datasets based on a :class:`.DiagonalDOE`. .. GENERATED FROM PYTHON SOURCE LINES 47-67 .. 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 Out: .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/4.0.1/lib/python3.9/site-packages/gemseo/algos/design_space.py:448: ComplexWarning: Casting complex values to real discards the imaginary part self.__current_value[name] = array_value.astype( INFO - 10:04:37: INFO - 10:04:37: *** Start DOEScenario execution *** INFO - 10:04:37: DOEScenario INFO - 10:04:37: Disciplines: Aerodynamics INFO - 10:04:37: MDO formulation: DisciplinaryOpt INFO - 10:04:37: Optimization problem: INFO - 10:04:37: minimize drag(thick_airfoils, sweep, displ) INFO - 10:04:37: with respect to displ, sweep, thick_airfoils INFO - 10:04:37: over the design space: INFO - 10:04:37: +----------------+-------------+-------+-------------+-------+ INFO - 10:04:37: | name | lower_bound | value | upper_bound | type | INFO - 10:04:37: +----------------+-------------+-------+-------------+-------+ INFO - 10:04:37: | thick_airfoils | 5 | 15 | 25 | float | INFO - 10:04:37: | sweep | 10 | 25 | 35 | float | INFO - 10:04:37: | displ | -1000 | -700 | 1000 | float | INFO - 10:04:37: +----------------+-------------+-------+-------------+-------+ INFO - 10:04:37: Solving optimization problem with algorithm DiagonalDOE: INFO - 10:04:37: ... 0%| | 0/10 [00:00, , , , , , , ] .. GENERATED FROM PYTHON SOURCE LINES 158-174 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 176-213 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 215-227 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 227-231 .. 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 Out: .. code-block:: none INFO - 10:05:14: Post-process for scalability study INFO - 10:05:14: Working directory: study INFO - 10:05:14: Save exec_time plot in study/visualization/scalability_study/exec_time.png INFO - 10:05:14: Save n_calls plot in study/visualization/scalability_study/n_calls.png INFO - 10:05:15: Save n_calls_linearize plot in study/visualization/scalability_study/n_calls_linearize.png INFO - 10:05:15: Save total_calls plot in study/visualization/scalability_study/total_calls.png INFO - 10:05:15: Save is_feasible plot in study/visualization/scalability_study/is_feasible.png INFO - 10:05:15: Execute post-processing INFO - 10:05:15: Type: replicate .. GENERATED FROM PYTHON SOURCE LINES 232-234 .. image:: /_images/scalable_example/exec_time-1.png .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 38.518 seconds) .. _sphx_glr_download_examples_scalable_scalable_study.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: 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 `_