Scatter plot matrix#

In this example, we illustrate the use of the ScatterPlotMatrix plot on the Sobieski's SSBJ problem.

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

Import#

The first step is to import some high-level functions and a method to get the design space.

configure_logger()
<RootLogger root (INFO)>

Description#

The ScatterPlotMatrix post-processing builds the scatter plot matrix among design variables and outputs functions. Each non-diagonal block represents the samples according to the x- and y- coordinates names while the diagonal ones approximate the probability distributions of the variables, using a kernel-density estimator.

Create disciplines#

At this point, we instantiate the disciplines of Sobieski's SSBJ problem: Propulsion, Aerodynamics, Structure and Mission

disciplines = create_discipline([
    "SobieskiPropulsion",
    "SobieskiAerodynamics",
    "SobieskiStructure",
    "SobieskiMission",
])

Create design space#

We also create the SobieskiDesignSpace.

design_space = SobieskiDesignSpace()

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,
    "y_4",
    design_space,
    formulation_name="MDF",
    maximize_objective=True,
    scenario_type="DOE",
)
scenario.set_differentiation_method()
for constraint in ["g_1", "g_2", "g_3"]:
    scenario.add_constraint(constraint, constraint_type="ineq")
scenario.execute(algo_name="OT_MONTE_CARLO", n_samples=30)
WARNING - 00:56:28: Unsupported feature 'minItems' in JSONGrammar 'SobieskiMission_discipline_output' for property 'y_4' in conversion to SimpleGrammar.
WARNING - 00:56:28: Unsupported feature 'maxItems' in JSONGrammar 'SobieskiMission_discipline_output' for property 'y_4' in conversion to SimpleGrammar.
   INFO - 00:56:28:
   INFO - 00:56:28: *** Start DOEScenario execution ***
   INFO - 00:56:28: DOEScenario
   INFO - 00:56:28:    Disciplines: SobieskiAerodynamics SobieskiMission SobieskiPropulsion SobieskiStructure
   INFO - 00:56:28:    MDO formulation: MDF
   INFO - 00:56:28: Optimization problem:
   INFO - 00:56:28:    minimize -y_4(x_shared, x_1, x_2, x_3)
   INFO - 00:56:28:    with respect to x_1, x_2, x_3, x_shared
   INFO - 00:56:28:    subject to constraints:
   INFO - 00:56:28:       g_1(x_shared, x_1, x_2, x_3) <= 0
   INFO - 00:56:28:       g_2(x_shared, x_1, x_2, x_3) <= 0
   INFO - 00:56:28:       g_3(x_shared, x_1, x_2, x_3) <= 0
   INFO - 00:56:28:    over the design space:
   INFO - 00:56:28:       +-------------+-------------+-------+-------------+-------+
   INFO - 00:56:28:       | Name        | Lower bound | Value | Upper bound | Type  |
   INFO - 00:56:28:       +-------------+-------------+-------+-------------+-------+
   INFO - 00:56:28:       | x_shared[0] |     0.01    |  0.05 |     0.09    | float |
   INFO - 00:56:28:       | x_shared[1] |    30000    | 45000 |    60000    | float |
   INFO - 00:56:28:       | x_shared[2] |     1.4     |  1.6  |     1.8     | float |
   INFO - 00:56:28:       | x_shared[3] |     2.5     |  5.5  |     8.5     | float |
   INFO - 00:56:28:       | x_shared[4] |      40     |   55  |      70     | float |
   INFO - 00:56:28:       | x_shared[5] |     500     |  1000 |     1500    | float |
   INFO - 00:56:28:       | x_1[0]      |     0.1     |  0.25 |     0.4     | float |
   INFO - 00:56:28:       | x_1[1]      |     0.75    |   1   |     1.25    | float |
   INFO - 00:56:28:       | x_2         |     0.75    |   1   |     1.25    | float |
   INFO - 00:56:28:       | x_3         |     0.1     |  0.5  |      1      | float |
   INFO - 00:56:28:       +-------------+-------------+-------+-------------+-------+
   INFO - 00:56:28: Solving optimization problem with algorithm OT_MONTE_CARLO:
   INFO - 00:56:28:      3%|▎         | 1/30 [00:00<00:01, 19.62 it/sec, obj=-166]
   INFO - 00:56:28:      7%|▋         | 2/30 [00:00<00:01, 26.04 it/sec, obj=-484]
   INFO - 00:56:28:     10%|█         | 3/30 [00:00<00:00, 29.41 it/sec, obj=-481]
   INFO - 00:56:28:     13%|█▎        | 4/30 [00:00<00:00, 31.40 it/sec, obj=-384]
   INFO - 00:56:28:     17%|█▋        | 5/30 [00:00<00:00, 32.53 it/sec, obj=-1.14e+3]
   INFO - 00:56:28:     20%|██        | 6/30 [00:00<00:00, 33.45 it/sec, obj=-290]
   INFO - 00:56:28:     23%|██▎       | 7/30 [00:00<00:00, 33.69 it/sec, obj=-630]
   INFO - 00:56:28:     27%|██▋       | 8/30 [00:00<00:00, 33.41 it/sec, obj=-346]
   INFO - 00:56:28:     30%|███       | 9/30 [00:00<00:00, 33.51 it/sec, obj=-626]
   INFO - 00:56:28:     33%|███▎      | 10/30 [00:00<00:00, 33.54 it/sec, obj=-621]
   INFO - 00:56:28:     37%|███▋      | 11/30 [00:00<00:00, 33.59 it/sec, obj=-280]
   INFO - 00:56:28:     40%|████      | 12/30 [00:00<00:00, 32.84 it/sec, obj=-288]
   INFO - 00:56:28:     43%|████▎     | 13/30 [00:00<00:00, 32.23 it/sec, obj=-257]
   INFO - 00:56:28:     47%|████▋     | 14/30 [00:00<00:00, 31.72 it/sec, obj=-367]
   INFO - 00:56:29:     50%|█████     | 15/30 [00:00<00:00, 31.49 it/sec, obj=-1.08e+3]
   INFO - 00:56:29:     53%|█████▎    | 16/30 [00:00<00:00, 31.72 it/sec, obj=-344]
   INFO - 00:56:29:     57%|█████▋    | 17/30 [00:00<00:00, 31.54 it/sec, obj=-368]
   INFO - 00:56:29:     60%|██████    | 18/30 [00:00<00:00, 31.34 it/sec, obj=-253]
   INFO - 00:56:29:     63%|██████▎   | 19/30 [00:00<00:00, 31.05 it/sec, obj=-129]
   INFO - 00:56:29:     67%|██████▋   | 20/30 [00:00<00:00, 30.97 it/sec, obj=-1.07e+3]
   INFO - 00:56:29:     70%|███████   | 21/30 [00:00<00:00, 31.29 it/sec, obj=-341]
   INFO - 00:56:29:     73%|███████▎  | 22/30 [00:00<00:00, 31.46 it/sec, obj=-1e+3]
   INFO - 00:56:29:     77%|███████▋  | 23/30 [00:00<00:00, 30.88 it/sec, obj=-586]
   INFO - 00:56:29:     80%|████████  | 24/30 [00:00<00:00, 31.05 it/sec, obj=-483]
   INFO - 00:56:29:     83%|████████▎ | 25/30 [00:00<00:00, 31.33 it/sec, obj=-392]
   INFO - 00:56:29:     87%|████████▋ | 26/30 [00:00<00:00, 31.59 it/sec, obj=-406]
   INFO - 00:56:29:     90%|█████████ | 27/30 [00:00<00:00, 31.36 it/sec, obj=-207]
   INFO - 00:56:29:     93%|█████████▎| 28/30 [00:00<00:00, 31.58 it/sec, obj=-702]
   INFO - 00:56:29:     97%|█████████▋| 29/30 [00:00<00:00, 31.90 it/sec, obj=-423]
   INFO - 00:56:29:    100%|██████████| 30/30 [00:00<00:00, 32.00 it/sec, obj=-664]
   INFO - 00:56:29: Optimization result:
   INFO - 00:56:29:    Optimizer info:
   INFO - 00:56:29:       Status: None
   INFO - 00:56:29:       Message: None
   INFO - 00:56:29:       Number of calls to the objective function by the optimizer: 30
   INFO - 00:56:29:    Solution:
   INFO - 00:56:29:       The solution is feasible.
   INFO - 00:56:29:       Objective: -367.45728393799953
   INFO - 00:56:29:       Standardized constraints:
   INFO - 00:56:29:          g_1 = [-0.02478574 -0.00310924 -0.00855146 -0.01702654 -0.02484732 -0.04764585
   INFO - 00:56:29:  -0.19235415]
   INFO - 00:56:29:          g_2 = -0.09000000000000008
   INFO - 00:56:29:          g_3 = [-0.98722984 -0.01277016 -0.60760341 -0.0557087 ]
   INFO - 00:56:29:       Design space:
   INFO - 00:56:29:          +-------------+-------------+---------------------+-------------+-------+
   INFO - 00:56:29:          | Name        | Lower bound |        Value        | Upper bound | Type  |
   INFO - 00:56:29:          +-------------+-------------+---------------------+-------------+-------+
   INFO - 00:56:29:          | x_shared[0] |     0.01    | 0.01230934749207792 |     0.09    | float |
   INFO - 00:56:29:          | x_shared[1] |    30000    |  43456.87364611478  |    60000    | float |
   INFO - 00:56:29:          | x_shared[2] |     1.4     |  1.731884935123487  |     1.8     | float |
   INFO - 00:56:29:          | x_shared[3] |     2.5     |  3.894765253193514  |     8.5     | float |
   INFO - 00:56:29:          | x_shared[4] |      40     |  57.92631048228255  |      70     | float |
   INFO - 00:56:29:          | x_shared[5] |     500     |  520.4048463450415  |     1500    | float |
   INFO - 00:56:29:          | x_1[0]      |     0.1     |  0.3994784918586811 |     0.4     | float |
   INFO - 00:56:29:          | x_1[1]      |     0.75    |  0.9500312867674923 |     1.25    | float |
   INFO - 00:56:29:          | x_2         |     0.75    |  1.205851870260564  |     1.25    | float |
   INFO - 00:56:29:          | x_3         |     0.1     |  0.2108042391973412 |      1      | float |
   INFO - 00:56:29:          +-------------+-------------+---------------------+-------------+-------+
   INFO - 00:56:29: *** End DOEScenario execution (time: 0:00:00.943473) ***

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.

Tip

Each post-processing method requires different inputs and offers a variety of customization options. Use the high-level function get_post_processing_options_schema() to print a table with the options for any post-processing algorithm. Or refer to our dedicated page: Post-processing algorithms.

design_variables = ["x_shared", "x_1", "x_2", "x_3"]
scenario.post_process(
    post_name="ScatterPlotMatrix",
    variable_names=[*design_variables, "-y_4"],
    save=False,
    show=True,
)
plot history scatter matrix
<gemseo.post.scatter_plot_matrix.ScatterPlotMatrix object at 0x7f1931b13b60>

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

Gallery generated by Sphinx-Gallery