.. 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.mdo.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-46 .. code-block:: Python from __future__ import annotations from gemseo import execute_algo from gemseo import execute_post from gemseo import generate_n2_plot from gemseo.problems.mdo.scalable.parametric.core.scalable_discipline_settings import ( ScalableDisciplineSettings, ) from gemseo.problems.mdo.scalable.parametric.scalable_problem import ScalableProblem .. GENERATED FROM PYTHON SOURCE LINES 47-49 Instantiation of the scalable problem ------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 49-53 .. code-block:: Python problem = ScalableProblem( [ScalableDisciplineSettings(1, 2), ScalableDisciplineSettings(3, 4)], 1 ) .. GENERATED FROM PYTHON SOURCE LINES 54-56 Display the coupling structure ------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 56-58 .. code-block:: Python 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 59-61 Solve the MDO using an MDF formulation -------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 61-64 .. code-block:: Python scenario = problem.create_scenario() scenario.execute(algo_name="NLOPT_SLSQP", max_iter=100) .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 16:13:52: *** Start MDOScenario execution *** INFO - 16:13:52: MDOScenario INFO - 16:13:52: Disciplines: MainDiscipline ScalableDiscipline[1] ScalableDiscipline[2] INFO - 16:13:52: MDO formulation: MDF INFO - 16:13:52: Optimization problem: INFO - 16:13:52: minimize f(x_0, x_1, x_2) INFO - 16:13:52: with respect to x_0, x_1, x_2 INFO - 16:13:52: under the inequality constraints INFO - 16:13:52: c_1(x_0, x_1, x_2) <= 0 INFO - 16:13:52: c_2(x_0, x_1, x_2) <= 0 INFO - 16:13:52: over the design space: INFO - 16:13:52: +--------+-------------+-------+-------------+-------+ INFO - 16:13:52: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:13:52: +--------+-------------+-------+-------------+-------+ INFO - 16:13:52: | x_0 | 0 | 0.5 | 1 | float | INFO - 16:13:52: | x_1 | 0 | 0.5 | 1 | float | INFO - 16:13:52: | x_2[0] | 0 | 0.5 | 1 | float | INFO - 16:13:52: | x_2[1] | 0 | 0.5 | 1 | float | INFO - 16:13:52: | x_2[2] | 0 | 0.5 | 1 | float | INFO - 16:13:52: +--------+-------------+-------+-------------+-------+ INFO - 16:13:52: Solving optimization problem with algorithm NLOPT_SLSQP: INFO - 16:13:52: 1%| | 1/100 [00:00<00:03, 28.68 it/sec, feas=True, obj=3.07] INFO - 16:13:52: 2%|▏ | 2/100 [00:00<00:02, 33.47 it/sec, feas=True, obj=1.21] WARNING - 16:13:52: MDAJacobi has reached its maximum number of iterations, but the normalized residual norm 2.715139844193851e-06 is still above the tolerance 1e-06. INFO - 16:13:52: 3%|▎ | 3/100 [00:00<00:02, 34.45 it/sec, feas=True, obj=0.991] INFO - 16:13:52: 4%|▍ | 4/100 [00:00<00:02, 35.17 it/sec, feas=True, obj=0.986] INFO - 16:13:52: 5%|▌ | 5/100 [00:00<00:02, 35.49 it/sec, feas=True, obj=0.982] INFO - 16:13:52: 6%|▌ | 6/100 [00:00<00:02, 35.91 it/sec, feas=True, obj=0.971] INFO - 16:13:52: 7%|▋ | 7/100 [00:00<00:02, 36.11 it/sec, feas=True, obj=0.97] WARNING - 16:13:52: MDAJacobi has reached its maximum number of iterations, but the normalized residual norm 1.1427901207750206e-06 is still above the tolerance 1e-06. INFO - 16:13:52: 8%|▊ | 8/100 [00:00<00:02, 35.72 it/sec, feas=True, obj=0.969] WARNING - 16:13:52: MDAJacobi has reached its maximum number of iterations, but the normalized residual norm 1.1427840077519516e-06 is still above the tolerance 1e-06. INFO - 16:13:52: 9%|▉ | 9/100 [00:00<00:02, 35.65 it/sec, feas=True, obj=0.969] WARNING - 16:13:52: MDAJacobi has reached its maximum number of iterations, but the normalized residual norm 1.142784007344151e-06 is still above the tolerance 1e-06. INFO - 16:13:52: 10%|█ | 10/100 [00:00<00:02, 35.56 it/sec, feas=True, obj=0.969] WARNING - 16:13:52: MDAJacobi has reached its maximum number of iterations, but the normalized residual norm 1.142784007205571e-06 is still above the tolerance 1e-06. INFO - 16:13:52: 11%|█ | 11/100 [00:00<00:02, 35.63 it/sec, feas=True, obj=0.969] INFO - 16:13:52: Optimization result: INFO - 16:13:52: Optimizer info: INFO - 16:13:52: Status: None INFO - 16:13:52: Message: Successive iterates of the objective function are closer than ftol_rel or ftol_abs. GEMSEO stopped the driver. INFO - 16:13:52: Solution: INFO - 16:13:52: The solution is feasible. INFO - 16:13:52: Objective: 0.9692147822181952 INFO - 16:13:52: Standardized constraints: INFO - 16:13:52: c_1 = [-0.68663938 -0.21340355] INFO - 16:13:52: c_2 = [-7.31227901e-01 -1.68967318e-01 -2.32696422e-01 7.43849426e-15] INFO - 16:13:52: Design space: INFO - 16:13:52: +--------+-------------+--------------------+-------------+-------+ INFO - 16:13:52: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:13:52: +--------+-------------+--------------------+-------------+-------+ INFO - 16:13:52: | x_0 | 0 | 0.707133579730868 | 1 | float | INFO - 16:13:52: | x_1 | 0 | 1 | 1 | float | INFO - 16:13:52: | x_2[0] | 0 | 0 | 1 | float | INFO - 16:13:52: | x_2[1] | 0 | 0.5233182522437052 | 1 | float | INFO - 16:13:52: | x_2[2] | 0 | 0 | 1 | float | INFO - 16:13:52: +--------+-------------+--------------------+-------------+-------+ INFO - 16:13:52: *** End MDOScenario execution *** .. GENERATED FROM PYTHON SOURCE LINES 65-67 Post-process the results ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 67-69 .. code-block:: Python scenario.post_process(post_name="OptHistoryView", save=False, show=True) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_002.png :alt: Evolution of the optimization variables :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_002.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_003.png :alt: Evolution of the objective value :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_004.png :alt: Evolution of the distance to the optimum :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_004.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_005.png :alt: Evolution of the inequality constraints :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_005.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 70-72 Solve the associated quadratic programming problem -------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 72-75 .. code-block:: Python 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 - 16:13:53: Optimization problem: INFO - 16:13:53: minimize f = 0.5x'Qx + c'x + d INFO - 16:13:53: with respect to x INFO - 16:13:53: under the inequality constraints INFO - 16:13:53: g: Ax-b <= 0 <= 0.0 INFO - 16:13:53: over the design space: INFO - 16:13:53: +------+-------------+-------+-------------+-------+ INFO - 16:13:53: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:13:53: +------+-------------+-------+-------------+-------+ INFO - 16:13:53: | x[0] | 0 | 0.5 | 1 | float | INFO - 16:13:53: | x[1] | 0 | 0.5 | 1 | float | INFO - 16:13:53: | x[2] | 0 | 0.5 | 1 | float | INFO - 16:13:53: | x[3] | 0 | 0.5 | 1 | float | INFO - 16:13:53: | x[4] | 0 | 0.5 | 1 | float | INFO - 16:13:53: +------+-------------+-------+-------------+-------+ INFO - 16:13:53: Solving optimization problem with algorithm NLOPT_SLSQP: INFO - 16:13:53: 1%| | 1/100 [00:00<00:00, 730.46 it/sec, feas=True, obj=3.07] INFO - 16:13:53: 2%|▏ | 2/100 [00:00<00:00, 776.79 it/sec, feas=True, obj=1.21] INFO - 16:13:53: 3%|▎ | 3/100 [00:00<00:00, 818.13 it/sec, feas=True, obj=0.991] INFO - 16:13:53: 4%|▍ | 4/100 [00:00<00:00, 775.97 it/sec, feas=True, obj=0.986] INFO - 16:13:53: 5%|▌ | 5/100 [00:00<00:00, 760.22 it/sec, feas=True, obj=0.982] INFO - 16:13:53: 6%|▌ | 6/100 [00:00<00:00, 749.81 it/sec, feas=True, obj=0.971] INFO - 16:13:53: 7%|▋ | 7/100 [00:00<00:00, 741.10 it/sec, feas=True, obj=0.97] INFO - 16:13:53: 8%|▊ | 8/100 [00:00<00:00, 740.80 it/sec, feas=True, obj=0.969] INFO - 16:13:53: 9%|▉ | 9/100 [00:00<00:00, 734.11 it/sec, feas=True, obj=0.969] INFO - 16:13:53: 10%|█ | 10/100 [00:00<00:00, 732.50 it/sec, feas=True, obj=0.969] INFO - 16:13:53: Optimization result: INFO - 16:13:53: Optimizer info: INFO - 16:13:53: Status: None INFO - 16:13:53: Message: Successive iterates of the objective function are closer than ftol_rel or ftol_abs. GEMSEO stopped the driver. INFO - 16:13:53: Solution: INFO - 16:13:53: The solution is feasible. INFO - 16:13:53: Objective: 0.9692176254004927 INFO - 16:13:53: Standardized constraints: INFO - 16:13:53: g = [-6.86640980e-01 -2.13404451e-01 -7.31227677e-01 -1.68967471e-01 INFO - 16:13:53: -2.32695870e-01 3.99680289e-15] INFO - 16:13:53: Design space: INFO - 16:13:53: +------+-------------+-----------------------+-------------+-------+ INFO - 16:13:53: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:13:53: +------+-------------+-----------------------+-------------+-------+ INFO - 16:13:53: | x[0] | 0 | 0.7071348743877868 | 1 | float | INFO - 16:13:53: | x[1] | 0 | 0.9999999999999947 | 1 | float | INFO - 16:13:53: | x[2] | 0 | 1.977635923099697e-15 | 1 | float | INFO - 16:13:53: | x[3] | 0 | 0.5233180438726605 | 1 | float | INFO - 16:13:53: | x[4] | 0 | 6.731912661281726e-16 | 1 | float | INFO - 16:13:53: +------+-------------+-----------------------+-------------+-------+ .. raw:: html
Optimization result:
  • Design variables: [7.07134874e-01 1.00000000e+00 1.97763592e-15 5.23318044e-01 6.73191266e-16]
  • Objective function: 0.9692176254004927
  • Feasible solution: True


.. GENERATED FROM PYTHON SOURCE LINES 76-78 Post-process the results ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 78-79 .. code-block:: Python execute_post(problem, post_name="OptHistoryView", save=False, show=True) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_006.png :alt: Evolution of the optimization variables :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_006.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_007.png :alt: Evolution of the objective value :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 distance to the optimum :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: Evolution of the inequality constraints :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_009.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 1.957 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-jupyter :download:`Download Jupyter notebook: plot_scalable_param_mdf.ipynb ` .. 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-zip :download:`Download zipped: plot_scalable_param_mdf.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_