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 division, unicode_literals

from matplotlib import pyplot as plt

from gemseo.api import (
    configure_logger,
    create_design_space,
    create_discipline,
    create_scenario,
)

configure_logger()

Out:

<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_dict={"z": "2*x-3*sin(2*pi*y)"}
)
discipline.set_cache_policy("MemoryFullCache")

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 = discipline.cache.export_to_dataset()
dataset.plot("ScatterMatrix", save=False, show=False)
plot diagonal doe

Out:

    INFO - 09:23:34:
    INFO - 09:23:34: *** Start DOE Scenario execution ***
    INFO - 09:23:34: DOEScenario
    INFO - 09:23:34:    Disciplines: AnalyticDiscipline
    INFO - 09:23:34:    MDOFormulation: DisciplinaryOpt
    INFO - 09:23:34:    Algorithm: DiagonalDOE
    INFO - 09:23:34: Optimization problem:
    INFO - 09:23:34:    Minimize: z(x, y)
    INFO - 09:23:34:    With respect to: x, y
    INFO - 09:23:34: DOE sampling:   0%|          | 0/10 [00:00<?, ?it]
    INFO - 09:23:34: DOE sampling: 100%|██████████| 10/10 [00:00<00:00, 501.54 it/sec, obj=2]
    INFO - 09:23:34: Optimization result:
    INFO - 09:23:34: Objective value = -2.5099788145921798
    INFO - 09:23:34: The result is feasible.
    INFO - 09:23:34: Status: None
    INFO - 09:23:34: Optimizer message: None
    INFO - 09:23:34: Number of calls to the objective function by the optimizer: 10
    INFO - 09:23:34: Design Space:
    INFO - 09:23:34: +------+-------------+--------------------+-------------+-------+
    INFO - 09:23:34: | name | lower_bound |       value        | upper_bound | type  |
    INFO - 09:23:34: +------+-------------+--------------------+-------------+-------+
    INFO - 09:23:34: | x    |      0      | 0.2222222222222222 |      1      | float |
    INFO - 09:23:34: | y    |      0      | 0.2222222222222222 |      1      | float |
    INFO - 09:23:34: +------+-------------+--------------------+-------------+-------+
    INFO - 09:23:34: *** DOE Scenario run terminated ***

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

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.

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

dataset = discipline.cache.export_to_dataset()
dataset.plot("ScatterMatrix", save=False, show=False)
# Workaround for HTML rendering, instead of ``show=True``
plt.show()
plot diagonal doe

Out:

INFO - 09:23:35:
INFO - 09:23:35: *** Start DOE Scenario execution ***
INFO - 09:23:35: DOEScenario
INFO - 09:23:35:    Disciplines: AnalyticDiscipline
INFO - 09:23:35:    MDOFormulation: DisciplinaryOpt
INFO - 09:23:35:    Algorithm: DiagonalDOE
INFO - 09:23:35: Optimization problem:
INFO - 09:23:35:    Minimize: z(x, y)
INFO - 09:23:35:    With respect to: x, y
INFO - 09:23:35: DOE sampling:   0%|          | 0/10 [00:00<?, ?it]
INFO - 09:23:35: DOE sampling: 100%|██████████| 10/10 [00:00<00:00, 364.10 it/sec, obj=2]
INFO - 09:23:35: Optimization result:
INFO - 09:23:35: Objective value = -1.3988677034810684
INFO - 09:23:35: The result is feasible.
INFO - 09:23:35: Status: None
INFO - 09:23:35: Optimizer message: None
INFO - 09:23:35: Number of calls to the objective function by the optimizer: 10
INFO - 09:23:35: Design Space:
INFO - 09:23:35: +------+-------------+--------------------+-------------+-------+
INFO - 09:23:35: | name | lower_bound |       value        | upper_bound | type  |
INFO - 09:23:35: +------+-------------+--------------------+-------------+-------+
INFO - 09:23:35: | x    |      0      | 0.7777777777777778 |      1      | float |
INFO - 09:23:35: | y    |      0      | 0.2222222222222222 |      1      | float |
INFO - 09:23:35: +------+-------------+--------------------+-------------+-------+
INFO - 09:23:35: *** DOE Scenario run terminated ***

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

Gallery generated by Sphinx-Gallery