.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/scalable/plot_scalable_param_mdf.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_scalable_param_mdf.py: Parametric scalable MDO problem - MDF ===================================== We define a :class:`~.gemseo.problems.scalable.parametric.scalable_problem.ScalableProblem` with a shared design variable of size 1 and 2 strongly coupled disciplines. The first one has a local design variable of size 1 and a coupling variable of size 2 while the second one has a local design variable of size 3 and a coupling variable of size 4. We would like to solve this MDO problem by means of an MDF formulation. .. GENERATED FROM PYTHON SOURCE LINES 35-48 .. code-block:: default from __future__ import annotations from gemseo import configure_logger from gemseo import execute_algo from gemseo import execute_post from gemseo import generate_n2_plot from gemseo.problems.scalable.parametric.core.scalable_discipline_settings import ( ScalableDisciplineSettings, ) from gemseo.problems.scalable.parametric.scalable_problem import ScalableProblem configure_logger() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 49-51 Instantiation of the scalable problem ------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 51-55 .. code-block:: default problem = ScalableProblem( [ScalableDisciplineSettings(1, 2), ScalableDisciplineSettings(3, 4)], 1 ) .. GENERATED FROM PYTHON SOURCE LINES 56-58 Display the coupling structure ------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 58-60 .. code-block:: default generate_n2_plot(problem.disciplines, save=False, show=True) .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_001.png :alt: plot scalable param mdf :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 61-63 Solve the MDO using an MDF formulation -------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 63-66 .. code-block:: default scenario = problem.create_scenario() scenario.execute({"algo": "NLOPT_SLSQP", "max_iter": 100}) .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 08:23:54: INFO - 08:23:54: *** Start MDOScenario execution *** INFO - 08:23:54: MDOScenario INFO - 08:23:54: Disciplines: MainDiscipline ScalableDiscipline[1] ScalableDiscipline[2] INFO - 08:23:54: MDO formulation: MDF INFO - 08:23:54: Optimization problem: INFO - 08:23:54: minimize f(x_0, x_1, x_2) INFO - 08:23:54: with respect to x_0, x_1, x_2 INFO - 08:23:54: subject to constraints: INFO - 08:23:54: c_1(x_0, x_1, x_2) <= 0.0 INFO - 08:23:54: c_2(x_0, x_1, x_2) <= 0.0 INFO - 08:23:54: over the design space: INFO - 08:23:54: +--------+-------------+-------+-------------+-------+----------------------+ INFO - 08:23:54: | name | lower_bound | value | upper_bound | type | Initial distribution | INFO - 08:23:54: +--------+-------------+-------+-------------+-------+----------------------+ INFO - 08:23:54: | x_0 | 0 | 0.5 | 1 | float | | INFO - 08:23:54: | x_1 | 0 | 0.5 | 1 | float | | INFO - 08:23:54: | x_2[0] | 0 | 0.5 | 1 | float | | INFO - 08:23:54: | x_2[1] | 0 | 0.5 | 1 | float | | INFO - 08:23:54: | x_2[2] | 0 | 0.5 | 1 | float | | INFO - 08:23:54: +--------+-------------+-------+-------------+-------+----------------------+ INFO - 08:23:54: Solving optimization problem with algorithm NLOPT_SLSQP: INFO - 08:23:54: ... 0%| | 0/100 [00:00 .. GENERATED FROM PYTHON SOURCE LINES 72-74 Solve the associated quadratic programming problem -------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 74-77 .. code-block:: default problem = problem.create_quadratic_programming_problem() execute_algo(problem, algo_name="NLOPT_SLSQP", max_iter=100) .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 08:23:56: Optimization problem: INFO - 08:23:56: minimize f = 0.5x'Qx + c'x + d INFO - 08:23:56: with respect to x INFO - 08:23:56: subject to constraints: INFO - 08:23:56: g: Ax-b <= 0 <= 0.0 INFO - 08:23:56: over the design space: INFO - 08:23:56: +------+-------------+-------+-------------+-------+ INFO - 08:23:56: | name | lower_bound | value | upper_bound | type | INFO - 08:23:56: +------+-------------+-------+-------------+-------+ INFO - 08:23:56: | x[0] | 0 | 0.5 | 1 | float | INFO - 08:23:56: | x[1] | 0 | 0.5 | 1 | float | INFO - 08:23:56: | x[2] | 0 | 0.5 | 1 | float | INFO - 08:23:56: | x[3] | 0 | 0.5 | 1 | float | INFO - 08:23:56: | x[4] | 0 | 0.5 | 1 | float | INFO - 08:23:56: +------+-------------+-------+-------------+-------+ INFO - 08:23:56: Solving optimization problem with algorithm NLOPT_SLSQP: INFO - 08:23:56: ... 0%| | 0/100 [00:00
Optimization result:
  • Design variables: [0.48363276 1. 0.08671678 0.90853579 0.2480177 ]
  • Objective function: 0.414721553468123
  • Feasible solution: True


.. GENERATED FROM PYTHON SOURCE LINES 78-80 Post-process the results ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 80-81 .. code-block:: default execute_post(problem, "OptHistoryView", save=False, show=True) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_007.png :alt: Evolution of the optimization variables :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_007.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_008.png :alt: Evolution of the objective value :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_008.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_009.png :alt: Distance to the optimum :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_009.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_010.png :alt: Hessian diagonal approximation :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_010.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_011.png :alt: Evolution of the inequality constraints :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_011.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.621 seconds) .. _sphx_glr_download_examples_scalable_plot_scalable_param_mdf.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_scalable_param_mdf.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_scalable_param_mdf.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_