Note
Go to the end to download the full example code.
Parametric scalable MDO problem - MDF#
We define
a 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.
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.mdo.scalable.parametric.core.scalable_discipline_settings import (
ScalableDisciplineSettings,
)
from gemseo.problems.mdo.scalable.parametric.scalable_problem import ScalableProblem
configure_logger()
<RootLogger root (INFO)>
Instantiation of the scalable problem#
problem = ScalableProblem(
[ScalableDisciplineSettings(1, 2), ScalableDisciplineSettings(3, 4)], 1
)
Display the coupling structure#
generate_n2_plot(problem.disciplines, save=False, show=True)

Solve the MDO using an MDF formulation#
scenario = problem.create_scenario()
scenario.execute(algo_name="NLOPT_SLSQP", max_iter=100)
INFO - 20:34:28: *** Start MDOScenario execution ***
INFO - 20:34:28: MDOScenario
INFO - 20:34:28: Disciplines: MainDiscipline ScalableDiscipline[1] ScalableDiscipline[2]
INFO - 20:34:28: MDO formulation: MDF
INFO - 20:34:28: Optimization problem:
INFO - 20:34:28: minimize f(x_0, x_1, x_2)
INFO - 20:34:28: with respect to x_0, x_1, x_2
INFO - 20:34:28: under the inequality constraints
INFO - 20:34:28: c_1(x_0, x_1, x_2) <= 0
INFO - 20:34:28: c_2(x_0, x_1, x_2) <= 0
INFO - 20:34:28: over the design space:
INFO - 20:34:28: +--------+-------------+-------+-------------+-------+
INFO - 20:34:28: | Name | Lower bound | Value | Upper bound | Type |
INFO - 20:34:28: +--------+-------------+-------+-------------+-------+
INFO - 20:34:28: | x_0 | 0 | 0.5 | 1 | float |
INFO - 20:34:28: | x_1 | 0 | 0.5 | 1 | float |
INFO - 20:34:28: | x_2[0] | 0 | 0.5 | 1 | float |
INFO - 20:34:28: | x_2[1] | 0 | 0.5 | 1 | float |
INFO - 20:34:28: | x_2[2] | 0 | 0.5 | 1 | float |
INFO - 20:34:28: +--------+-------------+-------+-------------+-------+
INFO - 20:34:28: Solving optimization problem with algorithm NLOPT_SLSQP:
INFO - 20:34:28: 1%| | 1/100 [00:00<00:01, 56.07 it/sec, obj=3.07]
WARNING - 20:34:28: MDAJacobi has reached its maximum number of iterations, but the normalized residual norm 2.7151398445206794e-06 is still above the tolerance 1e-06.
INFO - 20:34:28: 2%|▏ | 2/100 [00:00<00:03, 31.66 it/sec, obj=1.21]
INFO - 20:34:29: 3%|▎ | 3/100 [00:00<00:02, 37.26 it/sec, obj=0.991]
INFO - 20:34:29: 4%|▍ | 4/100 [00:00<00:02, 40.99 it/sec, obj=0.986]
INFO - 20:34:29: 5%|▌ | 5/100 [00:00<00:02, 43.39 it/sec, obj=0.982]
INFO - 20:34:29: 6%|▌ | 6/100 [00:00<00:02, 45.06 it/sec, obj=0.971]
WARNING - 20:34:29: MDAJacobi has reached its maximum number of iterations, but the normalized residual norm 1.1427901203368072e-06 is still above the tolerance 1e-06.
INFO - 20:34:29: 7%|▋ | 7/100 [00:00<00:02, 46.24 it/sec, obj=0.97]
WARNING - 20:34:29: MDAJacobi has reached its maximum number of iterations, but the normalized residual norm 1.1427840078240745e-06 is still above the tolerance 1e-06.
INFO - 20:34:29: 8%|▊ | 8/100 [00:00<00:01, 47.11 it/sec, obj=0.969]
WARNING - 20:34:29: MDAJacobi has reached its maximum number of iterations, but the normalized residual norm 1.1427840073629847e-06 is still above the tolerance 1e-06.
INFO - 20:34:29: 9%|▉ | 9/100 [00:00<00:01, 48.08 it/sec, obj=0.969]
WARNING - 20:34:29: MDAJacobi has reached its maximum number of iterations, but the normalized residual norm 1.1427840071115847e-06 is still above the tolerance 1e-06.
INFO - 20:34:29: 10%|█ | 10/100 [00:00<00:01, 48.89 it/sec, obj=0.969]
INFO - 20:34:29: 11%|█ | 11/100 [00:00<00:01, 53.55 it/sec, obj=Not evaluated]
INFO - 20:34:29: Optimization result:
INFO - 20:34:29: Optimizer info:
INFO - 20:34:29: Status: None
INFO - 20:34:29: Message: Successive iterates of the design variables are closer than xtol_rel or xtol_abs. GEMSEO stopped the driver.
INFO - 20:34:29: Number of calls to the objective function by the optimizer: 0
INFO - 20:34:29: Solution:
INFO - 20:34:29: The solution is feasible.
INFO - 20:34:29: Objective: 0.9692147822181947
INFO - 20:34:29: Standardized constraints:
INFO - 20:34:29: c_1 = [-0.68663938 -0.21340355]
INFO - 20:34:29: c_2 = [-7.31227901e-01 -1.68967318e-01 -2.32696422e-01 7.82707232e-15]
INFO - 20:34:29: Design space:
INFO - 20:34:29: +--------+-------------+--------------------+-------------+-------+
INFO - 20:34:29: | Name | Lower bound | Value | Upper bound | Type |
INFO - 20:34:29: +--------+-------------+--------------------+-------------+-------+
INFO - 20:34:29: | x_0 | 0 | 0.7071335797308679 | 1 | float |
INFO - 20:34:29: | x_1 | 0 | 1 | 1 | float |
INFO - 20:34:29: | x_2[0] | 0 | 0 | 1 | float |
INFO - 20:34:29: | x_2[1] | 0 | 0.5233182522437052 | 1 | float |
INFO - 20:34:29: | x_2[2] | 0 | 0 | 1 | float |
INFO - 20:34:29: +--------+-------------+--------------------+-------------+-------+
INFO - 20:34:29: *** End MDOScenario execution ***
Post-process the results#
scenario.post_process(post_name="OptHistoryView", save=False, show=True)
<gemseo.post.opt_history_view.OptHistoryView object at 0x78592f9720f0>
Solve the associated quadratic programming problem#
problem = problem.create_quadratic_programming_problem()
execute_algo(problem, algo_name="NLOPT_SLSQP", max_iter=100)
INFO - 20:34:29: Optimization problem:
INFO - 20:34:29: minimize f = 0.5x'Qx + c'x + d
INFO - 20:34:29: with respect to x
INFO - 20:34:29: under the inequality constraints
INFO - 20:34:29: g: Ax-b <= 0 <= 0.0
INFO - 20:34:29: over the design space:
INFO - 20:34:29: +------+-------------+-------+-------------+-------+
INFO - 20:34:29: | Name | Lower bound | Value | Upper bound | Type |
INFO - 20:34:29: +------+-------------+-------+-------------+-------+
INFO - 20:34:29: | x[0] | 0 | 0.5 | 1 | float |
INFO - 20:34:29: | x[1] | 0 | 0.5 | 1 | float |
INFO - 20:34:29: | x[2] | 0 | 0.5 | 1 | float |
INFO - 20:34:29: | x[3] | 0 | 0.5 | 1 | float |
INFO - 20:34:29: | x[4] | 0 | 0.5 | 1 | float |
INFO - 20:34:29: +------+-------------+-------+-------------+-------+
INFO - 20:34:29: Solving optimization problem with algorithm NLOPT_SLSQP:
INFO - 20:34:29: 1%| | 1/100 [00:00<00:00, 3398.95 it/sec, obj=3.07]
INFO - 20:34:29: 2%|▏ | 2/100 [00:00<00:00, 1217.15 it/sec, obj=1.21]
INFO - 20:34:29: 3%|▎ | 3/100 [00:00<00:00, 1220.69 it/sec, obj=0.991]
INFO - 20:34:29: 4%|▍ | 4/100 [00:00<00:00, 1241.01 it/sec, obj=0.986]
INFO - 20:34:29: 5%|▌ | 5/100 [00:00<00:00, 1266.47 it/sec, obj=0.982]
INFO - 20:34:29: 6%|▌ | 6/100 [00:00<00:00, 1274.09 it/sec, obj=0.971]
INFO - 20:34:29: 7%|▋ | 7/100 [00:00<00:00, 1281.77 it/sec, obj=0.97]
ERROR - 20:34:29: NLopt run failed: NLopt roundoff-limited, RoundoffLimited
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/6.2.0/lib/python3.12/site-packages/gemseo/algos/opt/nlopt/nlopt.py", line 403, in _run
nlopt_problem.optimize(x_0.real)
File "/home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/6.2.0/lib/python3.12/site-packages/nlopt/nlopt.py", line 454, in optimize
return _nlopt.opt_optimize(self, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nlopt.RoundoffLimited: NLopt roundoff-limited
INFO - 20:34:29: 8%|▊ | 8/100 [00:00<00:00, 1114.77 it/sec, obj=0.969]
INFO - 20:34:29: Optimization result:
INFO - 20:34:29: Optimizer info:
INFO - 20:34:29: Status: None
INFO - 20:34:29: Message: GEMSEO stopped the driver.
INFO - 20:34:29: Number of calls to the objective function by the optimizer: 0
INFO - 20:34:29: Solution:
INFO - 20:34:29: The solution is feasible.
INFO - 20:34:29: Objective: 0.9692176254005034
INFO - 20:34:29: Standardized constraints:
INFO - 20:34:29: g = [-6.86640980e-01 -2.13404451e-01 -7.31227677e-01 -1.68967471e-01
INFO - 20:34:29: -2.32695870e-01 -2.22044605e-15]
INFO - 20:34:29: Design space:
INFO - 20:34:29: +------+-------------+--------------------+-------------+-------+
INFO - 20:34:29: | Name | Lower bound | Value | Upper bound | Type |
INFO - 20:34:29: +------+-------------+--------------------+-------------+-------+
INFO - 20:34:29: | x[0] | 0 | 0.7071348743877915 | 1 | float |
INFO - 20:34:29: | x[1] | 0 | 1 | 1 | float |
INFO - 20:34:29: | x[2] | 0 | 0 | 1 | float |
INFO - 20:34:29: | x[3] | 0 | 0.5233180438726639 | 1 | float |
INFO - 20:34:29: | x[4] | 0 | 0 | 1 | float |
INFO - 20:34:29: +------+-------------+--------------------+-------------+-------+
Post-process the results#
execute_post(problem, post_name="OptHistoryView", save=False, show=True)
<gemseo.post.opt_history_view.OptHistoryView object at 0x7859177a0cb0>
Total running time of the script: (0 minutes 1.599 seconds)







