.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/dataset/creation/plot_dataset_from_optproblem.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_dataset_creation_plot_dataset_from_optproblem.py: Dataset from an optimization problem ==================================== In this example, we will see how to build a :class:`.Dataset` from objects of an :class:`.OptimizationProblem`. For that, we need to import this :class:`.Dataset` class: .. GENERATED FROM PYTHON SOURCE LINES 29-39 .. code-block:: default from __future__ import annotations from gemseo.api import configure_logger from gemseo.api import create_discipline from gemseo.api import create_scenario from gemseo.problems.sellar.sellar_design_space import SellarDesignSpace configure_logger() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 40-44 Synthetic data -------------- We can sample the :class:`.Sellar1` discipline and use the corresponding :class:`.OptimizationProblem`: .. GENERATED FROM PYTHON SOURCE LINES 44-54 .. code-block:: default discipline = create_discipline("Sellar1") design_space = SellarDesignSpace().filter(discipline.get_input_data_names()) scenario = create_scenario( [discipline], "DisciplinaryOpt", "y_1", design_space, scenario_type="DOE" ) scenario.execute({"algo": "lhs", "n_samples": 5}) opt_problem = scenario.formulation.opt_problem .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/4.3.0.post0/lib/python3.9/site-packages/gemseo/algos/design_space.py:458: ComplexWarning: Casting complex values to real discards the imaginary part self.__current_value[name] = array_value.astype( INFO - 16:58:48: INFO - 16:58:48: *** Start DOEScenario execution *** INFO - 16:58:48: DOEScenario INFO - 16:58:48: Disciplines: Sellar1 INFO - 16:58:48: MDO formulation: DisciplinaryOpt INFO - 16:58:48: Optimization problem: INFO - 16:58:48: minimize y_1(x_local, x_shared, y_2) INFO - 16:58:48: with respect to x_local, x_shared, y_2 INFO - 16:58:48: over the design space: INFO - 16:58:48: +-------------+-------------+-------+-------------+-------+ INFO - 16:58:48: | name | lower_bound | value | upper_bound | type | INFO - 16:58:48: +-------------+-------------+-------+-------------+-------+ INFO - 16:58:48: | x_local | 0 | 1 | 10 | float | INFO - 16:58:48: | x_shared[0] | -10 | 4 | 10 | float | INFO - 16:58:48: | x_shared[1] | 0 | 3 | 10 | float | INFO - 16:58:48: | y_2 | -100 | 1 | 100 | float | INFO - 16:58:48: +-------------+-------------+-------+-------------+-------+ INFO - 16:58:48: Solving optimization problem with algorithm lhs: INFO - 16:58:48: ... 0%| | 0/5 [00:00` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_dataset_from_optproblem.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_