Note
Go to the end to download the full example code.
Simple disciplinary DOE example on the Sobieski SSBJ test case#
from __future__ import annotations
from gemseo import configure_logger
from gemseo import create_discipline
from gemseo import create_scenario
from gemseo.problems.mdo.sobieski.core.design_space import SobieskiDesignSpace
configure_logger()
<RootLogger root (INFO)>
Instantiate the discipline#
discipline = create_discipline("SobieskiMission")
Create the design space#
design_space = SobieskiDesignSpace()
design_space.filter(["y_24", "y_34"])
Create the scenario#
Build scenario which links the disciplines with the formulation and The DOE algorithm.
scenario = create_scenario(
[discipline],
"y_4",
design_space,
maximize_objective=True,
scenario_type="DOE",
formulation_name="DisciplinaryOpt",
)
Execute the scenario#
Here we use a latin hypercube sampling algorithm with 30 samples.
scenario.execute(algo_name="PYDOE_LHS", n_samples=30)
INFO - 08:37:49:
INFO - 08:37:49: *** Start DOEScenario execution ***
INFO - 08:37:49: DOEScenario
INFO - 08:37:49: Disciplines: SobieskiMission
INFO - 08:37:49: MDO formulation: DisciplinaryOpt
INFO - 08:37:49: Optimization problem:
INFO - 08:37:49: minimize -y_4(y_24, y_34)
INFO - 08:37:49: with respect to y_24, y_34
INFO - 08:37:49: over the design space:
INFO - 08:37:49: +------+-------------+------------+-------------+-------+
INFO - 08:37:49: | Name | Lower bound | Value | Upper bound | Type |
INFO - 08:37:49: +------+-------------+------------+-------------+-------+
INFO - 08:37:49: | y_24 | 0.44 | 4.15006276 | 11.13 | float |
INFO - 08:37:49: | y_34 | 0.44 | 1.10754577 | 1.98 | float |
INFO - 08:37:49: +------+-------------+------------+-------------+-------+
INFO - 08:37:49: Solving optimization problem with algorithm PYDOE_LHS:
INFO - 08:37:49: 3%|▎ | 1/30 [00:00<00:00, 314.75 it/sec, obj=-1.53e+3]
INFO - 08:37:49: 7%|▋ | 2/30 [00:00<00:00, 531.09 it/sec, obj=-1.66e+3]
INFO - 08:37:49: 10%|█ | 3/30 [00:00<00:00, 698.51 it/sec, obj=-832]
INFO - 08:37:49: 13%|█▎ | 4/30 [00:00<00:00, 830.60 it/sec, obj=-1.62e+3]
INFO - 08:37:49: 17%|█▋ | 5/30 [00:00<00:00, 938.91 it/sec, obj=-994]
INFO - 08:37:49: 20%|██ | 6/30 [00:00<00:00, 1028.56 it/sec, obj=-601]
INFO - 08:37:49: 23%|██▎ | 7/30 [00:00<00:00, 1101.03 it/sec, obj=-180]
INFO - 08:37:49: 27%|██▋ | 8/30 [00:00<00:00, 1153.47 it/sec, obj=-755]
INFO - 08:37:49: 30%|███ | 9/30 [00:00<00:00, 1205.53 it/sec, obj=-691]
INFO - 08:37:49: 33%|███▎ | 10/30 [00:00<00:00, 1253.68 it/sec, obj=-393]
INFO - 08:37:49: 37%|███▋ | 11/30 [00:00<00:00, 1296.61 it/sec, obj=-362]
INFO - 08:37:49: 40%|████ | 12/30 [00:00<00:00, 1334.28 it/sec, obj=-748]
INFO - 08:37:49: 43%|████▎ | 13/30 [00:00<00:00, 1368.28 it/sec, obj=-719]
INFO - 08:37:49: 47%|████▋ | 14/30 [00:00<00:00, 1398.93 it/sec, obj=-293]
INFO - 08:37:49: 50%|█████ | 15/30 [00:00<00:00, 1424.08 it/sec, obj=-931]
INFO - 08:37:49: 53%|█████▎ | 16/30 [00:00<00:00, 1442.89 it/sec, obj=-264]
INFO - 08:37:49: 57%|█████▋ | 17/30 [00:00<00:00, 1464.49 it/sec, obj=-1.17e+3]
INFO - 08:37:49: 60%|██████ | 18/30 [00:00<00:00, 1485.12 it/sec, obj=-495]
INFO - 08:37:49: 63%|██████▎ | 19/30 [00:00<00:00, 1504.58 it/sec, obj=-189]
INFO - 08:37:49: 67%|██████▋ | 20/30 [00:00<00:00, 1522.43 it/sec, obj=-2.23e+3]
INFO - 08:37:49: 70%|███████ | 21/30 [00:00<00:00, 1539.01 it/sec, obj=-344]
INFO - 08:37:49: 73%|███████▎ | 22/30 [00:00<00:00, 1554.60 it/sec, obj=-799]
INFO - 08:37:49: 77%|███████▋ | 23/30 [00:00<00:00, 1566.39 it/sec, obj=-55.9]
INFO - 08:37:49: 80%|████████ | 24/30 [00:00<00:00, 1575.97 it/sec, obj=-123]
INFO - 08:37:49: 83%|████████▎ | 25/30 [00:00<00:00, 1588.58 it/sec, obj=-875]
INFO - 08:37:49: 87%|████████▋ | 26/30 [00:00<00:00, 1600.48 it/sec, obj=-726]
INFO - 08:37:49: 90%|█████████ | 27/30 [00:00<00:00, 1611.52 it/sec, obj=-69.6]
INFO - 08:37:49: 93%|█████████▎| 28/30 [00:00<00:00, 1621.86 it/sec, obj=-1.51e+3]
INFO - 08:37:49: 97%|█████████▋| 29/30 [00:00<00:00, 1631.46 it/sec, obj=-1.15e+3]
INFO - 08:37:49: 100%|██████████| 30/30 [00:00<00:00, 1634.80 it/sec, obj=-2.73e+3]
INFO - 08:37:49: Optimization result:
INFO - 08:37:49: Optimizer info:
INFO - 08:37:49: Status: None
INFO - 08:37:49: Message: None
INFO - 08:37:49: Number of calls to the objective function by the optimizer: 30
INFO - 08:37:49: Solution:
INFO - 08:37:49: Objective: -2726.3660548732214
INFO - 08:37:49: Design space:
INFO - 08:37:49: +------+-------------+--------------------+-------------+-------+
INFO - 08:37:49: | Name | Lower bound | Value | Upper bound | Type |
INFO - 08:37:49: +------+-------------+--------------------+-------------+-------+
INFO - 08:37:49: | y_24 | 0.44 | 9.094543945649603 | 11.13 | float |
INFO - 08:37:49: | y_34 | 0.44 | 0.4769766573300308 | 1.98 | float |
INFO - 08:37:49: +------+-------------+--------------------+-------------+-------+
INFO - 08:37:49: *** End DOEScenario execution (time: 0:00:00.023289) ***
Note that both the formulation settings passed to func:.create_scenario and the
algorithm settings passed to execute()
can be provided via a Pydantic model. For
more information, see Formulation Settings and Algorithm Settings.
Plot optimization history view#
scenario.post_process(post_name="OptHistoryView", save=False, show=True)
<gemseo.post.opt_history_view.OptHistoryView object at 0x7f24de0d0520>
Note that post-processor settings passed to BaseScenario.post_process()
can be
provided via a Pydantic model (see the example below). For more information,
see Post-processor Settings.
Plot scatter plot matrix#
from gemseo.settings.post import ScatterPlotMatrix_Settings # noqa: E402
settings_model = ScatterPlotMatrix_Settings(
variable_names=["y_4", "y_24", "y_34"],
save=False,
show=True,
)
scenario.post_process(settings_model)

<gemseo.post.scatter_plot_matrix.ScatterPlotMatrix object at 0x7f24dee1c2b0>
Total running time of the script: (0 minutes 1.472 seconds)