Note
Click here to download the full example code
Scatter plot matrix¶
In this example, we illustrate the use of the ScatterPlotMatrix
plot
on the Sobieski’s SSBJ problem.
from __future__ import division, unicode_literals
from matplotlib import pyplot as plt
Import¶
The first step is to import some functions from the API and a method to get the design space.
from gemseo.api import configure_logger, create_discipline, create_scenario
from gemseo.problems.sobieski.core import SobieskiProblem
configure_logger()
Out:
<RootLogger root (INFO)>
Create disciplines¶
Then, we instantiate the disciplines of the Sobieski’s SSBJ problem: Propulsion, Aerodynamics, Structure and Mission
disciplines = create_discipline(
[
"SobieskiPropulsion",
"SobieskiAerodynamics",
"SobieskiStructure",
"SobieskiMission",
]
)
Create design space¶
We also read the design space from the SobieskiProblem
.
design_space = SobieskiProblem().read_design_space()
Create and execute scenario¶
The next step is to build a DOE scenario in order to maximize the range, encoded ‘y_4’, with respect to the design parameters, while satisfying the inequality constraints ‘g_1’, ‘g_2’ and ‘g_3’. We can use the MDF formulation, the Monte Carlo DOE algorithm and 30 samples.
scenario = create_scenario(
disciplines,
formulation="MDF",
objective_name="y_4",
maximize_objective=True,
design_space=design_space,
scenario_type="DOE",
)
scenario.set_differentiation_method("user")
for constraint in ["g_1", "g_2", "g_3"]:
scenario.add_constraint(constraint, "ineq")
scenario.execute({"algo": "OT_MONTE_CARLO", "n_samples": 30})
Out:
INFO - 09:25:38:
INFO - 09:25:38: *** Start DOE Scenario execution ***
INFO - 09:25:38: DOEScenario
INFO - 09:25:38: Disciplines: SobieskiPropulsion SobieskiAerodynamics SobieskiStructure SobieskiMission
INFO - 09:25:38: MDOFormulation: MDF
INFO - 09:25:38: Algorithm: OT_MONTE_CARLO
INFO - 09:25:38: Optimization problem:
INFO - 09:25:38: Minimize: -y_4(x_shared, x_1, x_2, x_3)
INFO - 09:25:38: With respect to: x_shared, x_1, x_2, x_3
INFO - 09:25:38: Subject to constraints:
INFO - 09:25:38: g_1(x_shared, x_1, x_2, x_3) <= 0.0
INFO - 09:25:38: g_2(x_shared, x_1, x_2, x_3) <= 0.0
INFO - 09:25:38: g_3(x_shared, x_1, x_2, x_3) <= 0.0
INFO - 09:25:38: Generation of OT_MONTE_CARLO DOE with OpenTurns
INFO - 09:25:38: Creating default composed distribution based on Uniform
INFO - 09:25:38: Creation of a uniform distribution
INFO - 09:25:38: DOE sampling: 0%| | 0/30 [00:00<?, ?it]
INFO - 09:25:38: DOE sampling: 7%|▋ | 2/30 [00:00<00:00, 279.33 it/sec, obj=297]
INFO - 09:25:38: DOE sampling: 13%|█▎ | 4/30 [00:00<00:00, 135.94 it/sec, obj=1.01e+3]
INFO - 09:25:38: DOE sampling: 20%|██ | 6/30 [00:00<00:00, 87.94 it/sec, obj=540]
INFO - 09:25:38: DOE sampling: 27%|██▋ | 8/30 [00:00<00:00, 67.09 it/sec, obj=411]
INFO - 09:25:38: DOE sampling: 33%|███▎ | 10/30 [00:00<00:00, 49.99 it/sec, obj=567]
INFO - 09:25:38: DOE sampling: 40%|████ | 12/30 [00:00<00:00, 42.05 it/sec, obj=421]
INFO - 09:25:38: DOE sampling: 47%|████▋ | 14/30 [00:00<00:00, 36.25 it/sec, obj=347]
INFO - 09:25:39: DOE sampling: 53%|█████▎ | 16/30 [00:01<00:00, 29.97 it/sec, obj=949]
INFO - 09:25:39: DOE sampling: 60%|██████ | 18/30 [00:01<00:00, 26.15 it/sec, obj=1.8e+3]
INFO - 09:25:39: DOE sampling: 67%|██████▋ | 20/30 [00:01<00:00, 23.45 it/sec, obj=619]
INFO - 09:25:39: DOE sampling: 73%|███████▎ | 22/30 [00:01<00:00, 21.55 it/sec, obj=893]
INFO - 09:25:39: DOE sampling: 80%|████████ | 24/30 [00:01<00:00, 19.77 it/sec, obj=146]
INFO - 09:25:39: DOE sampling: 87%|████████▋ | 26/30 [00:01<00:00, 17.97 it/sec, obj=556]
INFO - 09:25:39: DOE sampling: 93%|█████████▎| 28/30 [00:01<00:00, 16.70 it/sec, obj=248]
INFO - 09:25:39: DOE sampling: 100%|██████████| 30/30 [00:01<00:00, 15.45 it/sec, obj=530]
WARNING - 09:25:40: Optimization found no feasible point ! The least infeasible point is selected.
INFO - 09:25:40: DOE sampling: 100%|██████████| 30/30 [00:02<00:00, 14.94 it/sec, obj=709]
INFO - 09:25:40: Optimization result:
INFO - 09:25:40: Objective value = 617.0803511313786
INFO - 09:25:40: The result is not feasible.
INFO - 09:25:40: Status: None
INFO - 09:25:40: Optimizer message: None
INFO - 09:25:40: Number of calls to the objective function by the optimizer: 30
INFO - 09:25:40: Constraints values w.r.t. 0:
INFO - 09:25:40: g_1 = [-0.48945084 -0.2922749 -0.21769656 -0.18063263 -0.15912463 -0.07434699
INFO - 09:25:40: -0.16565301]
INFO - 09:25:40: g_2 = 0.010000000000000009
INFO - 09:25:40: g_3 = [-0.78174978 -0.21825022 -0.11408603 -0.01907799]
INFO - 09:25:40: Design Space:
INFO - 09:25:40: +----------+-------------+---------------------+-------------+-------+
INFO - 09:25:40: | name | lower_bound | value | upper_bound | type |
INFO - 09:25:40: +----------+-------------+---------------------+-------------+-------+
INFO - 09:25:40: | x_shared | 0.01 | 0.06294679971968815 | 0.09 | float |
INFO - 09:25:40: | x_shared | 30000 | 42733.67550603654 | 60000 | float |
INFO - 09:25:40: | x_shared | 1.4 | 1.663874765307306 | 1.8 | float |
INFO - 09:25:40: | x_shared | 2.5 | 5.819410624921828 | 8.5 | float |
INFO - 09:25:40: | x_shared | 40 | 69.42919736071644 | 70 | float |
INFO - 09:25:40: | x_shared | 500 | 1221.859441367615 | 1500 | float |
INFO - 09:25:40: | x_1 | 0.1 | 0.1065122508792764 | 0.4 | float |
INFO - 09:25:40: | x_1 | 0.75 | 1.09882806437771 | 1.25 | float |
INFO - 09:25:40: | x_2 | 0.75 | 1.07969581180922 | 1.25 | float |
INFO - 09:25:40: | x_3 | 0.1 | 0.4585171784931197 | 1 | float |
INFO - 09:25:40: +----------+-------------+---------------------+-------------+-------+
INFO - 09:25:40: *** DOE Scenario run terminated ***
{'eval_jac': False, 'algo': 'OT_MONTE_CARLO', 'n_samples': 30}
Post-process scenario¶
Lastly, we post-process the scenario by means of the ScatterPlotMatrix
plot which builds scatter plot matrix among design variables, objective
function and constraints.
design_variables = ["x_shared", "x_1", "x_2", "x_3"]
scenario.post_process(
"ScatterPlotMatrix",
save=False,
show=True,
variables_list=design_variables + ["-y_4"],
)
# Workaround for HTML rendering, instead of ``show=True``
plt.show()
Total running time of the script: ( 0 minutes 7.814 seconds)