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.sobieski.core.problem import SobieskiProblem
configure_logger()
<RootLogger root (INFO)>
Instantiate the discipline¶
discipline = create_discipline("SobieskiMission")
Create the design space¶
design_space = SobieskiProblem().design_space
design_space.filter(["y_24", "y_34"])
<gemseo.algos.design_space.DesignSpace object at 0x7fea3c654430>
Create the scenario¶
Build scenario which links the disciplines with the formulation and The DOE algorithm.
scenario = create_scenario(
[discipline],
formulation="DisciplinaryOpt",
objective_name="y_4",
design_space=design_space,
maximize_objective=True,
scenario_type="DOE",
)
Execute the scenario¶
Here we use a latin hypercube sampling algorithm with 30 samples.
scenario.execute({"n_samples": 30, "algo": "lhs"})
INFO - 16:29:09:
INFO - 16:29:09: *** Start DOEScenario execution ***
INFO - 16:29:09: DOEScenario
INFO - 16:29:09: Disciplines: SobieskiMission
INFO - 16:29:09: MDO formulation: DisciplinaryOpt
INFO - 16:29:09: Optimization problem:
INFO - 16:29:09: minimize -y_4(y_24, y_34)
INFO - 16:29:09: with respect to y_24, y_34
INFO - 16:29:09: over the design space:
INFO - 16:29:09: +------+-------------+------------+-------------+-------+
INFO - 16:29:09: | name | lower_bound | value | upper_bound | type |
INFO - 16:29:09: +------+-------------+------------+-------------+-------+
INFO - 16:29:09: | y_24 | 0.44 | 4.15006276 | 11.13 | float |
INFO - 16:29:09: | y_34 | 0.44 | 1.10754577 | 1.98 | float |
INFO - 16:29:09: +------+-------------+------------+-------------+-------+
INFO - 16:29:09: Solving optimization problem with algorithm lhs:
INFO - 16:29:09: ... 0%| | 0/30 [00:00<?, ?it]
INFO - 16:29:09: ... 3%|▎ | 1/30 [00:00<00:00, 241.41 it/sec, obj=-1.53e+3]
INFO - 16:29:09: ... 7%|▋ | 2/30 [00:00<00:00, 405.15 it/sec, obj=-1.66e+3]
INFO - 16:29:09: ... 10%|█ | 3/30 [00:00<00:00, 525.84 it/sec, obj=-832]
INFO - 16:29:09: ... 13%|█▎ | 4/30 [00:00<00:00, 620.73 it/sec, obj=-1.62e+3]
INFO - 16:29:09: ... 17%|█▋ | 5/30 [00:00<00:00, 699.12 it/sec, obj=-994]
INFO - 16:29:09: ... 20%|██ | 6/30 [00:00<00:00, 764.08 it/sec, obj=-601]
INFO - 16:29:09: ... 23%|██▎ | 7/30 [00:00<00:00, 818.29 it/sec, obj=-180]
INFO - 16:29:09: ... 27%|██▋ | 8/30 [00:00<00:00, 861.56 it/sec, obj=-755]
INFO - 16:29:09: ... 30%|███ | 9/30 [00:00<00:00, 900.90 it/sec, obj=-691]
INFO - 16:29:09: ... 33%|███▎ | 10/30 [00:00<00:00, 933.91 it/sec, obj=-393]
INFO - 16:29:09: ... 37%|███▋ | 11/30 [00:00<00:00, 959.76 it/sec, obj=-362]
INFO - 16:29:09: ... 40%|████ | 12/30 [00:00<00:00, 986.39 it/sec, obj=-748]
INFO - 16:29:09: ... 43%|████▎ | 13/30 [00:00<00:00, 1010.04 it/sec, obj=-719]
INFO - 16:29:09: ... 47%|████▋ | 14/30 [00:00<00:00, 1027.73 it/sec, obj=-293]
INFO - 16:29:09: ... 50%|█████ | 15/30 [00:00<00:00, 1045.93 it/sec, obj=-931]
INFO - 16:29:09: ... 53%|█████▎ | 16/30 [00:00<00:00, 1063.55 it/sec, obj=-264]
INFO - 16:29:09: ... 57%|█████▋ | 17/30 [00:00<00:00, 1079.61 it/sec, obj=-1.17e+3]
INFO - 16:29:09: ... 60%|██████ | 18/30 [00:00<00:00, 1094.34 it/sec, obj=-495]
INFO - 16:29:09: ... 63%|██████▎ | 19/30 [00:00<00:00, 1106.00 it/sec, obj=-189]
INFO - 16:29:09: ... 67%|██████▋ | 20/30 [00:00<00:00, 1118.26 it/sec, obj=-2.23e+3]
INFO - 16:29:09: ... 70%|███████ | 21/30 [00:00<00:00, 1128.58 it/sec, obj=-344]
INFO - 16:29:09: ... 73%|███████▎ | 22/30 [00:00<00:00, 1139.26 it/sec, obj=-799]
INFO - 16:29:09: ... 77%|███████▋ | 23/30 [00:00<00:00, 1149.40 it/sec, obj=-55.9]
INFO - 16:29:09: ... 80%|████████ | 24/30 [00:00<00:00, 1158.86 it/sec, obj=-123]
INFO - 16:29:09: ... 83%|████████▎ | 25/30 [00:00<00:00, 1165.36 it/sec, obj=-875]
INFO - 16:29:09: ... 87%|████████▋ | 26/30 [00:00<00:00, 1171.18 it/sec, obj=-726]
INFO - 16:29:09: ... 90%|█████████ | 27/30 [00:00<00:00, 1176.60 it/sec, obj=-69.6]
INFO - 16:29:09: ... 93%|█████████▎| 28/30 [00:00<00:00, 1183.58 it/sec, obj=-1.51e+3]
INFO - 16:29:09: ... 97%|█████████▋| 29/30 [00:00<00:00, 1190.14 it/sec, obj=-1.15e+3]
INFO - 16:29:09: ... 100%|██████████| 30/30 [00:00<00:00, 1195.33 it/sec, obj=-2.73e+3]
INFO - 16:29:09: Optimization result:
INFO - 16:29:09: Optimizer info:
INFO - 16:29:09: Status: None
INFO - 16:29:09: Message: None
INFO - 16:29:09: Number of calls to the objective function by the optimizer: 30
INFO - 16:29:09: Solution:
INFO - 16:29:09: Objective: -2726.3660548732214
INFO - 16:29:09: Design space:
INFO - 16:29:09: +------+-------------+--------------------+-------------+-------+
INFO - 16:29:09: | name | lower_bound | value | upper_bound | type |
INFO - 16:29:09: +------+-------------+--------------------+-------------+-------+
INFO - 16:29:09: | y_24 | 0.44 | 9.094543945649603 | 11.13 | float |
INFO - 16:29:09: | y_34 | 0.44 | 0.4769766573300308 | 1.98 | float |
INFO - 16:29:09: +------+-------------+--------------------+-------------+-------+
INFO - 16:29:09: *** End DOEScenario execution (time: 0:00:00.037297) ***
{'eval_jac': False, 'n_samples': 30, 'algo': 'lhs'}
Plot optimization history view¶
scenario.post_process("OptHistoryView", save=False, show=True)
/home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/5.0.0/lib/python3.9/site-packages/genson/schema/strategies/base.py:42: UserWarning: Schema incompatible. Keyword 'description' has conflicting values ('The width and height of the figure in inches, e.g. ``(w, h)``.\nIf ``None``, use the :attr:`.OptPostProcessor.DEFAULT_FIG_SIZE`\nof the post-processor.' vs. 'The width and height of the figure in inches, e.g. `(w, h)`.\nIf ``None``, use the :attr:`.OptPostProcessor.DEFAULT_FIG_SIZE`\nof the post-processor.'). Using 'The width and height of the figure in inches, e.g. ``(w, h)``.\nIf ``None``, use the :attr:`.OptPostProcessor.DEFAULT_FIG_SIZE`\nof the post-processor.'
warn(('Schema incompatible. Keyword {0!r} has conflicting '
WARNING - 16:29:09: Failed to create Hessian approximation.
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/5.0.0/lib/python3.9/site-packages/gemseo/post/opt_history_view.py", line 621, in _create_hessian_approx_plot
_, diag, _, _ = SR1Approx(history).build_approximation(
File "/home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/5.0.0/lib/python3.9/site-packages/gemseo/post/core/hessians.py", line 379, in build_approximation
x_hist, grad_hist, _, _ = self.get_x_grad_history(
File "/home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/5.0.0/lib/python3.9/site-packages/gemseo/post/core/hessians.py", line 170, in get_x_grad_history
raise ValueError(
ValueError: Cannot build approximation for function: -y_4 because its gradient history is too small: 0.
<gemseo.post.opt_history_view.OptHistoryView object at 0x7fea3af1ac10>
Plot parallel coordinates¶
scenario.post_process(
"ScatterPlotMatrix",
variable_names=["y_4", "y_24", "y_34"],
save=False,
show=True,
)

<gemseo.post.scatter_mat.ScatterPlotMatrix object at 0x7fea46f6fc40>
Total running time of the script: ( 0 minutes 1.619 seconds)