.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/exterior_penalty/plot_exterior_penalty_sobieski.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_exterior_penalty_plot_exterior_penalty_sobieski.py: Example for exterior penalty applied to the Sobieski test case. =============================================================== .. GENERATED FROM PYTHON SOURCE LINES 22-54 This section describes how to set up and solve the MDO problem relative to the :ref:`Sobieski test case ` with |g| applying external penalty. .. seealso:: To start with a simpler MDO problem, and for a detailed description of how to plug a test case into |g|, see :ref:`sellar_mdo`. .. _sobieski_use_case: Solving with an :ref:`MDF formulation ` -------------------------------------------------------- In this example, we solve the range optimization using the following :ref:`MDF formulation `: - The :ref:`MDF formulation ` couples all the disciplines during the :ref:`mda` at each optimization iteration. - All the :term:`design variables` are equally treated, concatenated in a single vector and given to a single :term:`optimization algorithm` as the unknowns of the problem. - There is no specific :term:`constraint` due to the :ref:`MDF formulation `. - Only the design :term:`constraints` :math:`g\_1`, :math:`g\_2` and :math:`g\_3` are added to the problem. - The :term:`objective function` is the range (the :math:`y\_4` variable in the model), computed after the :ref:`mda`. Imports ------- All the imports needed for the tutorials are performed here. .. GENERATED FROM PYTHON SOURCE LINES 54-67 .. code-block:: Python from __future__ import annotations from gemseo import configure_logger from gemseo import create_discipline from gemseo import create_scenario from gemseo import get_available_formulations from gemseo.disciplines.utils import get_all_inputs from gemseo.disciplines.utils import get_all_outputs from gemseo.formulations.mdf_settings import MDF_Settings from gemseo.problems.mdo.sobieski.core.design_space import SobieskiDesignSpace configure_logger() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 68-74 Step 1: Creation of :class:`.Discipline` ------------------------------------------- To build the scenario, we first instantiate the disciplines. Here, the disciplines themselves have already been developed and interfaced with |g| (see :ref:`benchmark_problems`). .. GENERATED FROM PYTHON SOURCE LINES 74-82 .. code-block:: Python disciplines = create_discipline([ "SobieskiPropulsion", "SobieskiAerodynamics", "SobieskiMission", "SobieskiStructure", ]) .. GENERATED FROM PYTHON SOURCE LINES 83-90 .. tip:: For the disciplines that are not interfaced with |g|, the |g|'s :mod:`~gemseo` eases the creation of disciplines without having to import them. See :ref:`api`. .. GENERATED FROM PYTHON SOURCE LINES 92-108 Step 2: Creation of :class:`.Scenario` -------------------------------------- The scenario delegates the creation of the optimization problem to the :ref:`MDO formulation `. Therefore, it needs the list of ``disciplines``, the name of the formulation (or its settings model), the name of the objective function and the design space. - The ``design_space`` (shown below for reference) defines the unknowns of the optimization problem, and their bounds. It contains all the design variables needed by the :ref:`MDF formulation `. It can be imported from a text file, or created from scratch with the methods :func:`.create_design_space` and :meth:`~gemseo.algos.design_space.DesignSpace.add_variable`. In this case, we will use ``SobieskiDesignSpace`` already defined in |g|. .. GENERATED FROM PYTHON SOURCE LINES 108-110 .. code-block:: Python design_space = SobieskiDesignSpace() x_0 = design_space.get_current_value(as_dict=True) .. GENERATED FROM PYTHON SOURCE LINES 111-142 .. code:: name lower_bound value upper_bound type x_shared 0.01 0.05 0.09 float x_shared 30000.0 45000.0 60000.0 float x_shared 1.4 1.6 1.8 float x_shared 2.5 5.5 8.5 float x_shared 40.0 55.0 70.0 float x_shared 500.0 1000.0 1500.0 float x_1 0.1 0.25 0.4 float x_1 0.75 1.0 1.25 float x_2 0.75 1.0 1.25 float x_3 0.1 0.5 1.0 float y_14 24850.0 50606.9741711 77100.0 float y_14 -7700.0 7306.20262124 45000.0 float y_32 0.235 0.50279625 0.795 float y_31 2960.0 6354.32430691 10185.0 float y_24 0.44 4.15006276 11.13 float y_34 0.44 1.10754577 1.98 float y_23 3365.0 12194.2671934 26400.0 float y_21 24850.0 50606.9741711 77250.0 float y_12 24850.0 50606.9742 77250.0 float y_12 0.45 0.95 1.5 float - The available :ref:`MDO formulations ` are located in the **gemseo.formulations** package, see :ref:`extending-gemseo` for extending GEMSEO with other formulations. - The ``formulation`` name (here, ``"MDF"``) shall be passed to the scenario to select them. - The list of available formulations can be obtained by using :func:`.get_available_formulations`. .. GENERATED FROM PYTHON SOURCE LINES 142-143 .. code-block:: Python get_available_formulations() .. rst-class:: sphx-glr-script-out .. code-block:: none ['BiLevel', 'DisciplinaryOpt', 'IDF', 'MDF'] .. GENERATED FROM PYTHON SOURCE LINES 144-148 - :math:`y\_4` corresponds to the ``objective_name``. This name must be one of the disciplines outputs, here the ``SobieskiMission`` discipline. The list of all outputs of the disciplines can be obtained by using :meth:`~gemseo.disciplines.utils.get_all_outputs`: .. GENERATED FROM PYTHON SOURCE LINES 148-150 .. code-block:: Python get_all_outputs(disciplines) get_all_inputs(disciplines) .. rst-class:: sphx-glr-script-out .. code-block:: none ['c_0', 'c_1', 'c_2', 'c_3', 'c_4', 'x_1', 'x_2', 'x_3', 'x_shared', 'y_12', 'y_14', 'y_21', 'y_23', 'y_24', 'y_31', 'y_32', 'y_34'] .. GENERATED FROM PYTHON SOURCE LINES 151-154 From these :class:`~gemseo.core.discipline.Discipline`, design space, :ref:`MDO formulation ` name and objective function name, we build the scenario: .. GENERATED FROM PYTHON SOURCE LINES 154-162 .. code-block:: Python scenario = create_scenario( disciplines, "y_4", design_space, maximize_objective=True, formulation_name="MDF", ) .. rst-class:: sphx-glr-script-out .. code-block:: none WARNING - 02:41:20: Unsupported feature 'minItems' in JSONGrammar 'SobieskiMission_discipline_output' for property 'y_4' in conversion to SimpleGrammar. WARNING - 02:41:20: Unsupported feature 'maxItems' in JSONGrammar 'SobieskiMission_discipline_output' for property 'y_4' in conversion to SimpleGrammar. .. GENERATED FROM PYTHON SOURCE LINES 163-165 Note that both the formulation settings passed to :func:`.create_scenario` can be provided via a Pydantic model. For more information, see :ref:`formulation_settings`. .. GENERATED FROM PYTHON SOURCE LINES 167-181 The range function (:math:`y\_4`) should be maximized. However, optimizers minimize functions by default. Which is why, when creating the scenario, the argument ``maximize_objective`` shall be set to ``True``. Differentiation method ~~~~~~~~~~~~~~~~~~~~~~ We may choose the way derivatives are computed: **Function derivatives.** As analytical disciplinary derivatives are available for the Sobieski test-case, they can be used instead of computing the derivatives with finite-differences or with the complex-step method. The easiest way to set a method is to let the optimizer determine it: .. GENERATED FROM PYTHON SOURCE LINES 181-182 .. code-block:: Python scenario.set_differentiation_method() .. GENERATED FROM PYTHON SOURCE LINES 183-208 The default behavior of the optimizer triggers :term:`finite differences`. It corresponds to: .. code:: scenario.set_differentiation_method("finite_differences",1e-7) It is also possible to differentiate functions by means of the :term:`complex step` method: .. code:: scenario.set_differentiation_method("complex_step",1e-30j) Constraints ~~~~~~~~~~~ Similarly to the objective function, the constraints names are a subset of the disciplines' outputs. They can be obtained by using :meth:`~gemseo.disciplines.utils.get_all_outputs`. The formulation has a powerful feature to automatically dispatch the constraints (:math:`g\_1, g\_2, g\_3`) and plug them to the optimizers depending on the formulation. To do that, we use the method :meth:`~gemseo.scenarios.scenario.Scenario.add_constraint`: .. GENERATED FROM PYTHON SOURCE LINES 209-211 .. code-block:: Python for constraint in ["g_1", "g_2", "g_3"]: scenario.add_constraint(constraint, constraint_type="ineq") .. GENERATED FROM PYTHON SOURCE LINES 212-214 Step 3: Apply the exterior penalty and execute the scenario ----------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 214-217 .. code-block:: Python scenario.formulation.optimization_problem.apply_exterior_penalty( objective_scale=10.0, scale_inequality=10.0 ) .. GENERATED FROM PYTHON SOURCE LINES 218-220 In this way the L-BFGS-B algorithm can be used to solve the optimization problem. Note that this algorithm is not suited for constrained optimization problems. .. GENERATED FROM PYTHON SOURCE LINES 220-222 .. code-block:: Python scenario.execute(algo_name="L-BFGS-B", max_iter=10) .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 02:41:20: INFO - 02:41:20: *** Start MDOScenario execution *** INFO - 02:41:20: MDOScenario INFO - 02:41:20: Disciplines: SobieskiAerodynamics SobieskiMission SobieskiPropulsion SobieskiStructure INFO - 02:41:20: MDO formulation: MDF INFO - 02:41:20: Optimization problem: INFO - 02:41:20: minimize [[[[-y_4/10.0]+pos_sum_g_1]+pos_sum_g_2]+pos_sum_g_3](x_1, x_2, x_3, x_shared) = -y_4(x_shared, x_1, x_2, x_3)/10.0+sum(heaviside()***2)+sum(heaviside()***2)+sum(heaviside()***2) INFO - 02:41:20: with respect to x_1, x_2, x_3, x_shared INFO - 02:41:20: over the design space: INFO - 02:41:20: +-------------+-------------+-------+-------------+-------+ INFO - 02:41:20: | Name | Lower bound | Value | Upper bound | Type | INFO - 02:41:20: +-------------+-------------+-------+-------------+-------+ INFO - 02:41:20: | x_shared[0] | 0.01 | 0.05 | 0.09 | float | INFO - 02:41:20: | x_shared[1] | 30000 | 45000 | 60000 | float | INFO - 02:41:20: | x_shared[2] | 1.4 | 1.6 | 1.8 | float | INFO - 02:41:20: | x_shared[3] | 2.5 | 5.5 | 8.5 | float | INFO - 02:41:20: | x_shared[4] | 40 | 55 | 70 | float | INFO - 02:41:20: | x_shared[5] | 500 | 1000 | 1500 | float | INFO - 02:41:20: | x_1[0] | 0.1 | 0.25 | 0.4 | float | INFO - 02:41:20: | x_1[1] | 0.75 | 1 | 1.25 | float | INFO - 02:41:20: | x_2 | 0.75 | 1 | 1.25 | float | INFO - 02:41:20: | x_3 | 0.1 | 0.5 | 1 | float | INFO - 02:41:20: +-------------+-------------+-------+-------------+-------+ INFO - 02:41:20: Solving optimization problem with algorithm L-BFGS-B: INFO - 02:41:20: 10%|█ | 1/10 [00:00<00:00, 21.56 it/sec, obj=-53.3] INFO - 02:41:20: 20%|██ | 2/10 [00:00<00:00, 16.37 it/sec, obj=-401] INFO - 02:41:20: 30%|███ | 3/10 [00:00<00:00, 16.05 it/sec, obj=103] INFO - 02:41:20: 40%|████ | 4/10 [00:00<00:00, 15.28 it/sec, obj=-488] INFO - 02:41:20: 50%|█████ | 5/10 [00:00<00:00, 14.73 it/sec, obj=-489] INFO - 02:41:20: 60%|██████ | 6/10 [00:00<00:00, 14.41 it/sec, obj=-489] INFO - 02:41:20: 70%|███████ | 7/10 [00:00<00:00, 14.18 it/sec, obj=-489] INFO - 02:41:20: 80%|████████ | 8/10 [00:00<00:00, 14.06 it/sec, obj=-489] INFO - 02:41:20: 90%|█████████ | 9/10 [00:00<00:00, 13.96 it/sec, obj=-489] INFO - 02:41:20: 100%|██████████| 10/10 [00:00<00:00, 13.87 it/sec, obj=-489] INFO - 02:41:20: Optimization result: INFO - 02:41:20: Optimizer info: INFO - 02:41:20: Status: None INFO - 02:41:20: Message: Maximum number of iterations reached. GEMSEO stopped the driver. INFO - 02:41:20: Number of calls to the objective function by the optimizer: 12 INFO - 02:41:20: Solution: INFO - 02:41:20: Objective: -489.2416290389579 INFO - 02:41:20: Design space: INFO - 02:41:20: +-------------+-------------+--------------------+-------------+-------+ INFO - 02:41:20: | Name | Lower bound | Value | Upper bound | Type | INFO - 02:41:20: +-------------+-------------+--------------------+-------------+-------+ INFO - 02:41:20: | x_shared[0] | 0.01 | 0.09 | 0.09 | float | INFO - 02:41:20: | x_shared[1] | 30000 | 60000 | 60000 | float | INFO - 02:41:20: | x_shared[2] | 1.4 | 1.4 | 1.8 | float | INFO - 02:41:20: | x_shared[3] | 2.5 | 2.5 | 8.5 | float | INFO - 02:41:20: | x_shared[4] | 40 | 70 | 70 | float | INFO - 02:41:20: | x_shared[5] | 500 | 1500 | 1500 | float | INFO - 02:41:20: | x_1[0] | 0.1 | 0.2486534942780023 | 0.4 | float | INFO - 02:41:20: | x_1[1] | 0.75 | 0.75 | 1.25 | float | INFO - 02:41:20: | x_2 | 0.75 | 0.75 | 1.25 | float | INFO - 02:41:20: | x_3 | 0.1 | 0.258406178367566 | 1 | float | INFO - 02:41:20: +-------------+-------------+--------------------+-------------+-------+ INFO - 02:41:20: *** End MDOScenario execution (time: 0:00:00.757958) *** .. GENERATED FROM PYTHON SOURCE LINES 223-225 Note that the algorithm settings passed to :class:`~.BaseDriverLibrary.execute` can be provided via a Pydantic model. For more information, :ref:`algorithm_settings`. .. GENERATED FROM PYTHON SOURCE LINES 227-231 Post-processing options ~~~~~~~~~~~~~~~~~~~~~~~ To visualize the optimization history of the constraint violation one can use the :class:`.BasicHistory`: .. GENERATED FROM PYTHON SOURCE LINES 231-237 .. code-block:: Python scenario.post_process( post_name="BasicHistory", variable_names=["g_1", "g_2", "g_3"], save=False, show=True, ) .. image-sg:: /examples/exterior_penalty/images/sphx_glr_plot_exterior_penalty_sobieski_001.png :alt: History plot :srcset: /examples/exterior_penalty/images/sphx_glr_plot_exterior_penalty_sobieski_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 238-243 This solution is almost feasible. The solution can better approximate the original problem solution increasing the value of `objective_scale` and `scale_inequality` parameters. Step 4: Rerun the scenario with increased penalty and objective scaling. ------------------------------------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 243-245 .. code-block:: Python design_space.set_current_value(x_0) .. GENERATED FROM PYTHON SOURCE LINES 246-249 Here, we use the :class:`.MDF_Settings` model to define the formulation instead of passing the settings one by one as we did the first time. Both ways of defining the settings are equally valid. .. GENERATED FROM PYTHON SOURCE LINES 249-264 .. code-block:: Python scenario_2 = create_scenario( disciplines, "y_4", design_space, formulation_settings_model=MDF_Settings(), maximize_objective=True, ) for constraint in ["g_1", "g_2", "g_3"]: scenario_2.add_constraint(constraint, constraint_type="ineq") scenario_2.set_differentiation_method() scenario_2.formulation.optimization_problem.apply_exterior_penalty( objective_scale=1000.0, scale_inequality=1000.0 ) .. rst-class:: sphx-glr-script-out .. code-block:: none WARNING - 02:41:21: Unsupported feature 'minItems' in JSONGrammar 'SobieskiMission_discipline_output' for property 'y_4' in conversion to SimpleGrammar. WARNING - 02:41:21: Unsupported feature 'maxItems' in JSONGrammar 'SobieskiMission_discipline_output' for property 'y_4' in conversion to SimpleGrammar. .. GENERATED FROM PYTHON SOURCE LINES 265-268 Here, we use the :class:`.L_BFGS_B_Settings` model to define the algorithm settings instead of passing them one by one as we did the first time. Both ways of defining the settings are equally valid. .. GENERATED FROM PYTHON SOURCE LINES 268-275 .. code-block:: Python from gemseo.settings.opt import L_BFGS_B_Settings # noqa: E402 scenario_2.execute(L_BFGS_B_Settings(max_iter=1000)) scenario_2.post_process( post_name="BasicHistory", variable_names=["-y_4"], save=False, show=True ) .. image-sg:: /examples/exterior_penalty/images/sphx_glr_plot_exterior_penalty_sobieski_002.png :alt: History plot :srcset: /examples/exterior_penalty/images/sphx_glr_plot_exterior_penalty_sobieski_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 02:41:21: INFO - 02:41:21: *** Start MDOScenario execution *** INFO - 02:41:21: MDOScenario INFO - 02:41:21: Disciplines: SobieskiAerodynamics SobieskiMission SobieskiPropulsion SobieskiStructure INFO - 02:41:21: MDO formulation: MDF INFO - 02:41:21: Optimization problem: INFO - 02:41:21: minimize [[[[-y_4/1000.0]+pos_sum_g_1]+pos_sum_g_2]+pos_sum_g_3](x_1, x_2, x_3, x_shared) = -y_4(x_shared, x_1, x_2, x_3)/1000.0+sum(heaviside()***2)+sum(heaviside()***2)+sum(heaviside()***2) INFO - 02:41:21: with respect to x_1, x_2, x_3, x_shared INFO - 02:41:21: over the design space: INFO - 02:41:21: +-------------+-------------+-------+-------------+-------+ INFO - 02:41:21: | Name | Lower bound | Value | Upper bound | Type | INFO - 02:41:21: +-------------+-------------+-------+-------------+-------+ INFO - 02:41:21: | x_shared[0] | 0.01 | 0.05 | 0.09 | float | INFO - 02:41:21: | x_shared[1] | 30000 | 45000 | 60000 | float | INFO - 02:41:21: | x_shared[2] | 1.4 | 1.6 | 1.8 | float | INFO - 02:41:21: | x_shared[3] | 2.5 | 5.5 | 8.5 | float | INFO - 02:41:21: | x_shared[4] | 40 | 55 | 70 | float | INFO - 02:41:21: | x_shared[5] | 500 | 1000 | 1500 | float | INFO - 02:41:21: | x_1[0] | 0.1 | 0.25 | 0.4 | float | INFO - 02:41:21: | x_1[1] | 0.75 | 1 | 1.25 | float | INFO - 02:41:21: | x_2 | 0.75 | 1 | 1.25 | float | INFO - 02:41:21: | x_3 | 0.1 | 0.5 | 1 | float | INFO - 02:41:21: +-------------+-------------+-------+-------------+-------+ INFO - 02:41:21: Solving optimization problem with algorithm L-BFGS-B: INFO - 02:41:21: 1%| | 6/1000 [00:00<01:03, 15.53 it/sec, obj=-0.428] INFO - 02:41:21: 1%| | 7/1000 [00:00<01:03, 15.64 it/sec, obj=-0.504] INFO - 02:41:21: 1%| | 8/1000 [00:00<01:02, 15.81 it/sec, obj=-0.413] INFO - 02:41:21: 1%| | 9/1000 [00:00<01:02, 15.96 it/sec, obj=-0.521] INFO - 02:41:21: 1%| | 10/1000 [00:00<01:01, 16.16 it/sec, obj=-0.537] INFO - 02:41:21: 1%| | 11/1000 [00:00<01:00, 16.33 it/sec, obj=-0.54] INFO - 02:41:22: 1%| | 12/1000 [00:00<00:59, 16.47 it/sec, obj=-0.541] INFO - 02:41:22: 1%|▏ | 13/1000 [00:00<00:59, 16.59 it/sec, obj=-0.521] INFO - 02:41:22: 1%|▏ | 14/1000 [00:00<00:59, 16.70 it/sec, obj=-0.541] INFO - 02:41:22: 2%|▏ | 15/1000 [00:00<00:58, 16.70 it/sec, obj=4.92] INFO - 02:41:22: 2%|▏ | 16/1000 [00:00<00:58, 16.79 it/sec, obj=-0.542] INFO - 02:41:22: 2%|▏ | 17/1000 [00:01<00:58, 16.88 it/sec, obj=-0.542] INFO - 02:41:22: 2%|▏ | 18/1000 [00:01<00:58, 16.91 it/sec, obj=0.751] INFO - 02:41:22: 2%|▏ | 19/1000 [00:01<00:57, 16.98 it/sec, obj=-0.542] INFO - 02:41:22: 2%|▏ | 20/1000 [00:01<00:57, 16.99 it/sec, obj=-0.589] INFO - 02:41:22: 2%|▏ | 21/1000 [00:01<00:57, 16.91 it/sec, obj=28.5] INFO - 02:41:22: 2%|▏ | 22/1000 [00:01<00:57, 16.92 it/sec, obj=-0.601] INFO - 02:41:22: 2%|▏ | 23/1000 [00:01<00:57, 16.93 it/sec, obj=-0.609] INFO - 02:41:22: 2%|▏ | 24/1000 [00:01<00:57, 16.90 it/sec, obj=2.4] INFO - 02:41:22: 2%|▎ | 25/1000 [00:01<00:57, 16.88 it/sec, obj=-0.625] INFO - 02:41:22: 3%|▎ | 26/1000 [00:01<00:57, 16.86 it/sec, obj=-0.639] INFO - 02:41:22: 3%|▎ | 27/1000 [00:01<00:57, 16.84 it/sec, obj=-0.311] INFO - 02:41:22: 3%|▎ | 28/1000 [00:01<00:57, 16.80 it/sec, obj=-0.645] INFO - 02:41:23: 3%|▎ | 29/1000 [00:01<00:57, 16.78 it/sec, obj=-0.65] INFO - 02:41:23: 3%|▎ | 30/1000 [00:01<00:57, 16.74 it/sec, obj=-0.611] INFO - 02:41:23: 3%|▎ | 31/1000 [00:01<00:57, 16.72 it/sec, obj=2.98] INFO - 02:41:23: 3%|▎ | 32/1000 [00:01<00:57, 16.71 it/sec, obj=-0.651] INFO - 02:41:23: 3%|▎ | 33/1000 [00:01<00:57, 16.70 it/sec, obj=0.77] INFO - 02:41:23: 3%|▎ | 34/1000 [00:02<00:57, 16.69 it/sec, obj=-0.652] INFO - 02:41:23: 4%|▎ | 35/1000 [00:02<00:57, 16.68 it/sec, obj=-0.103] INFO - 02:41:23: 4%|▎ | 36/1000 [00:02<00:57, 16.67 it/sec, obj=-0.654] INFO - 02:41:23: 4%|▎ | 37/1000 [00:02<00:57, 16.65 it/sec, obj=-0.444] INFO - 02:41:23: 4%|▍ | 38/1000 [00:02<00:57, 16.64 it/sec, obj=-0.655] INFO - 02:41:23: 4%|▍ | 39/1000 [00:02<00:57, 16.63 it/sec, obj=-0.574] INFO - 02:41:23: 4%|▍ | 40/1000 [00:02<00:57, 16.63 it/sec, obj=-0.656] INFO - 02:41:23: 4%|▍ | 41/1000 [00:02<00:57, 16.63 it/sec, obj=-0.624] INFO - 02:41:23: 4%|▍ | 42/1000 [00:02<00:57, 16.63 it/sec, obj=-0.657] INFO - 02:41:23: 4%|▍ | 43/1000 [00:02<00:57, 16.62 it/sec, obj=-0.658] INFO - 02:41:23: 4%|▍ | 44/1000 [00:02<00:57, 16.62 it/sec, obj=-0.669] INFO - 02:41:24: 4%|▍ | 45/1000 [00:02<00:57, 16.62 it/sec, obj=-0.68] INFO - 02:41:24: 5%|▍ | 46/1000 [00:02<00:57, 16.61 it/sec, obj=-0.686] INFO - 02:41:24: 5%|▍ | 47/1000 [00:02<00:57, 16.61 it/sec, obj=-0.694] INFO - 02:41:24: 5%|▍ | 48/1000 [00:02<00:57, 16.56 it/sec, obj=-0.774] INFO - 02:41:24: 5%|▍ | 49/1000 [00:02<00:57, 16.49 it/sec, obj=-1.19] INFO - 02:41:24: 5%|▌ | 50/1000 [00:03<00:58, 16.35 it/sec, obj=-1.69] INFO - 02:41:24: 5%|▌ | 51/1000 [00:03<00:58, 16.22 it/sec, obj=-1.7] INFO - 02:41:24: 5%|▌ | 52/1000 [00:03<00:58, 16.10 it/sec, obj=-1.71] INFO - 02:41:24: 5%|▌ | 53/1000 [00:03<00:59, 15.98 it/sec, obj=-1.75] INFO - 02:41:24: 5%|▌ | 54/1000 [00:03<00:59, 15.91 it/sec, obj=-1.93] INFO - 02:41:24: 6%|▌ | 55/1000 [00:03<00:59, 15.86 it/sec, obj=-2.17] INFO - 02:41:24: 6%|▌ | 56/1000 [00:03<00:59, 15.81 it/sec, obj=-2.19] INFO - 02:41:24: 6%|▌ | 57/1000 [00:03<00:59, 15.77 it/sec, obj=-2.28] INFO - 02:41:25: 6%|▌ | 58/1000 [00:03<00:59, 15.72 it/sec, obj=-2.29] INFO - 02:41:25: 6%|▌ | 59/1000 [00:03<01:00, 15.67 it/sec, obj=-2.3] INFO - 02:41:25: 6%|▌ | 60/1000 [00:03<01:00, 15.62 it/sec, obj=-2.35] INFO - 02:41:25: 6%|▌ | 61/1000 [00:03<01:00, 15.58 it/sec, obj=-2.1] INFO - 02:41:25: 6%|▌ | 62/1000 [00:03<01:00, 15.54 it/sec, obj=-2.4] INFO - 02:41:25: 6%|▋ | 63/1000 [00:04<01:00, 15.50 it/sec, obj=25.5] INFO - 02:41:25: 6%|▋ | 64/1000 [00:04<01:00, 15.46 it/sec, obj=-2.41] INFO - 02:41:25: 6%|▋ | 65/1000 [00:04<01:00, 15.42 it/sec, obj=3.96] INFO - 02:41:25: 7%|▋ | 66/1000 [00:04<01:00, 15.39 it/sec, obj=-2.42] INFO - 02:41:25: 7%|▋ | 67/1000 [00:04<01:00, 15.35 it/sec, obj=0.179] INFO - 02:41:25: 7%|▋ | 68/1000 [00:04<01:00, 15.33 it/sec, obj=-2.43] INFO - 02:41:25: 7%|▋ | 69/1000 [00:04<01:00, 15.30 it/sec, obj=-1.35] INFO - 02:41:25: 7%|▋ | 70/1000 [00:04<01:00, 15.27 it/sec, obj=-2.43] INFO - 02:41:25: 7%|▋ | 71/1000 [00:04<01:00, 15.25 it/sec, obj=-2.51] INFO - 02:41:26: 7%|▋ | 72/1000 [00:04<01:00, 15.22 it/sec, obj=-2.9] INFO - 02:41:26: 7%|▋ | 73/1000 [00:04<01:01, 15.19 it/sec, obj=-3.17] INFO - 02:41:26: 7%|▋ | 74/1000 [00:04<01:01, 15.15 it/sec, obj=-3.17] INFO - 02:41:26: 8%|▊ | 75/1000 [00:04<01:01, 15.12 it/sec, obj=-3.2] INFO - 02:41:26: 8%|▊ | 76/1000 [00:05<01:01, 15.09 it/sec, obj=-2.81] INFO - 02:41:26: 8%|▊ | 77/1000 [00:05<01:01, 15.06 it/sec, obj=-3.2] INFO - 02:41:26: 8%|▊ | 78/1000 [00:05<01:01, 15.03 it/sec, obj=-3.23] INFO - 02:41:26: 8%|▊ | 79/1000 [00:05<01:01, 15.01 it/sec, obj=-3.35] INFO - 02:41:26: 8%|▊ | 80/1000 [00:05<01:01, 15.00 it/sec, obj=-3.39] INFO - 02:41:26: 8%|▊ | 81/1000 [00:05<01:01, 14.98 it/sec, obj=-3.67] INFO - 02:41:26: 8%|▊ | 82/1000 [00:05<01:01, 14.96 it/sec, obj=-3.73] INFO - 02:41:26: 8%|▊ | 83/1000 [00:05<01:01, 14.94 it/sec, obj=-3.96] INFO - 02:41:26: 8%|▊ | 84/1000 [00:05<01:01, 14.91 it/sec, obj=-4.24] INFO - 02:41:27: 8%|▊ | 85/1000 [00:05<01:01, 14.88 it/sec, obj=-4.27] INFO - 02:41:27: 9%|▊ | 86/1000 [00:05<01:01, 14.85 it/sec, obj=-4.27] INFO - 02:41:27: 9%|▊ | 87/1000 [00:05<01:01, 14.83 it/sec, obj=-4.28] INFO - 02:41:27: 9%|▉ | 88/1000 [00:05<01:01, 14.81 it/sec, obj=-4.31] INFO - 02:41:27: 9%|▉ | 89/1000 [00:06<01:01, 14.78 it/sec, obj=-4.39] INFO - 02:41:27: 9%|▉ | 90/1000 [00:06<01:01, 14.76 it/sec, obj=-4.39] INFO - 02:41:27: 9%|▉ | 91/1000 [00:06<01:01, 14.74 it/sec, obj=-4.39] INFO - 02:41:27: 9%|▉ | 92/1000 [00:06<01:01, 14.71 it/sec, obj=-4.4] INFO - 02:41:27: 9%|▉ | 93/1000 [00:06<01:01, 14.69 it/sec, obj=-3.7] INFO - 02:41:27: 9%|▉ | 94/1000 [00:06<01:01, 14.67 it/sec, obj=-4.4] INFO - 02:41:27: 10%|▉ | 95/1000 [00:06<01:01, 14.66 it/sec, obj=-4.15] INFO - 02:41:27: 10%|▉ | 96/1000 [00:06<01:01, 14.64 it/sec, obj=-4.41] INFO - 02:41:27: 10%|▉ | 97/1000 [00:06<01:01, 14.62 it/sec, obj=-4.31] INFO - 02:41:28: 10%|▉ | 98/1000 [00:06<01:01, 14.60 it/sec, obj=-4.41] INFO - 02:41:28: 10%|▉ | 99/1000 [00:06<01:01, 14.58 it/sec, obj=-4.37] INFO - 02:41:28: 10%|█ | 100/1000 [00:06<01:01, 14.56 it/sec, obj=-4.41] INFO - 02:41:28: 10%|█ | 101/1000 [00:06<01:01, 14.54 it/sec, obj=-1.72] INFO - 02:41:28: 10%|█ | 102/1000 [00:07<01:01, 14.52 it/sec, obj=-4.41] INFO - 02:41:28: 10%|█ | 103/1000 [00:07<01:01, 14.51 it/sec, obj=-4.41] INFO - 02:41:28: 10%|█ | 104/1000 [00:07<01:01, 14.49 it/sec, obj=-4.41] INFO - 02:41:28: 10%|█ | 105/1000 [00:07<01:01, 14.47 it/sec, obj=-4.41] INFO - 02:41:28: 11%|█ | 106/1000 [00:07<01:01, 14.46 it/sec, obj=-4.41] INFO - 02:41:28: 11%|█ | 107/1000 [00:07<01:01, 14.44 it/sec, obj=-4.41] INFO - 02:41:28: 11%|█ | 108/1000 [00:07<01:01, 14.43 it/sec, obj=-4.41] INFO - 02:41:28: 11%|█ | 109/1000 [00:07<01:01, 14.41 it/sec, obj=-4.41] INFO - 02:41:28: 11%|█ | 110/1000 [00:07<01:01, 14.40 it/sec, obj=-4.41] INFO - 02:41:29: 11%|█ | 111/1000 [00:07<01:01, 14.38 it/sec, obj=-4.41] INFO - 02:41:29: 11%|█ | 112/1000 [00:07<01:01, 14.36 it/sec, obj=-4.41] INFO - 02:41:29: 11%|█▏ | 113/1000 [00:07<01:01, 14.35 it/sec, obj=-4.41] INFO - 02:41:29: 11%|█▏ | 114/1000 [00:07<01:01, 14.33 it/sec, obj=-4.41] INFO - 02:41:29: 12%|█▏ | 115/1000 [00:08<01:01, 14.32 it/sec, obj=-4.41] INFO - 02:41:29: 12%|█▏ | 116/1000 [00:08<01:01, 14.31 it/sec, obj=-4.41] INFO - 02:41:29: Optimization result: INFO - 02:41:29: Optimizer info: INFO - 02:41:29: Status: 0 INFO - 02:41:29: Message: CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL INFO - 02:41:29: Number of calls to the objective function by the optimizer: 118 INFO - 02:41:29: Solution: INFO - 02:41:29: Objective: -4.4116962873840135 INFO - 02:41:29: Design space: INFO - 02:41:29: +-------------+-------------+--------------------+-------------+-------+ INFO - 02:41:29: | Name | Lower bound | Value | Upper bound | Type | INFO - 02:41:29: +-------------+-------------+--------------------+-------------+-------+ INFO - 02:41:29: | x_shared[0] | 0.01 | 0.09 | 0.09 | float | INFO - 02:41:29: | x_shared[1] | 30000 | 60000 | 60000 | float | INFO - 02:41:29: | x_shared[2] | 1.4 | 1.4 | 1.8 | float | INFO - 02:41:29: | x_shared[3] | 2.5 | 2.5 | 8.5 | float | INFO - 02:41:29: | x_shared[4] | 40 | 70 | 70 | float | INFO - 02:41:29: | x_shared[5] | 500 | 1500 | 1500 | float | INFO - 02:41:29: | x_1[0] | 0.1 | 0.4 | 0.4 | float | INFO - 02:41:29: | x_1[1] | 0.75 | 0.75 | 1.25 | float | INFO - 02:41:29: | x_2 | 0.75 | 0.75 | 1.25 | float | INFO - 02:41:29: | x_3 | 0.1 | 0.1563542074363522 | 1 | float | INFO - 02:41:29: +-------------+-------------+--------------------+-------------+-------+ INFO - 02:41:29: *** End MDOScenario execution (time: 0:00:08.146409) *** .. GENERATED FROM PYTHON SOURCE LINES 276-279 Here, we use the :class:`.BasicHistory_Settings` model to define the post-processor settings instead of passing them one by one as we did the first time. Both ways of defining the settings are equally valid. .. GENERATED FROM PYTHON SOURCE LINES 279-288 .. code-block:: Python from gemseo.settings.post import BasicHistory_Settings # noqa: E402 scenario_2.post_process( BasicHistory_Settings( variable_names=["g_1", "g_2", "g_3"], save=False, show=True, ) ) .. image-sg:: /examples/exterior_penalty/images/sphx_glr_plot_exterior_penalty_sobieski_003.png :alt: History plot :srcset: /examples/exterior_penalty/images/sphx_glr_plot_exterior_penalty_sobieski_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 289-291 The solution feasibility was improved but this comes with a much higher number of iterations. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 9.813 seconds) .. _sphx_glr_download_examples_exterior_penalty_plot_exterior_penalty_sobieski.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_exterior_penalty_sobieski.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_exterior_penalty_sobieski.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_exterior_penalty_sobieski.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_