.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/scenario_adapter/plot_multistart_example.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_scenario_adapter_plot_multistart_example.py: Multistart optimization ======================= Runs simple optimization problem with multiple starting points Nests a :class:`.MDOScenario` in a :class:`.DOEScenario` using a :class:`.MDOScenarioAdapter`. .. GENERATED FROM PYTHON SOURCE LINES 29-40 .. code-block:: default from __future__ import annotations from gemseo.api import configure_logger from gemseo.api import create_design_space from gemseo.api import create_discipline from gemseo.api import create_scenario from gemseo.disciplines.scenario_adapter import MDOScenarioAdapter configure_logger() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 41-43 Create the disciplines ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 43-48 .. code-block:: default objective = create_discipline("AnalyticDiscipline", expressions={"obj": "x**3-x+1"}) constraint = create_discipline( "AnalyticDiscipline", expressions={"cstr": "x**2+obj**2-1.5"} ) .. GENERATED FROM PYTHON SOURCE LINES 49-51 Create the design space ----------------------- .. GENERATED FROM PYTHON SOURCE LINES 51-54 .. code-block:: default design_space = create_design_space() design_space.add_variable("x", l_b=-1.5, u_b=1.5, value=1.5) .. GENERATED FROM PYTHON SOURCE LINES 55-57 Create the MDO scenario ----------------------- .. GENERATED FROM PYTHON SOURCE LINES 57-66 .. code-block:: default scenario = create_scenario( [objective, constraint], formulation="DisciplinaryOpt", objective_name="obj", design_space=design_space, ) scenario.default_inputs = {"algo": "SLSQP", "max_iter": 10} scenario.add_constraint("cstr", "ineq") .. GENERATED FROM PYTHON SOURCE LINES 67-69 Create the scenario adapter --------------------------- .. GENERATED FROM PYTHON SOURCE LINES 69-74 .. code-block:: default dv_names = scenario.formulation.opt_problem.design_space.variables_names adapter = MDOScenarioAdapter( scenario, dv_names, ["obj", "cstr"], set_x0_before_opt=True ) .. GENERATED FROM PYTHON SOURCE LINES 75-77 Create the DOE scenario ----------------------- .. GENERATED FROM PYTHON SOURCE LINES 77-88 .. code-block:: default scenario_doe = create_scenario( adapter, formulation="DisciplinaryOpt", objective_name="obj", design_space=design_space, scenario_type="DOE", ) scenario_doe.add_constraint("cstr", "ineq") run_inputs = {"n_samples": 10, "algo": "fullfact"} scenario_doe.execute(run_inputs) .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 16:58:47: INFO - 16:58:47: *** Start DOEScenario execution *** INFO - 16:58:47: DOEScenario INFO - 16:58:47: Disciplines: MDOScenario_adapter INFO - 16:58:47: MDO formulation: DisciplinaryOpt INFO - 16:58:47: Optimization problem: INFO - 16:58:47: minimize obj(x) INFO - 16:58:47: with respect to x INFO - 16:58:47: subject to constraints: INFO - 16:58:47: cstr(x) <= 0.0 INFO - 16:58:47: over the design space: INFO - 16:58:47: +------+-------------+-------+-------------+-------+ INFO - 16:58:47: | name | lower_bound | value | upper_bound | type | INFO - 16:58:47: +------+-------------+-------+-------------+-------+ INFO - 16:58:47: | x | -1.5 | 1.5 | 1.5 | float | INFO - 16:58:47: +------+-------------+-------+-------------+-------+ INFO - 16:58:47: Solving optimization problem with algorithm fullfact: INFO - 16:58:47: ... 0%| | 0/10 [00:00 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.473 seconds) .. _sphx_glr_download_examples_scenario_adapter_plot_multistart_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_multistart_example.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_multistart_example.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_