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

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

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

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

Gallery generated by Sphinx-Gallery