Execute a scenario using a DOE#

from __future__ import annotations

from gemseo import create_discipline
from gemseo import create_scenario
from gemseo.problems.mdo.sobieski.core.design_space import SobieskiDesignSpace

Instantiate the discipline#

discipline = create_discipline("SobieskiMission")

Create the design space#

design_space = SobieskiDesignSpace()
design_space.filter(["y_24", "y_34"])
Sobieski design space:
Name Lower bound Value Upper bound Type
y_24 0.44 4.15006276 11.13 float
y_34 0.44 1.10754577 1.98 float


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 - 16:25:34: *** Start DOEScenario execution ***
INFO - 16:25:34: DOEScenario
INFO - 16:25:34:    Disciplines: SobieskiMission
INFO - 16:25:34:    MDO formulation: DisciplinaryOpt
INFO - 16:25:34: Optimization problem:
INFO - 16:25:34:    minimize -y_4(y_24, y_34)
INFO - 16:25:34:    with respect to y_24, y_34
INFO - 16:25:34:    over the design space:
INFO - 16:25:34:       +------+-------------+------------+-------------+-------+
INFO - 16:25:34:       | Name | Lower bound |   Value    | Upper bound | Type  |
INFO - 16:25:34:       +------+-------------+------------+-------------+-------+
INFO - 16:25:34:       | y_24 |     0.44    | 4.15006276 |    11.13    | float |
INFO - 16:25:34:       | y_34 |     0.44    | 1.10754577 |     1.98    | float |
INFO - 16:25:34:       +------+-------------+------------+-------------+-------+
INFO - 16:25:34: Solving optimization problem with algorithm PYDOE_LHS:
INFO - 16:25:34:      3%|▎         | 1/30 [00:00<00:00, 379.20 it/sec, feas=True, obj=-1.53e+3]
INFO - 16:25:34:      7%|▋         | 2/30 [00:00<00:00, 665.02 it/sec, feas=True, obj=-1.66e+3]
INFO - 16:25:34:     10%|█         | 3/30 [00:00<00:00, 913.59 it/sec, feas=True, obj=-832]
INFO - 16:25:34:     13%|█▎        | 4/30 [00:00<00:00, 1123.73 it/sec, feas=True, obj=-1.62e+3]
INFO - 16:25:34:     17%|█▋        | 5/30 [00:00<00:00, 1306.72 it/sec, feas=True, obj=-994]
INFO - 16:25:34:     20%|██        | 6/30 [00:00<00:00, 1473.32 it/sec, feas=True, obj=-601]
INFO - 16:25:34:     23%|██▎       | 7/30 [00:00<00:00, 1624.08 it/sec, feas=True, obj=-180]
INFO - 16:25:34:     27%|██▋       | 8/30 [00:00<00:00, 1758.89 it/sec, feas=True, obj=-755]
INFO - 16:25:34:     30%|███       | 9/30 [00:00<00:00, 1876.65 it/sec, feas=True, obj=-691]
INFO - 16:25:34:     33%|███▎      | 10/30 [00:00<00:00, 1985.38 it/sec, feas=True, obj=-393]
INFO - 16:25:34:     37%|███▋      | 11/30 [00:00<00:00, 2088.99 it/sec, feas=True, obj=-362]
INFO - 16:25:34:     40%|████      | 12/30 [00:00<00:00, 2184.82 it/sec, feas=True, obj=-748]
INFO - 16:25:34:     43%|████▎     | 13/30 [00:00<00:00, 2272.39 it/sec, feas=True, obj=-719]
INFO - 16:25:34:     47%|████▋     | 14/30 [00:00<00:00, 2341.22 it/sec, feas=True, obj=-293]
INFO - 16:25:34:     50%|█████     | 15/30 [00:00<00:00, 2414.40 it/sec, feas=True, obj=-931]
INFO - 16:25:34:     53%|█████▎    | 16/30 [00:00<00:00, 2485.05 it/sec, feas=True, obj=-264]
INFO - 16:25:34:     57%|█████▋    | 17/30 [00:00<00:00, 2550.55 it/sec, feas=True, obj=-1.17e+3]
INFO - 16:25:34:     60%|██████    | 18/30 [00:00<00:00, 2603.09 it/sec, feas=True, obj=-495]
INFO - 16:25:34:     63%|██████▎   | 19/30 [00:00<00:00, 2659.58 it/sec, feas=True, obj=-189]
INFO - 16:25:34:     67%|██████▋   | 20/30 [00:00<00:00, 2710.46 it/sec, feas=True, obj=-2.23e+3]
INFO - 16:25:34:     70%|███████   | 21/30 [00:00<00:00, 2758.63 it/sec, feas=True, obj=-344]
INFO - 16:25:34:     73%|███████▎  | 22/30 [00:00<00:00, 2795.86 it/sec, feas=True, obj=-799]
INFO - 16:25:34:     77%|███████▋  | 23/30 [00:00<00:00, 2839.75 it/sec, feas=True, obj=-55.9]
INFO - 16:25:34:     80%|████████  | 24/30 [00:00<00:00, 2882.77 it/sec, feas=True, obj=-123]
INFO - 16:25:34:     83%|████████▎ | 25/30 [00:00<00:00, 2924.65 it/sec, feas=True, obj=-875]
INFO - 16:25:34:     87%|████████▋ | 26/30 [00:00<00:00, 2964.33 it/sec, feas=True, obj=-726]
INFO - 16:25:34:     90%|█████████ | 27/30 [00:00<00:00, 2993.87 it/sec, feas=True, obj=-69.6]
INFO - 16:25:34:     93%|█████████▎| 28/30 [00:00<00:00, 3028.38 it/sec, feas=True, obj=-1.51e+3]
INFO - 16:25:34:     97%|█████████▋| 29/30 [00:00<00:00, 3061.69 it/sec, feas=True, obj=-1.15e+3]
INFO - 16:25:34:    100%|██████████| 30/30 [00:00<00:00, 3048.41 it/sec, feas=True, obj=-2.73e+3]
INFO - 16:25:34: Optimization result:
INFO - 16:25:34:    Optimizer info:
INFO - 16:25:34:       Status: None
INFO - 16:25:34:       Message: None
INFO - 16:25:34:    Solution:
INFO - 16:25:34:       Objective: -2726.3660548732214
INFO - 16:25:34:       Design space:
INFO - 16:25:34:          +------+-------------+--------------------+-------------+-------+
INFO - 16:25:34:          | Name | Lower bound |       Value        | Upper bound | Type  |
INFO - 16:25:34:          +------+-------------+--------------------+-------------+-------+
INFO - 16:25:34:          | y_24 |     0.44    | 9.094543945649603  |    11.13    | float |
INFO - 16:25:34:          | y_34 |     0.44    | 0.4769766573300308 |     1.98    | float |
INFO - 16:25:34:          +------+-------------+--------------------+-------------+-------+
INFO - 16:25:34: *** End DOEScenario execution (time: 0:00:00.012337) ***

Note that both the formulation settings passed to 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)
  • Evolution of the optimization variables
  • Evolution of the objective value
  • Evolution of the distance to the optimum
<gemseo.post.opt_history_view.OptHistoryView object at 0x72a4e0e0c230>

Note that post-processor settings passed to 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)
plot scenario doe
<gemseo.post.scatter_plot_matrix.ScatterPlotMatrix object at 0x72a4f230d190>

Total running time of the script: (0 minutes 0.569 seconds)

Gallery generated by Sphinx-Gallery