Diagonal design of experiments

Here is an illustration of the diagonal design of experiments (DOE) implemented by the DiagonalDOE class and used by the ScalableDiagonalModel. The idea is to sample the discipline by varying its inputs proportionally on one of the diagonals of its input space.

from __future__ import annotations

from gemseo.api import configure_logger
from gemseo.api import create_design_space
from gemseo.api import create_discipline
from gemseo.api import create_scenario

configure_logger()
<RootLogger root (INFO)>

Create the discipline

First, we create an AnalyticDiscipline implementing the function: \(f(x)=2x-3\sin(2\pi y)\) and set its cache policy to "MemoryFullCache".

discipline = create_discipline(
    "AnalyticDiscipline", expressions={"z": "2*x-3*sin(2*pi*y)"}
)

Create the design space

Then, we create a DesignSpace where \(x\) and \(y\) vary between 0 and 1.

design_space = create_design_space()
design_space.add_variable("x", l_b=0.0, u_b=1.0)
design_space.add_variable("y", l_b=0.0, u_b=1.0)

Sample with the default mode

Lastly, we create a DOEScenario and execute it with the DiagonalDOE algorithm to get 10 evaluations of \(f\). Note that we use the default configuration: all the disciplinary inputs vary proportionally from their lower bounds to their upper bounds.

scenario = create_scenario(
    discipline, "DisciplinaryOpt", "z", design_space, scenario_type="DOE"
)
scenario.execute({"algo": "DiagonalDOE", "n_samples": 10})

dataset = scenario.export_to_dataset(opt_naming=False)
dataset.plot("ScatterMatrix", save=False, show=True)
plot diagonal doe
    INFO - 11:17:14:
    INFO - 11:17:14: *** Start DOEScenario execution ***
    INFO - 11:17:14: DOEScenario
    INFO - 11:17:14:    Disciplines: AnalyticDiscipline
    INFO - 11:17:14:    MDO formulation: DisciplinaryOpt
    INFO - 11:17:14: Optimization problem:
    INFO - 11:17:14:    minimize z(x, y)
    INFO - 11:17:14:    with respect to x, y
    INFO - 11:17:14:    over the design space:
    INFO - 11:17:14:    +------+-------------+-------+-------------+-------+
    INFO - 11:17:14:    | name | lower_bound | value | upper_bound | type  |
    INFO - 11:17:14:    +------+-------------+-------+-------------+-------+
    INFO - 11:17:14:    | x    |      0      |  None |      1      | float |
    INFO - 11:17:14:    | y    |      0      |  None |      1      | float |
    INFO - 11:17:14:    +------+-------------+-------+-------------+-------+
    INFO - 11:17:14: Solving optimization problem with algorithm DiagonalDOE:
    INFO - 11:17:14: ...   0%|          | 0/10 [00:00<?, ?it]
    INFO - 11:17:14: ... 100%|██████████| 10/10 [00:00<00:00, 1696.31 it/sec, obj=2]
    INFO - 11:17:14: Optimization result:
    INFO - 11:17:14:    Optimizer info:
    INFO - 11:17:14:       Status: None
    INFO - 11:17:14:       Message: None
    INFO - 11:17:14:       Number of calls to the objective function by the optimizer: 10
    INFO - 11:17:14:    Solution:
    INFO - 11:17:14:       Objective: -2.5099788145921798
    INFO - 11:17:14:       Design space:
    INFO - 11:17:14:       +------+-------------+--------------------+-------------+-------+
    INFO - 11:17:14:       | name | lower_bound |       value        | upper_bound | type  |
    INFO - 11:17:14:       +------+-------------+--------------------+-------------+-------+
    INFO - 11:17:14:       | x    |      0      | 0.2222222222222222 |      1      | float |
    INFO - 11:17:14:       | y    |      0      | 0.2222222222222222 |      1      | float |
    INFO - 11:17:14:       +------+-------------+--------------------+-------------+-------+
    INFO - 11:17:14: *** End DOEScenario execution (time: 0:00:00.013790) ***
/home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/develop/lib/python3.9/site-packages/gemseo/post/dataset/scatter_plot_matrix.py:135: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared.
  sub_axes = scatter_matrix(

<gemseo.post.dataset.scatter_plot_matrix.ScatterMatrix object at 0x7f3d22a00310>

Sample with reverse mode for \(y\)

We can also change the configuration in order to select another diagonal of the input space, e.g. increasing \(x\) and decreasing \(y\). This configuration is illustrated in the new ScatterMatrix plot where the \((x,y)\) points follow the \(t\mapsto -t\) line while the \((x,y)\) points follow the \(t\mapsto t\) line with the default configuration.

scenario = create_scenario(
    discipline, "DisciplinaryOpt", "z", design_space, scenario_type="DOE"
)
scenario.execute(
    {"algo": "DiagonalDOE", "n_samples": 10, "algo_options": {"reverse": ["y"]}}
)

dataset = scenario.export_to_dataset(opt_naming=False)
dataset.plot("ScatterMatrix", save=False, show=True)
plot diagonal doe
    INFO - 11:17:15:
    INFO - 11:17:15: *** Start DOEScenario execution ***
    INFO - 11:17:15: DOEScenario
    INFO - 11:17:15:    Disciplines: AnalyticDiscipline
    INFO - 11:17:15:    MDO formulation: DisciplinaryOpt
    INFO - 11:17:15: Optimization problem:
    INFO - 11:17:15:    minimize z(x, y)
    INFO - 11:17:15:    with respect to x, y
    INFO - 11:17:15:    over the design space:
    INFO - 11:17:15:    +------+-------------+--------------------+-------------+-------+
    INFO - 11:17:15:    | name | lower_bound |       value        | upper_bound | type  |
    INFO - 11:17:15:    +------+-------------+--------------------+-------------+-------+
    INFO - 11:17:15:    | x    |      0      | 0.2222222222222222 |      1      | float |
    INFO - 11:17:15:    | y    |      0      | 0.2222222222222222 |      1      | float |
    INFO - 11:17:15:    +------+-------------+--------------------+-------------+-------+
    INFO - 11:17:15: Solving optimization problem with algorithm DiagonalDOE:
    INFO - 11:17:15: ...   0%|          | 0/10 [00:00<?, ?it]
    INFO - 11:17:15: ... 100%|██████████| 10/10 [00:00<00:00, 2656.64 it/sec, obj=2]
    INFO - 11:17:15: Optimization result:
    INFO - 11:17:15:    Optimizer info:
    INFO - 11:17:15:       Status: None
    INFO - 11:17:15:       Message: None
    INFO - 11:17:15:       Number of calls to the objective function by the optimizer: 10
    INFO - 11:17:15:    Solution:
    INFO - 11:17:15:       Objective: -1.3988677034810695
    INFO - 11:17:15:       Design space:
    INFO - 11:17:15:       +------+-------------+--------------------+-------------+-------+
    INFO - 11:17:15:       | name | lower_bound |       value        | upper_bound | type  |
    INFO - 11:17:15:       +------+-------------+--------------------+-------------+-------+
    INFO - 11:17:15:       | x    |      0      | 0.7777777777777777 |      1      | float |
    INFO - 11:17:15:       | y    |      0      | 0.2222222222222223 |      1      | float |
    INFO - 11:17:15:       +------+-------------+--------------------+-------------+-------+
    INFO - 11:17:15: *** End DOEScenario execution (time: 0:00:00.011735) ***
/home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/develop/lib/python3.9/site-packages/gemseo/post/dataset/scatter_plot_matrix.py:135: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared.
  sub_axes = scatter_matrix(

<gemseo.post.dataset.scatter_plot_matrix.ScatterMatrix object at 0x7f3d292b03a0>

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

Gallery generated by Sphinx-Gallery