Note
Click here to download the full example code
Simple disciplinary DOE example on the Sobieski SSBJ test case¶
from __future__ import division, unicode_literals
from matplotlib import pyplot as plt
from gemseo.api import configure_logger, create_discipline, create_scenario
from gemseo.problems.sobieski.core import SobieskiProblem
configure_logger()
Out:
<RootLogger root (INFO)>
Instantiate the discipline¶
discipline = create_discipline("SobieskiMission")
Create the design space¶
design_space = SobieskiProblem().read_design_space()
design_space.filter(["y_24", "y_34"])
Out:
<gemseo.algos.design_space.DesignSpace object at 0x7fb7553f4b50>
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"})
Out:
INFO - 12:56:25:
INFO - 12:56:25: *** Start DOE Scenario execution ***
INFO - 12:56:25: DOEScenario
INFO - 12:56:25: Disciplines: SobieskiMission
INFO - 12:56:25: MDOFormulation: DisciplinaryOpt
INFO - 12:56:25: Algorithm: lhs
INFO - 12:56:25: Optimization problem:
INFO - 12:56:25: Minimize: -y_4(y_24, y_34)
INFO - 12:56:25: With respect to: y_24, y_34
INFO - 12:56:25: DOE sampling: 0%| | 0/30 [00:00<?, ?it]
INFO - 12:56:25: DOE sampling: 100%|██████████| 30/30 [00:00<00:00, 1765.38 it/sec, obj=2.73e+3]
INFO - 12:56:25: Optimization result:
INFO - 12:56:25: Objective value = 2726.3660548732214
INFO - 12:56:25: The result is feasible.
INFO - 12:56:25: Status: None
INFO - 12:56:25: Optimizer message: None
INFO - 12:56:25: Number of calls to the objective function by the optimizer: 30
INFO - 12:56:25: Design space:
INFO - 12:56:25: +------+-------------+--------------------+-------------+-------+
INFO - 12:56:25: | name | lower_bound | value | upper_bound | type |
INFO - 12:56:25: +------+-------------+--------------------+-------------+-------+
INFO - 12:56:25: | y_24 | 0.44 | 9.094543945649603 | 11.13 | float |
INFO - 12:56:25: | y_34 | 0.44 | 0.4769766573300308 | 1.98 | float |
INFO - 12:56:25: +------+-------------+--------------------+-------------+-------+
INFO - 12:56:25: *** DOE Scenario run terminated ***
{'eval_jac': False, 'algo': 'lhs', 'n_samples': 30}
Plot optimization history view¶
scenario.post_process("OptHistoryView", save=False, show=False)
Out:
<gemseo.post.opt_history_view.OptHistoryView object at 0x7fb75543aee0>
Plot parallel coordinates¶
scenario.post_process(
"ScatterPlotMatrix", save=False, show=False, variables_list=["y_4", "y_24", "y_34"]
)
# Workaround for HTML rendering, instead of ``show=True``
plt.show()
Total running time of the script: ( 0 minutes 1.332 seconds)