.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/scalable/plot_diagonal_doe.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_scalable_plot_diagonal_doe.py: Diagonal design of experiments ============================== Here is an illustration of the diagonal design of experiments (DOE) implemented by the :class:`.DiagonalDOE` class and used by the :class:`.ScalableDiagonalModel`. The idea is to sample the discipline by varying its inputs proportionally on one of the diagonals of its input space. .. GENERATED FROM PYTHON SOURCE LINES 31-43 .. code-block:: Python from __future__ import annotations from gemseo import configure_logger from gemseo import create_design_space from gemseo import create_discipline from gemseo import create_scenario from gemseo.post.dataset.scatter_plot_matrix import ScatterMatrix configure_logger() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 44-49 Create the discipline --------------------- First, we create an :class:`.AnalyticDiscipline` implementing the function: :math:`f(x)=2x-3\sin(2\pi y)` and set its cache policy to ``"MemoryFullCache"``. .. GENERATED FROM PYTHON SOURCE LINES 49-54 .. code-block:: Python discipline = create_discipline( "AnalyticDiscipline", expressions={"z": "2*x-3*sin(2*pi*y)"} ) .. GENERATED FROM PYTHON SOURCE LINES 55-59 Create the design space ----------------------- Then, we create a :class:`.DesignSpace` where :math:`x` and :math:`y` vary between 0 and 1. .. GENERATED FROM PYTHON SOURCE LINES 59-63 .. code-block:: Python 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) .. GENERATED FROM PYTHON SOURCE LINES 64-72 Sample with the default mode ---------------------------- Lastly, we create a :class:`.DOEScenario` and execute it with the :class:`.DiagonalDOE` algorithm to get 10 evaluations of :math:`f`. Note that we use the default configuration: all the disciplinary inputs vary proportionally from their lower bounds to their upper bounds. .. GENERATED FROM PYTHON SOURCE LINES 72-79 .. code-block:: Python scenario = create_scenario( discipline, "DisciplinaryOpt", "z", design_space, scenario_type="DOE" ) scenario.execute({"algo": "DiagonalDOE", "n_samples": 10}) dataset = scenario.to_dataset(opt_naming=False) ScatterMatrix(dataset).execute(save=False, show=True) .. image-sg:: /examples/scalable/images/sphx_glr_plot_diagonal_doe_001.png :alt: plot diagonal doe :srcset: /examples/scalable/images/sphx_glr_plot_diagonal_doe_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 13:53:44: INFO - 13:53:44: *** Start DOEScenario execution *** INFO - 13:53:44: DOEScenario INFO - 13:53:44: Disciplines: AnalyticDiscipline INFO - 13:53:44: MDO formulation: DisciplinaryOpt INFO - 13:53:44: Optimization problem: INFO - 13:53:44: minimize z(x, y) INFO - 13:53:44: with respect to x, y INFO - 13:53:44: over the design space: INFO - 13:53:44: +------+-------------+-------+-------------+-------+ INFO - 13:53:44: | Name | Lower bound | Value | Upper bound | Type | INFO - 13:53:44: +------+-------------+-------+-------------+-------+ INFO - 13:53:44: | x | 0 | None | 1 | float | INFO - 13:53:44: | y | 0 | None | 1 | float | INFO - 13:53:44: +------+-------------+-------+-------------+-------+ INFO - 13:53:44: Solving optimization problem with algorithm DiagonalDOE: INFO - 13:53:44: 10%|█ | 1/10 [00:00<00:00, 411.25 it/sec, obj=0] INFO - 13:53:44: 20%|██ | 2/10 [00:00<00:00, 640.99 it/sec, obj=-1.71] INFO - 13:53:44: 30%|███ | 3/10 [00:00<00:00, 802.89 it/sec, obj=-2.51] INFO - 13:53:44: 40%|████ | 4/10 [00:00<00:00, 920.46 it/sec, obj=-1.93] INFO - 13:53:44: 50%|█████ | 5/10 [00:00<00:00, 1008.88 it/sec, obj=-0.137] INFO - 13:53:44: 60%|██████ | 6/10 [00:00<00:00, 1078.04 it/sec, obj=2.14] INFO - 13:53:44: 70%|███████ | 7/10 [00:00<00:00, 1123.92 it/sec, obj=3.93] INFO - 13:53:44: 80%|████████ | 8/10 [00:00<00:00, 1168.37 it/sec, obj=4.51] INFO - 13:53:44: 90%|█████████ | 9/10 [00:00<00:00, 1207.15 it/sec, obj=3.71] INFO - 13:53:44: 100%|██████████| 10/10 [00:00<00:00, 1239.89 it/sec, obj=2] INFO - 13:53:44: Optimization result: INFO - 13:53:44: Optimizer info: INFO - 13:53:44: Status: None INFO - 13:53:44: Message: None INFO - 13:53:44: Number of calls to the objective function by the optimizer: 10 INFO - 13:53:44: Solution: INFO - 13:53:44: Objective: -2.5099788145921798 INFO - 13:53:44: Design space: INFO - 13:53:44: +------+-------------+--------------------+-------------+-------+ INFO - 13:53:44: | Name | Lower bound | Value | Upper bound | Type | INFO - 13:53:44: +------+-------------+--------------------+-------------+-------+ INFO - 13:53:44: | x | 0 | 0.2222222222222222 | 1 | float | INFO - 13:53:44: | y | 0 | 0.2222222222222222 | 1 | float | INFO - 13:53:44: +------+-------------+--------------------+-------------+-------+ INFO - 13:53:44: *** End DOEScenario execution (time: 0:00:00.018256) *** [
] .. GENERATED FROM PYTHON SOURCE LINES 80-89 Sample with reverse mode for :math:`y` -------------------------------------- We can also change the configuration in order to select another diagonal of the input space, e.g. increasing :math:`x` and decreasing :math:`y`. This configuration is illustrated in the new :class:`.ScatterMatrix` plot where the :math:`(x,y)` points follow the :math:`t\mapsto -t` line while the :math:`(x,y)` points follow the :math:`t\mapsto t` line with the default configuration. .. GENERATED FROM PYTHON SOURCE LINES 89-99 .. code-block:: Python scenario = create_scenario( discipline, "DisciplinaryOpt", "z", design_space, scenario_type="DOE" ) scenario.execute({ "algo": "DiagonalDOE", "n_samples": 10, "algo_options": {"reverse": ["y"]}, }) dataset = scenario.to_dataset(opt_naming=False) ScatterMatrix(dataset).execute(save=False, show=True) .. image-sg:: /examples/scalable/images/sphx_glr_plot_diagonal_doe_002.png :alt: plot diagonal doe :srcset: /examples/scalable/images/sphx_glr_plot_diagonal_doe_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 13:53:45: INFO - 13:53:45: *** Start DOEScenario execution *** INFO - 13:53:45: DOEScenario INFO - 13:53:45: Disciplines: AnalyticDiscipline INFO - 13:53:45: MDO formulation: DisciplinaryOpt INFO - 13:53:45: Optimization problem: INFO - 13:53:45: minimize z(x, y) INFO - 13:53:45: with respect to x, y INFO - 13:53:45: over the design space: INFO - 13:53:45: +------+-------------+--------------------+-------------+-------+ INFO - 13:53:45: | Name | Lower bound | Value | Upper bound | Type | INFO - 13:53:45: +------+-------------+--------------------+-------------+-------+ INFO - 13:53:45: | x | 0 | 0.2222222222222222 | 1 | float | INFO - 13:53:45: | y | 0 | 0.2222222222222222 | 1 | float | INFO - 13:53:45: +------+-------------+--------------------+-------------+-------+ INFO - 13:53:45: Solving optimization problem with algorithm DiagonalDOE: INFO - 13:53:45: 10%|█ | 1/10 [00:00<00:00, 1535.81 it/sec, obj=7.35e-16] INFO - 13:53:45: 20%|██ | 2/10 [00:00<00:00, 1538.91 it/sec, obj=2.15] INFO - 13:53:45: 30%|███ | 3/10 [00:00<00:00, 1545.24 it/sec, obj=3.4] INFO - 13:53:45: 40%|████ | 4/10 [00:00<00:00, 1549.57 it/sec, obj=3.26] INFO - 13:53:45: 50%|█████ | 5/10 [00:00<00:00, 1518.46 it/sec, obj=1.91] INFO - 13:53:45: 60%|██████ | 6/10 [00:00<00:00, 1536.00 it/sec, obj=0.0851] INFO - 13:53:45: 70%|███████ | 7/10 [00:00<00:00, 1551.07 it/sec, obj=-1.26] INFO - 13:53:45: 80%|████████ | 8/10 [00:00<00:00, 1562.20 it/sec, obj=-1.4] INFO - 13:53:45: 90%|█████████ | 9/10 [00:00<00:00, 1571.49 it/sec, obj=-0.151] INFO - 13:53:45: 100%|██████████| 10/10 [00:00<00:00, 1579.89 it/sec, obj=2] INFO - 13:53:45: Optimization result: INFO - 13:53:45: Optimizer info: INFO - 13:53:45: Status: None INFO - 13:53:45: Message: None INFO - 13:53:45: Number of calls to the objective function by the optimizer: 10 INFO - 13:53:45: Solution: INFO - 13:53:45: Objective: -1.398867703481069 INFO - 13:53:45: Design space: INFO - 13:53:45: +------+-------------+--------------------+-------------+-------+ INFO - 13:53:45: | Name | Lower bound | Value | Upper bound | Type | INFO - 13:53:45: +------+-------------+--------------------+-------------+-------+ INFO - 13:53:45: | x | 0 | 0.7777777777777777 | 1 | float | INFO - 13:53:45: | y | 0 | 0.2222222222222223 | 1 | float | INFO - 13:53:45: +------+-------------+--------------------+-------------+-------+ INFO - 13:53:45: *** End DOEScenario execution (time: 0:00:00.016633) *** [
] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.816 seconds) .. _sphx_glr_download_examples_scalable_plot_diagonal_doe.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_diagonal_doe.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_diagonal_doe.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_