.. 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-49 .. code-block:: Python 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 50-52 Instantiation of the scalable problem ------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 52-56 .. code-block:: Python problem = ScalableProblem( [ScalableDisciplineSettings(1, 2), ScalableDisciplineSettings(3, 4)], 1 ) .. GENERATED FROM PYTHON SOURCE LINES 57-59 Display the coupling structure ------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 59-61 .. 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 62-64 Solve the MDO using an MDF formulation -------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 64-67 .. code-block:: Python scenario = problem.create_scenario() scenario.execute({"algo": "NLOPT_SLSQP", "max_iter": 100}) .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 00:11:21: INFO - 00:11:21: *** Start MDOScenario execution *** INFO - 00:11:21: MDOScenario INFO - 00:11:21: Disciplines: MainDiscipline ScalableDiscipline[1] ScalableDiscipline[2] INFO - 00:11:21: MDO formulation: MDF INFO - 00:11:21: Optimization problem: INFO - 00:11:21: minimize f(x_0, x_1, x_2) INFO - 00:11:21: with respect to x_0, x_1, x_2 INFO - 00:11:21: subject to constraints: INFO - 00:11:21: c_1(x_0, x_1, x_2) <= 0.0 INFO - 00:11:21: c_2(x_0, x_1, x_2) <= 0.0 INFO - 00:11:21: over the design space: INFO - 00:11:21: +--------+-------------+-------+-------------+-------+ INFO - 00:11:21: | Name | Lower bound | Value | Upper bound | Type | INFO - 00:11:21: +--------+-------------+-------+-------------+-------+ INFO - 00:11:21: | x_0 | 0 | 0.5 | 1 | float | INFO - 00:11:21: | x_1 | 0 | 0.5 | 1 | float | INFO - 00:11:21: | x_2[0] | 0 | 0.5 | 1 | float | INFO - 00:11:21: | x_2[1] | 0 | 0.5 | 1 | float | INFO - 00:11:21: | x_2[2] | 0 | 0.5 | 1 | float | INFO - 00:11:21: +--------+-------------+-------+-------------+-------+ INFO - 00:11:21: Solving optimization problem with algorithm NLOPT_SLSQP: INFO - 00:11:21: 1%| | 1/100 [00:00<00:05, 19.14 it/sec, obj=3.07] WARNING - 00:11:21: MDAJacobi has reached its maximum number of iterations but the normed residual 2.1168696144554684e-06 is still above the tolerance 1e-06. INFO - 00:11:21: 2%|▏ | 2/100 [00:00<00:12, 7.67 it/sec, obj=1.21] INFO - 00:11:21: 3%|▎ | 3/100 [00:00<00:11, 8.81 it/sec, obj=0.991] INFO - 00:11:21: 4%|▍ | 4/100 [00:00<00:10, 9.56 it/sec, obj=0.986] INFO - 00:11:22: 5%|▌ | 5/100 [00:00<00:09, 10.03 it/sec, obj=0.982] INFO - 00:11:22: 6%|▌ | 6/100 [00:00<00:09, 10.38 it/sec, obj=0.971] INFO - 00:11:22: 7%|▋ | 7/100 [00:00<00:08, 10.64 it/sec, obj=0.97] INFO - 00:11:22: 8%|▊ | 8/100 [00:00<00:08, 10.86 it/sec, obj=0.969] INFO - 00:11:22: 9%|▉ | 9/100 [00:00<00:08, 11.03 it/sec, obj=0.969] INFO - 00:11:22: 10%|█ | 10/100 [00:00<00:08, 11.17 it/sec, obj=0.969] INFO - 00:11:22: 11%|█ | 11/100 [00:00<00:07, 12.27 it/sec, obj=Not evaluated] INFO - 00:11:22: Optimization result: INFO - 00:11:22: Optimizer info: INFO - 00:11:22: Status: None INFO - 00:11:22: Message: Successive iterates of the design variables are closer than xtol_rel or xtol_abs. GEMSEO Stopped the driver INFO - 00:11:22: Number of calls to the objective function by the optimizer: 11 INFO - 00:11:22: Solution: INFO - 00:11:22: The solution is feasible. INFO - 00:11:22: Objective: 0.9692177673322224 INFO - 00:11:22: Standardized constraints: INFO - 00:11:22: c_1 = [-0.68664086 -0.21340455] INFO - 00:11:22: c_2 = [-7.31227816e-01 -1.68967484e-01 -2.32695971e-01 1.19487753e-12] INFO - 00:11:22: Design space: INFO - 00:11:22: +--------+-------------+-----------------------+-------------+-------+ INFO - 00:11:22: | Name | Lower bound | Value | Upper bound | Type | INFO - 00:11:22: +--------+-------------+-----------------------+-------------+-------+ INFO - 00:11:22: | x_0 | 0 | 0.7071349698120538 | 1 | float | INFO - 00:11:22: | x_1 | 0 | 0.9999999999999997 | 1 | float | INFO - 00:11:22: | x_2[0] | 0 | 2.906542539477308e-16 | 1 | float | INFO - 00:11:22: | x_2[1] | 0 | 0.5233175560073929 | 1 | float | INFO - 00:11:22: | x_2[2] | 0 | 6.286235338479938e-31 | 1 | float | INFO - 00:11:22: +--------+-------------+-----------------------+-------------+-------+ INFO - 00:11:22: *** End MDOScenario execution (time: 0:00:00.913104) *** {'max_iter': 100, 'algo': 'NLOPT_SLSQP'} .. GENERATED FROM PYTHON SOURCE LINES 68-70 Post-process the results ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 70-72 .. code-block:: Python scenario.post_process("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: 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: Hessian diagonal approximation :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_005.png :class: sphx-glr-multi-img * .. image-sg:: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_006.png :alt: Evolution of the inequality constraints :srcset: /examples/scalable/images/sphx_glr_plot_scalable_param_mdf_006.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 73-75 Solve the associated quadratic programming problem -------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 75-78 .. 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 - 00:11:23: Optimization problem: INFO - 00:11:23: minimize f = 0.5x'Qx + c'x + d INFO - 00:11:23: with respect to x INFO - 00:11:23: subject to constraints: INFO - 00:11:23: g: Ax-b <= 0 <= 0.0 INFO - 00:11:23: over the design space: INFO - 00:11:23: +------+-------------+-------+-------------+-------+ INFO - 00:11:23: | Name | Lower bound | Value | Upper bound | Type | INFO - 00:11:23: +------+-------------+-------+-------------+-------+ INFO - 00:11:23: | x[0] | 0 | 0.5 | 1 | float | INFO - 00:11:23: | x[1] | 0 | 0.5 | 1 | float | INFO - 00:11:23: | x[2] | 0 | 0.5 | 1 | float | INFO - 00:11:23: | x[3] | 0 | 0.5 | 1 | float | INFO - 00:11:23: | x[4] | 0 | 0.5 | 1 | float | INFO - 00:11:23: +------+-------------+-------+-------------+-------+ INFO - 00:11:23: Solving optimization problem with algorithm NLOPT_SLSQP: INFO - 00:11:23: 1%| | 1/100 [00:00<00:00, 1970.08 it/sec, obj=3.07] INFO - 00:11:23: 2%|▏ | 2/100 [00:00<00:00, 598.67 it/sec, obj=1.21] INFO - 00:11:23: 3%|▎ | 3/100 [00:00<00:00, 588.12 it/sec, obj=0.991] INFO - 00:11:23: 4%|▍ | 4/100 [00:00<00:00, 587.19 it/sec, obj=0.986] INFO - 00:11:23: 5%|▌ | 5/100 [00:00<00:00, 588.69 it/sec, obj=0.982] INFO - 00:11:23: 6%|▌ | 6/100 [00:00<00:00, 589.96 it/sec, obj=0.971] INFO - 00:11:23: 7%|▋ | 7/100 [00:00<00:00, 592.05 it/sec, obj=0.97] ERROR - 00:11:23: NLopt run failed: NLopt roundoff-limited, RoundoffLimited Traceback (most recent call last): File "/home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/develop/lib/python3.9/site-packages/gemseo/algos/opt/lib_nlopt.py", line 498, in _run nlopt_problem.optimize(x_0.real) File "/home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/develop/lib/python3.9/site-packages/nlopt/nlopt.py", line 335, in optimize return _nlopt.opt_optimize(self, *args) nlopt.RoundoffLimited: NLopt roundoff-limited INFO - 00:11:23: 8%|▊ | 8/100 [00:00<00:00, 565.93 it/sec, obj=0.969] INFO - 00:11:23: Optimization result: INFO - 00:11:23: Optimizer info: INFO - 00:11:23: Status: None INFO - 00:11:23: Message: GEMSEO Stopped the driver INFO - 00:11:23: Number of calls to the objective function by the optimizer: 9 INFO - 00:11:23: Solution: INFO - 00:11:23: The solution is feasible. INFO - 00:11:23: Objective: 0.9692176254005034 INFO - 00:11:23: Standardized constraints: INFO - 00:11:23: g = [-6.86640980e-01 -2.13404451e-01 -7.31227677e-01 -1.68967471e-01 INFO - 00:11:23: -2.32695870e-01 -2.22044605e-15] INFO - 00:11:23: Design space: INFO - 00:11:23: +------+-------------+--------------------+-------------+-------+ INFO - 00:11:23: | Name | Lower bound | Value | Upper bound | Type | INFO - 00:11:23: +------+-------------+--------------------+-------------+-------+ INFO - 00:11:23: | x[0] | 0 | 0.7071348743877915 | 1 | float | INFO - 00:11:23: | x[1] | 0 | 1 | 1 | float | INFO - 00:11:23: | x[2] | 0 | 0 | 1 | float | INFO - 00:11:23: | x[3] | 0 | 0.5233180438726639 | 1 | float | INFO - 00:11:23: | x[4] | 0 | 0 | 1 | float | INFO - 00:11:23: +------+-------------+--------------------+-------------+-------+ .. raw:: html
Optimization result:
  • Design variables: [0.70713487 1. 0. 0.52331804 0. ]
  • Objective function: 0.9692176254005034
  • Feasible solution: True


.. GENERATED FROM PYTHON SOURCE LINES 79-81 Post-process the results ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 81-82 .. code-block:: Python 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.834 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 ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_