.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/dataset/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_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-37 .. code-block:: default 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 Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 38-42 Synthetic data -------------- We can sample the :class:`.Sellar1` discipline and use the corresponding :class:`.OptimizationProblem`: .. GENERATED FROM PYTHON SOURCE LINES 42-52 .. 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 Out: .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/gemseo/envs/4.0.1/lib/python3.9/site-packages/gemseo/algos/design_space.py:448: ComplexWarning: Casting complex values to real discards the imaginary part self.__current_value[name] = array_value.astype( INFO - 10:06:04: INFO - 10:06:04: *** Start DOEScenario execution *** INFO - 10:06:04: DOEScenario INFO - 10:06:04: Disciplines: Sellar1 INFO - 10:06:04: MDO formulation: DisciplinaryOpt INFO - 10:06:04: Optimization problem: INFO - 10:06:04: minimize y_1(x_local, x_shared, y_2) INFO - 10:06:04: with respect to x_local, x_shared, y_2 INFO - 10:06:04: over the design space: INFO - 10:06:04: +----------+-------------+-------+-------------+-------+ INFO - 10:06:04: | name | lower_bound | value | upper_bound | type | INFO - 10:06:04: +----------+-------------+-------+-------------+-------+ INFO - 10:06:04: | x_local | 0 | 1 | 10 | float | INFO - 10:06:04: | x_shared | -10 | 4 | 10 | float | INFO - 10:06:04: | x_shared | 0 | 3 | 10 | float | INFO - 10:06:04: | y_2 | -100 | 1 | 100 | float | INFO - 10:06:04: +----------+-------------+-------+-------------+-------+ INFO - 10:06:04: Solving optimization problem with algorithm lhs: INFO - 10:06:04: ... 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 `_