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.scalable.parametric.core.scalable_discipline_settings import (
ScalableDisciplineSettings,
)
from gemseo.problems.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": "NLOPT_SLSQP", "max_iter": 100})
INFO - 15:35:54:
INFO - 15:35:54: *** Start MDOScenario execution ***
INFO - 15:35:54: MDOScenario
INFO - 15:35:54: Disciplines: MainDiscipline ScalableDiscipline[1] ScalableDiscipline[2]
INFO - 15:35:54: MDO formulation: MDF
INFO - 15:35:54: Optimization problem:
INFO - 15:35:54: minimize f(x_0, x_1, x_2)
INFO - 15:35:54: with respect to x_0, x_1, x_2
INFO - 15:35:54: subject to constraints:
INFO - 15:35:54: c_1(x_0, x_1, x_2) <= 0.0
INFO - 15:35:54: c_2(x_0, x_1, x_2) <= 0.0
INFO - 15:35:54: over the design space:
INFO - 15:35:54: +--------+-------------+-------+-------------+-------+----------------------+
INFO - 15:35:54: | name | lower_bound | value | upper_bound | type | Initial distribution |
INFO - 15:35:54: +--------+-------------+-------+-------------+-------+----------------------+
INFO - 15:35:54: | x_0 | 0 | 0.5 | 1 | float | |
INFO - 15:35:54: | x_1 | 0 | 0.5 | 1 | float | |
INFO - 15:35:54: | x_2[0] | 0 | 0.5 | 1 | float | |
INFO - 15:35:54: | x_2[1] | 0 | 0.5 | 1 | float | |
INFO - 15:35:54: | x_2[2] | 0 | 0.5 | 1 | float | |
INFO - 15:35:54: +--------+-------------+-------+-------------+-------+----------------------+
INFO - 15:35:54: Solving optimization problem with algorithm NLOPT_SLSQP:
INFO - 15:35:54: ... 0%| | 0/100 [00:00<?, ?it]
INFO - 15:35:54: ... 1%| | 1/100 [00:00<00:04, 22.70 it/sec, obj=1]
INFO - 15:35:54: ... 2%|▏ | 2/100 [00:00<00:09, 10.77 it/sec, obj=0.921]
INFO - 15:35:54: ... 3%|▎ | 3/100 [00:00<00:06, 16.12 it/sec, obj=0.513]
INFO - 15:35:54: ... 4%|▍ | 4/100 [00:00<00:08, 10.87 it/sec, obj=0.438]
INFO - 15:35:54: ... 5%|▌ | 5/100 [00:00<00:08, 11.42 it/sec, obj=0.418]
INFO - 15:35:54: ... 6%|▌ | 6/100 [00:00<00:07, 11.81 it/sec, obj=0.416]
INFO - 15:35:54: ... 7%|▋ | 7/100 [00:00<00:07, 12.15 it/sec, obj=0.415]
INFO - 15:35:54: ... 8%|▊ | 8/100 [00:00<00:07, 12.46 it/sec, obj=0.415]
INFO - 15:35:54: ... 9%|▉ | 9/100 [00:00<00:07, 12.68 it/sec, obj=0.415]
INFO - 15:35:54: ... 10%|█ | 10/100 [00:00<00:06, 12.86 it/sec, obj=0.415]
INFO - 15:35:55: ... 11%|█ | 11/100 [00:00<00:06, 13.01 it/sec, obj=0.415]
INFO - 15:35:55: ... 12%|█▏ | 12/100 [00:00<00:06, 13.79 it/sec, obj=0.415]
INFO - 15:35:55: ... 13%|█▎ | 13/100 [00:00<00:05, 14.93 it/sec, obj=0.415]
INFO - 15:35:55: Optimization result:
INFO - 15:35:55: Optimizer info:
INFO - 15:35:55: Status: None
INFO - 15:35:55: Message: Successive iterates of the objective function are closer than ftol_rel or ftol_abs. GEMSEO Stopped the driver
INFO - 15:35:55: Number of calls to the objective function by the optimizer: 15
INFO - 15:35:55: Solution:
INFO - 15:35:55: The solution is feasible.
INFO - 15:35:55: Objective: 0.4147215357836146
INFO - 15:35:55: Standardized constraints:
INFO - 15:35:55: c_1 = [-0.32430628 -0.43254422]
INFO - 15:35:55: c_2 = [ 9.31144051e-13 -2.51296986e-01 -2.35380042e-01 -4.99967955e-01]
INFO - 15:35:55: Scalable design space:
INFO - 15:35:55: +--------+-------------+---------------------+-------------+-------+----------------------+
INFO - 15:35:55: | name | lower_bound | value | upper_bound | type | Initial distribution |
INFO - 15:35:55: +--------+-------------+---------------------+-------------+-------+----------------------+
INFO - 15:35:55: | x_0 | 0 | 0.4836327506555587 | 1 | float | |
INFO - 15:35:55: | x_1 | 0 | 1 | 1 | float | |
INFO - 15:35:55: | x_2[0] | 0 | 0.08671670660039867 | 1 | float | |
INFO - 15:35:55: | x_2[1] | 0 | 0.9085357960727601 | 1 | float | |
INFO - 15:35:55: | x_2[2] | 0 | 0.2480176667988829 | 1 | float | |
INFO - 15:35:55: +--------+-------------+---------------------+-------------+-------+----------------------+
INFO - 15:35:55: *** End MDOScenario execution (time: 0:00:00.887755) ***
{'max_iter': 100, 'algo': 'NLOPT_SLSQP'}
Post-process the results¶
scenario.post_process("OptHistoryView", save=False, show=True)
<gemseo.post.opt_history_view.OptHistoryView object at 0x7fcc220a9d00>
Solve the associated quadratic programming problem¶
problem = problem.create_quadratic_programming_problem()
execute_algo(problem, algo_name="NLOPT_SLSQP", max_iter=100)
INFO - 15:35:56: Optimization problem:
INFO - 15:35:56: minimize f = 0.5x'Qx + c'x + d
INFO - 15:35:56: with respect to x
INFO - 15:35:56: subject to constraints:
INFO - 15:35:56: g: Ax-b <= 0 <= 0.0
INFO - 15:35:56: over the design space:
INFO - 15:35:56: +------+-------------+-------+-------------+-------+
INFO - 15:35:56: | name | lower_bound | value | upper_bound | type |
INFO - 15:35:56: +------+-------------+-------+-------------+-------+
INFO - 15:35:56: | x[0] | 0 | 0.5 | 1 | float |
INFO - 15:35:56: | x[1] | 0 | 0.5 | 1 | float |
INFO - 15:35:56: | x[2] | 0 | 0.5 | 1 | float |
INFO - 15:35:56: | x[3] | 0 | 0.5 | 1 | float |
INFO - 15:35:56: | x[4] | 0 | 0.5 | 1 | float |
INFO - 15:35:56: +------+-------------+-------+-------------+-------+
INFO - 15:35:56: Solving optimization problem with algorithm NLOPT_SLSQP:
INFO - 15:35:56: ... 0%| | 0/100 [00:00<?, ?it]
INFO - 15:35:56: ... 1%| | 1/100 [00:00<00:00, 2096.10 it/sec, obj=1]
INFO - 15:35:56: ... 2%|▏ | 2/100 [00:00<00:00, 559.80 it/sec, obj=0.921]
INFO - 15:35:56: ... 3%|▎ | 3/100 [00:00<00:00, 780.05 it/sec, obj=0.513]
INFO - 15:35:56: ... 4%|▍ | 4/100 [00:00<00:00, 516.35 it/sec, obj=0.438]
INFO - 15:35:56: ... 5%|▌ | 5/100 [00:00<00:00, 523.86 it/sec, obj=0.418]
INFO - 15:35:56: ... 6%|▌ | 6/100 [00:00<00:00, 526.61 it/sec, obj=0.416]
INFO - 15:35:56: ... 7%|▋ | 7/100 [00:00<00:00, 531.15 it/sec, obj=0.415]
INFO - 15:35:56: ... 8%|▊ | 8/100 [00:00<00:00, 533.24 it/sec, obj=0.415]
INFO - 15:35:56: ... 9%|▉ | 9/100 [00:00<00:00, 535.75 it/sec, obj=0.415]
INFO - 15:35:56: ... 10%|█ | 10/100 [00:00<00:00, 538.28 it/sec, obj=0.415]
INFO - 15:35:56: ... 11%|█ | 11/100 [00:00<00:00, 538.86 it/sec, obj=0.415]
INFO - 15:35:56: ... 12%|█▏ | 12/100 [00:00<00:00, 541.21 it/sec, obj=0.415]
INFO - 15:35:56: ... 13%|█▎ | 13/100 [00:00<00:00, 579.59 it/sec, obj=0.415]
INFO - 15:35:56: Optimization result:
INFO - 15:35:56: Optimizer info:
INFO - 15:35:56: Status: None
INFO - 15:35:56: Message: Successive iterates of the objective function are closer than ftol_rel or ftol_abs. GEMSEO Stopped the driver
INFO - 15:35:56: Number of calls to the objective function by the optimizer: 15
INFO - 15:35:56: Solution:
INFO - 15:35:56: The solution is feasible.
INFO - 15:35:56: Objective: 0.414721553468123
INFO - 15:35:56: Standardized constraints:
INFO - 15:35:56: g = [-3.24306238e-01 -4.32544172e-01 -4.44089210e-16 -2.51297007e-01
INFO - 15:35:56: -2.35380057e-01 -4.99968031e-01]
INFO - 15:35:56: Design space:
INFO - 15:35:56: +------+-------------+---------------------+-------------+-------+
INFO - 15:35:56: | name | lower_bound | value | upper_bound | type |
INFO - 15:35:56: +------+-------------+---------------------+-------------+-------+
INFO - 15:35:56: | x[0] | 0 | 0.4836327595359132 | 1 | float |
INFO - 15:35:56: | x[1] | 0 | 0.9999999999999998 | 1 | float |
INFO - 15:35:56: | x[2] | 0 | 0.08671677713547089 | 1 | float |
INFO - 15:35:56: | x[3] | 0 | 0.9085357909356101 | 1 | float |
INFO - 15:35:56: | x[4] | 0 | 0.2480176979962943 | 1 | float |
INFO - 15:35:56: +------+-------------+---------------------+-------------+-------+
Post-process the results¶
execute_post(problem, "OptHistoryView", save=False, show=True)
<gemseo.post.opt_history_view.OptHistoryView object at 0x7fcc22250760>
Total running time of the script: ( 0 minutes 3.917 seconds)