.. 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 31-47 .. code-block:: default from __future__ import absolute_import, division, print_function, unicode_literals from future import standard_library from gemseo.api import ( configure_logger, create_design_space, create_discipline, create_scenario, ) from gemseo.core.mdo_scenario import MDOScenarioAdapter configure_logger() standard_library.install_aliases() .. GENERATED FROM PYTHON SOURCE LINES 48-50 Create the disciplines ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 50-57 .. code-block:: default objective = create_discipline( "AnalyticDiscipline", expressions_dict={"obj": "x**3-x+1"} ) constraint = create_discipline( "AnalyticDiscipline", expressions_dict={"cstr": "x**2+obj**2-1.5"} ) .. GENERATED FROM PYTHON SOURCE LINES 58-60 Create the design space ----------------------- .. GENERATED FROM PYTHON SOURCE LINES 60-63 .. code-block:: default design_space = create_design_space() design_space.add_variable("x", 1, l_b=-1.5, u_b=1.5, value=1.5) .. GENERATED FROM PYTHON SOURCE LINES 64-66 Create the MDO scenario ----------------------- .. GENERATED FROM PYTHON SOURCE LINES 66-75 .. 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 76-78 Create the scenario adapter --------------------------- .. GENERATED FROM PYTHON SOURCE LINES 78-83 .. 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 84-86 Create the DOE scenario ----------------------- .. GENERATED FROM PYTHON SOURCE LINES 86-97 .. 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 Out: .. code-block:: none {'eval_jac': False, 'algo': 'fullfact', 'n_samples': 10} .. GENERATED FROM PYTHON SOURCE LINES 98-100 Plot the optimum objective for different x0 ------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 100-101 .. code-block:: default scenario_doe.post_process("BasicHistory", data_list=["obj"], save=False, show=True) .. image:: /examples/scenario_adapter/images/sphx_glr_plot_multistart_example_001.png :alt: History plot :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.611 seconds) .. _sphx_glr_download_examples_scenario_adapter_plot_multistart_example.py: .. only :: html .. container:: sphx-glr-footer :class: 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 `_