.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/formulations/plot_sobieski_bilevel_example.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_formulations_plot_sobieski_bilevel_example.py: BiLevel-based MDO on the Sobieski SSBJ test case ================================================ .. GENERATED FROM PYTHON SOURCE LINES 24-41 .. code-block:: Python from __future__ import annotations from copy import deepcopy from logging import WARNING from gemseo import configure_logger from gemseo import create_discipline from gemseo import create_scenario from gemseo import execute_post from gemseo.problems.mdo.sobieski.core.design_space import SobieskiDesignSpace from gemseo.settings.mda import MDAGaussSeidel_Settings from gemseo.settings.opt import NLOPT_COBYLA_Settings from gemseo.settings.opt import SLSQP_Settings configure_logger() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 42-49 Instantiate the disciplines ---------------------------- First, we instantiate the four disciplines of the use case: :class:`.SobieskiPropulsion`, :class:`.SobieskiAerodynamics`, :class:`.SobieskiMission` and :class:`.SobieskiStructure`. .. GENERATED FROM PYTHON SOURCE LINES 49-56 .. code-block:: Python propu, aero, mission, struct = create_discipline([ "SobieskiPropulsion", "SobieskiAerodynamics", "SobieskiMission", "SobieskiStructure", ]) .. GENERATED FROM PYTHON SOURCE LINES 57-65 Build, execute and post-process the scenario -------------------------------------------- Then, we build the scenario which links the disciplines with the formulation and the optimization algorithm. Here, we use the :class:`.BiLevel` formulation. We tell the scenario to minimize -y_4 instead of minimizing y_4 (range), which is the default option. We need to define the design space. .. GENERATED FROM PYTHON SOURCE LINES 65-67 .. code-block:: Python design_space = SobieskiDesignSpace() .. GENERATED FROM PYTHON SOURCE LINES 68-71 Then, we build a sub-scenario for each strongly coupled disciplines, using the following algorithm, maximum number of iterations and algorithm settings: .. GENERATED FROM PYTHON SOURCE LINES 71-90 .. code-block:: Python slsqp_settings = SLSQP_Settings( max_iter=30, xtol_rel=1e-7, xtol_abs=1e-7, ftol_rel=1e-7, ftol_abs=1e-7, ineq_tolerance=1e-4, ) cobyla_settings = NLOPT_COBYLA_Settings( max_iter=140, xtol_rel=1e-7, xtol_abs=1e-7, ftol_rel=1e-7, ftol_abs=1e-7, ineq_tolerance=1e-4, ) .. GENERATED FROM PYTHON SOURCE LINES 91-94 Build a sub-scenario for Propulsion ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This sub-scenario will minimize SFC. .. GENERATED FROM PYTHON SOURCE LINES 94-104 .. code-block:: Python sc_prop = create_scenario( propu, "y_34", design_space.filter("x_3", copy=True), name="PropulsionScenario", formulation_name="DisciplinaryOpt", ) sc_prop.set_algorithm(slsqp_settings) sc_prop.add_constraint("g_3", constraint_type="ineq") .. GENERATED FROM PYTHON SOURCE LINES 105-108 Build a sub-scenario for Aerodynamics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This sub-scenario will minimize L/D. .. GENERATED FROM PYTHON SOURCE LINES 108-119 .. code-block:: Python sc_aero = create_scenario( aero, "y_24", design_space.filter("x_2", copy=True), name="AerodynamicsScenario", maximize_objective=True, formulation_name="DisciplinaryOpt", ) sc_aero.set_algorithm(slsqp_settings) sc_aero.add_constraint("g_2", constraint_type="ineq") .. GENERATED FROM PYTHON SOURCE LINES 120-124 Build a sub-scenario for Structure ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This sub-scenario will maximize log(aircraft total weight / (aircraft total weight - fuel weight)). .. GENERATED FROM PYTHON SOURCE LINES 124-135 .. code-block:: Python sc_str = create_scenario( struct, "y_11", design_space.filter("x_1", copy=True), name="StructureScenario", maximize_objective=True, formulation_name="DisciplinaryOpt", ) sc_str.add_constraint("g_1", constraint_type="ineq") sc_str.set_algorithm(slsqp_settings) .. GENERATED FROM PYTHON SOURCE LINES 136-140 Build a scenario for Mission ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This scenario is based on the three previous sub-scenarios and on the Mission and aims to maximize the range (Breguet). .. GENERATED FROM PYTHON SOURCE LINES 140-160 .. code-block:: Python system_scenario = create_scenario( [sc_prop, sc_aero, sc_str, mission], "y_4", design_space.filter("x_shared", copy=True), apply_cstr_tosub_scenarios=False, parallel_scenarios=False, multithread_scenarios=True, main_mda_settings=MDAGaussSeidel_Settings( tolerance=1e-14, max_mda_iter=50, warm_start=True, use_lu_fact=False, linear_solver_tolerance=1e-14, ), maximize_objective=True, sub_scenarios_log_level=WARNING, formulation_name="BiLevel", ) system_scenario.add_constraint(["g_1", "g_2", "g_3"], constraint_type="ineq") .. GENERATED FROM PYTHON SOURCE LINES 161-171 .. tip:: When running BiLevel scenarios, it is interesting to access the optimization history of the sub-scenarios for each system iteration. By default, the setting ``keep_opt_history`` is set to ``True``. This allows you to store in memory the databases of the sub-scenarios (see the last section of this example for more details). In some cases, storing the databases in memory can take up too much space and cause performance issues. In these cases, set ``keep_opt_history=False`` and save the databases to the disk using ``save_opt_history=True``. .. GENERATED FROM PYTHON SOURCE LINES 173-180 Visualize the XDSM ^^^^^^^^^^^^^^^^^^ Generate the XDSM on the fly: - ``log_workflow_status=True`` will log the status of the workflow in the console, - ``save_html`` (default ``True``) will generate a self-contained HTML file, that can be automatically opened using ``show_html=True``. .. GENERATED FROM PYTHON SOURCE LINES 180-182 .. code-block:: Python system_scenario.xdsmize(save_html=False) .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 183-185 Execute the main scenario ^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 185-187 .. code-block:: Python system_scenario.execute(cobyla_settings) .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 20:37:18: *** Start MDOScenario execution *** INFO - 20:37:18: MDOScenario INFO - 20:37:18: Disciplines: AerodynamicsScenario PropulsionScenario SobieskiMission StructureScenario INFO - 20:37:18: MDO formulation: BiLevel INFO - 20:37:18: Optimization problem: INFO - 20:37:18: minimize -y_4(x_shared) INFO - 20:37:18: with respect to x_shared INFO - 20:37:18: under the inequality constraints INFO - 20:37:18: g_1_g_2_g_3(x_shared) <= 0 INFO - 20:37:18: over the design space: INFO - 20:37:18: +-------------+-------------+-------+-------------+-------+ INFO - 20:37:18: | Name | Lower bound | Value | Upper bound | Type | INFO - 20:37:18: +-------------+-------------+-------+-------------+-------+ INFO - 20:37:18: | x_shared[0] | 0.01 | 0.05 | 0.09 | float | INFO - 20:37:18: | x_shared[1] | 30000 | 45000 | 60000 | float | INFO - 20:37:18: | x_shared[2] | 1.4 | 1.6 | 1.8 | float | INFO - 20:37:18: | x_shared[3] | 2.5 | 5.5 | 8.5 | float | INFO - 20:37:18: | x_shared[4] | 40 | 55 | 70 | float | INFO - 20:37:18: | x_shared[5] | 500 | 1000 | 1500 | float | INFO - 20:37:18: +-------------+-------------+-------+-------------+-------+ INFO - 20:37:18: Solving optimization problem with algorithm NLOPT_COBYLA: INFO - 20:37:18: 1%| | 1/140 [00:00<00:17, 8.00 it/sec, obj=-553] WARNING - 20:37:18: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:18: The solution is not feasible. INFO - 20:37:18: 1%|▏ | 2/140 [00:00<00:15, 8.76 it/sec, obj=-574] WARNING - 20:37:18: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:18: The solution is not feasible. INFO - 20:37:18: 2%|▏ | 3/140 [00:00<00:13, 9.85 it/sec, obj=-813] WARNING - 20:37:18: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:18: The solution is not feasible. INFO - 20:37:18: 3%|▎ | 4/140 [00:00<00:12, 10.80 it/sec, obj=-751] WARNING - 20:37:18: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:18: The solution is not feasible. INFO - 20:37:18: 4%|▎ | 5/140 [00:00<00:13, 10.17 it/sec, obj=-734] WARNING - 20:37:18: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:18: The solution is not feasible. INFO - 20:37:18: 4%|▍ | 6/140 [00:00<00:12, 10.42 it/sec, obj=-977] WARNING - 20:37:18: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:18: The solution is not feasible. INFO - 20:37:18: 5%|▌ | 7/140 [00:00<00:12, 10.55 it/sec, obj=-1.05e+3] WARNING - 20:37:18: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:18: The solution is not feasible. INFO - 20:37:18: 6%|▌ | 8/140 [00:00<00:12, 10.38 it/sec, obj=-1.67e+3] INFO - 20:37:18: 6%|▋ | 9/140 [00:00<00:13, 9.89 it/sec, obj=-1.73e+3] WARNING - 20:37:19: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:19: The solution is not feasible. INFO - 20:37:19: 7%|▋ | 10/140 [00:01<00:13, 9.57 it/sec, obj=-2.59e+3] INFO - 20:37:19: 8%|▊ | 11/140 [00:01<00:13, 9.44 it/sec, obj=-2.94e+3] INFO - 20:37:19: 9%|▊ | 12/140 [00:01<00:13, 9.53 it/sec, obj=-2.64e+3] WARNING - 20:37:19: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:19: The solution is not feasible. INFO - 20:37:19: 9%|▉ | 13/140 [00:01<00:13, 9.48 it/sec, obj=-2.85e+3] WARNING - 20:37:19: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.9738634258039e-14 is still above the tolerance 1e-14. INFO - 20:37:19: 10%|█ | 14/140 [00:01<00:13, 9.45 it/sec, obj=-2.79e+3] WARNING - 20:37:19: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:19: The solution is not feasible. INFO - 20:37:19: 11%|█ | 15/140 [00:01<00:13, 9.47 it/sec, obj=-2.4e+3] INFO - 20:37:19: 11%|█▏ | 16/140 [00:01<00:13, 9.50 it/sec, obj=-3.07e+3] WARNING - 20:37:19: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.079798716410762e-14 is still above the tolerance 1e-14. WARNING - 20:37:19: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:19: The solution is not feasible. INFO - 20:37:19: 12%|█▏ | 17/140 [00:01<00:12, 9.52 it/sec, obj=-3.01e+3] INFO - 20:37:19: 13%|█▎ | 18/140 [00:01<00:12, 9.51 it/sec, obj=-3.39e+3] INFO - 20:37:20: 14%|█▎ | 19/140 [00:01<00:12, 9.56 it/sec, obj=-3.84e+3] INFO - 20:37:20: 14%|█▍ | 20/140 [00:02<00:12, 9.71 it/sec, obj=-3.58e+3] INFO - 20:37:20: 15%|█▌ | 21/140 [00:02<00:12, 9.71 it/sec, obj=-3.66e+3] INFO - 20:37:20: 16%|█▌ | 22/140 [00:02<00:12, 9.75 it/sec, obj=-3.55e+3] INFO - 20:37:20: 16%|█▋ | 23/140 [00:02<00:11, 9.86 it/sec, obj=-3.72e+3] INFO - 20:37:20: 17%|█▋ | 24/140 [00:02<00:11, 9.97 it/sec, obj=-3.27e+3] INFO - 20:37:20: 18%|█▊ | 25/140 [00:02<00:11, 10.06 it/sec, obj=-3.52e+3] INFO - 20:37:20: 19%|█▊ | 26/140 [00:02<00:11, 10.17 it/sec, obj=-3.96e+3] WARNING - 20:37:20: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:20: The solution is not feasible. INFO - 20:37:20: 19%|█▉ | 27/140 [00:02<00:11, 10.27 it/sec, obj=-3.9e+3] WARNING - 20:37:20: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:20: The solution is not feasible. INFO - 20:37:20: 20%|██ | 28/140 [00:02<00:10, 10.36 it/sec, obj=-3.8e+3] WARNING - 20:37:20: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.079798716410762e-14 is still above the tolerance 1e-14. WARNING - 20:37:20: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:20: The solution is not feasible. INFO - 20:37:20: 21%|██ | 29/140 [00:02<00:10, 10.40 it/sec, obj=-3.76e+3] INFO - 20:37:20: 21%|██▏ | 30/140 [00:02<00:10, 10.48 it/sec, obj=-3.79e+3] WARNING - 20:37:20: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.2779426426139174e-14 is still above the tolerance 1e-14. WARNING - 20:37:20: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:20: The solution is not feasible. INFO - 20:37:21: 22%|██▏ | 31/140 [00:02<00:10, 10.49 it/sec, obj=-3.89e+3] WARNING - 20:37:21: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:21: The solution is not feasible. INFO - 20:37:21: 23%|██▎ | 32/140 [00:03<00:10, 10.58 it/sec, obj=-3.91e+3] WARNING - 20:37:21: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:21: The solution is not feasible. INFO - 20:37:21: 24%|██▎ | 33/140 [00:03<00:10, 10.65 it/sec, obj=-3.88e+3] INFO - 20:37:21: 24%|██▍ | 34/140 [00:03<00:09, 10.71 it/sec, obj=-3.79e+3] INFO - 20:37:21: 25%|██▌ | 35/140 [00:03<00:09, 10.78 it/sec, obj=-3.8e+3] WARNING - 20:37:21: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:21: The solution is not feasible. WARNING - 20:37:21: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 7.9477268516078e-14 is still above the tolerance 1e-14. INFO - 20:37:21: 26%|██▌ | 36/140 [00:03<00:09, 10.81 it/sec, obj=-3.84e+3] INFO - 20:37:21: 26%|██▋ | 37/140 [00:03<00:09, 10.88 it/sec, obj=-3.89e+3] WARNING - 20:37:21: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:21: The solution is not feasible. INFO - 20:37:21: 27%|██▋ | 38/140 [00:03<00:09, 10.93 it/sec, obj=-3.8e+3] WARNING - 20:37:21: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:21: The solution is not feasible. WARNING - 20:37:21: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.9738634258039e-14 is still above the tolerance 1e-14. INFO - 20:37:21: 28%|██▊ | 39/140 [00:03<00:09, 10.96 it/sec, obj=-3.79e+3] WARNING - 20:37:21: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:21: The solution is not feasible. INFO - 20:37:21: 29%|██▊ | 40/140 [00:03<00:09, 11.01 it/sec, obj=-3.82e+3] WARNING - 20:37:21: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:21: The solution is not feasible. INFO - 20:37:21: 29%|██▉ | 41/140 [00:03<00:08, 11.06 it/sec, obj=-3.87e+3] WARNING - 20:37:21: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:21: The solution is not feasible. INFO - 20:37:21: 30%|███ | 42/140 [00:03<00:08, 11.06 it/sec, obj=-3.81e+3] WARNING - 20:37:21: Optimization found no feasible point; the least infeasible point is selected. WARNING - 20:37:21: The solution is not feasible. INFO - 20:37:21: 31%|███ | 43/140 [00:03<00:08, 11.10 it/sec, obj=-3.91e+3] INFO - 20:37:22: 31%|███▏ | 44/140 [00:03<00:08, 11.11 it/sec, obj=-3.87e+3] INFO - 20:37:22: 32%|███▏ | 45/140 [00:04<00:08, 11.13 it/sec, obj=-3.74e+3] INFO - 20:37:22: 33%|███▎ | 46/140 [00:04<00:08, 11.12 it/sec, obj=-3.91e+3] INFO - 20:37:22: 34%|███▎ | 47/140 [00:04<00:08, 11.13 it/sec, obj=-3.7e+3] INFO - 20:37:22: 34%|███▍ | 48/140 [00:04<00:08, 11.12 it/sec, obj=-3.96e+3] INFO - 20:37:22: 35%|███▌ | 49/140 [00:04<00:08, 11.16 it/sec, obj=-3.78e+3] INFO - 20:37:22: 36%|███▌ | 50/140 [00:04<00:08, 11.21 it/sec, obj=-3.81e+3] INFO - 20:37:22: 36%|███▋ | 51/140 [00:04<00:07, 11.25 it/sec, obj=-3.83e+3] INFO - 20:37:22: 37%|███▋ | 52/140 [00:04<00:07, 11.29 it/sec, obj=-3.79e+3] INFO - 20:37:22: 38%|███▊ | 53/140 [00:04<00:07, 11.33 it/sec, obj=-3.84e+3] INFO - 20:37:22: 39%|███▊ | 54/140 [00:04<00:07, 11.38 it/sec, obj=-3.73e+3] INFO - 20:37:22: 39%|███▉ | 55/140 [00:04<00:07, 11.40 it/sec, obj=-3.79e+3] INFO - 20:37:22: 40%|████ | 56/140 [00:04<00:07, 11.44 it/sec, obj=-3.9e+3] INFO - 20:37:23: 41%|████ | 57/140 [00:04<00:07, 11.47 it/sec, obj=-3.8e+3] INFO - 20:37:23: 41%|████▏ | 58/140 [00:05<00:07, 11.50 it/sec, obj=-3.73e+3] INFO - 20:37:23: 42%|████▏ | 59/140 [00:05<00:07, 11.53 it/sec, obj=-3.94e+3] INFO - 20:37:23: 43%|████▎ | 60/140 [00:05<00:06, 11.56 it/sec, obj=-3.75e+3] INFO - 20:37:23: 44%|████▎ | 61/140 [00:05<00:06, 11.60 it/sec, obj=-3.82e+3] INFO - 20:37:23: 44%|████▍ | 62/140 [00:05<00:06, 11.64 it/sec, obj=-3.74e+3] INFO - 20:37:23: 45%|████▌ | 63/140 [00:05<00:06, 11.66 it/sec, obj=-3.88e+3] INFO - 20:37:23: 46%|████▌ | 64/140 [00:05<00:06, 11.69 it/sec, obj=-3.88e+3] INFO - 20:37:23: 46%|████▋ | 65/140 [00:05<00:06, 11.71 it/sec, obj=-3.86e+3] INFO - 20:37:23: 47%|████▋ | 66/140 [00:05<00:06, 11.74 it/sec, obj=-3.79e+3] WARNING - 20:37:23: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 7.9477268516078e-14 is still above the tolerance 1e-14. INFO - 20:37:23: 48%|████▊ | 67/140 [00:05<00:06, 11.74 it/sec, obj=-3.74e+3] WARNING - 20:37:23: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.079798716410762e-14 is still above the tolerance 1e-14. INFO - 20:37:23: 49%|████▊ | 68/140 [00:05<00:06, 11.74 it/sec, obj=-3.82e+3] INFO - 20:37:23: 49%|████▉ | 69/140 [00:05<00:06, 11.76 it/sec, obj=-3.76e+3] INFO - 20:37:23: 50%|█████ | 70/140 [00:05<00:05, 11.79 it/sec, obj=-3.79e+3] INFO - 20:37:24: 51%|█████ | 71/140 [00:06<00:05, 11.80 it/sec, obj=-3.85e+3] INFO - 20:37:24: 51%|█████▏ | 72/140 [00:06<00:05, 11.83 it/sec, obj=-3.75e+3] INFO - 20:37:24: 52%|█████▏ | 73/140 [00:06<00:05, 11.86 it/sec, obj=-3.71e+3] INFO - 20:37:24: 53%|█████▎ | 74/140 [00:06<00:05, 11.87 it/sec, obj=-3.77e+3] INFO - 20:37:24: 54%|█████▎ | 75/140 [00:06<00:05, 11.89 it/sec, obj=-3.89e+3] INFO - 20:37:24: 54%|█████▍ | 76/140 [00:06<00:05, 11.91 it/sec, obj=-3.88e+3] INFO - 20:37:24: 55%|█████▌ | 77/140 [00:06<00:05, 11.93 it/sec, obj=-3.78e+3] WARNING - 20:37:24: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.079798716410762e-14 is still above the tolerance 1e-14. INFO - 20:37:24: 56%|█████▌ | 78/140 [00:06<00:05, 11.93 it/sec, obj=-3.86e+3] INFO - 20:37:24: 56%|█████▋ | 79/140 [00:06<00:05, 11.95 it/sec, obj=-3.86e+3] INFO - 20:37:24: 57%|█████▋ | 80/140 [00:06<00:05, 11.98 it/sec, obj=-3.69e+3] INFO - 20:37:24: 58%|█████▊ | 81/140 [00:06<00:04, 12.00 it/sec, obj=-3.91e+3] WARNING - 20:37:24: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.079798716410762e-14 is still above the tolerance 1e-14. INFO - 20:37:24: 59%|█████▊ | 82/140 [00:06<00:04, 12.00 it/sec, obj=-3.95e+3] INFO - 20:37:24: 59%|█████▉ | 83/140 [00:06<00:04, 12.01 it/sec, obj=-3.85e+3] INFO - 20:37:25: 60%|██████ | 84/140 [00:06<00:04, 12.02 it/sec, obj=-3.92e+3] INFO - 20:37:25: 61%|██████ | 85/140 [00:07<00:04, 12.03 it/sec, obj=-3.9e+3] INFO - 20:37:25: 61%|██████▏ | 86/140 [00:07<00:04, 12.05 it/sec, obj=-3.9e+3] WARNING - 20:37:25: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 6.159597432821524e-14 is still above the tolerance 1e-14. INFO - 20:37:25: 62%|██████▏ | 87/140 [00:07<00:04, 12.05 it/sec, obj=-3.81e+3] INFO - 20:37:25: 63%|██████▎ | 88/140 [00:07<00:04, 12.06 it/sec, obj=-3.93e+3] INFO - 20:37:25: 64%|██████▎ | 89/140 [00:07<00:04, 12.08 it/sec, obj=-3.94e+3] WARNING - 20:37:25: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 7.9477268516078e-14 is still above the tolerance 1e-14. INFO - 20:37:25: 64%|██████▍ | 90/140 [00:07<00:04, 12.08 it/sec, obj=-3.96e+3] INFO - 20:37:25: 65%|██████▌ | 91/140 [00:07<00:04, 12.13 it/sec, obj=-3.96e+3] INFO - 20:37:25: 66%|██████▌ | 92/140 [00:07<00:03, 12.19 it/sec, obj=-3.95e+3] WARNING - 20:37:25: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 6.159597432821524e-14 is still above the tolerance 1e-14. WARNING - 20:37:25: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 7.9477268516078e-14 is still above the tolerance 1e-14. INFO - 20:37:25: 66%|██████▋ | 93/140 [00:07<00:03, 12.21 it/sec, obj=-3.95e+3] INFO - 20:37:25: 67%|██████▋ | 94/140 [00:07<00:03, 12.26 it/sec, obj=-3.94e+3] INFO - 20:37:25: 68%|██████▊ | 95/140 [00:07<00:03, 12.31 it/sec, obj=-3.96e+3] INFO - 20:37:25: 69%|██████▊ | 96/140 [00:07<00:03, 12.37 it/sec, obj=-3.95e+3] INFO - 20:37:25: 69%|██████▉ | 97/140 [00:07<00:03, 12.42 it/sec, obj=-3.95e+3] INFO - 20:37:25: 70%|███████ | 98/140 [00:07<00:03, 12.43 it/sec, obj=-3.94e+3] INFO - 20:37:26: 71%|███████ | 99/140 [00:07<00:03, 12.45 it/sec, obj=-3.96e+3] INFO - 20:37:26: 71%|███████▏ | 100/140 [00:08<00:03, 12.47 it/sec, obj=-3.96e+3] INFO - 20:37:26: 72%|███████▏ | 101/140 [00:08<00:03, 12.48 it/sec, obj=-3.96e+3] WARNING - 20:37:26: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 7.955484517651815e-14 is still above the tolerance 1e-14. INFO - 20:37:26: 73%|███████▎ | 102/140 [00:08<00:03, 12.47 it/sec, obj=-3.96e+3] INFO - 20:37:26: 74%|███████▎ | 103/140 [00:08<00:02, 12.53 it/sec, obj=-3.96e+3] INFO - 20:37:26: 74%|███████▍ | 104/140 [00:08<00:02, 12.58 it/sec, obj=-3.96e+3] INFO - 20:37:26: 75%|███████▌ | 105/140 [00:08<00:02, 12.63 it/sec, obj=-3.96e+3] INFO - 20:37:26: 76%|███████▌ | 106/140 [00:08<00:02, 12.69 it/sec, obj=-3.96e+3] INFO - 20:37:26: 76%|███████▋ | 107/140 [00:08<00:02, 12.73 it/sec, obj=-3.96e+3] INFO - 20:37:26: 77%|███████▋ | 108/140 [00:08<00:02, 12.79 it/sec, obj=-3.96e+3] INFO - 20:37:26: 78%|███████▊ | 109/140 [00:08<00:02, 12.84 it/sec, obj=-3.96e+3] INFO - 20:37:26: 79%|███████▊ | 110/140 [00:08<00:02, 12.86 it/sec, obj=-3.96e+3] INFO - 20:37:26: 79%|███████▉ | 111/140 [00:08<00:02, 12.88 it/sec, obj=-3.96e+3] INFO - 20:37:26: 80%|████████ | 112/140 [00:08<00:02, 12.89 it/sec, obj=-3.96e+3] INFO - 20:37:26: 81%|████████ | 113/140 [00:08<00:02, 12.90 it/sec, obj=-3.96e+3] INFO - 20:37:26: 81%|████████▏ | 114/140 [00:08<00:02, 12.95 it/sec, obj=-3.96e+3] WARNING - 20:37:26: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 6.159597432821524e-14 is still above the tolerance 1e-14. INFO - 20:37:26: 82%|████████▏ | 115/140 [00:08<00:01, 12.95 it/sec, obj=-3.96e+3] INFO - 20:37:27: 83%|████████▎ | 116/140 [00:08<00:01, 12.96 it/sec, obj=-3.96e+3] INFO - 20:37:27: 84%|████████▎ | 117/140 [00:09<00:01, 12.98 it/sec, obj=-3.96e+3] INFO - 20:37:27: 84%|████████▍ | 118/140 [00:09<00:01, 13.03 it/sec, obj=-3.96e+3] INFO - 20:37:27: 85%|████████▌ | 119/140 [00:09<00:01, 13.07 it/sec, obj=-3.96e+3] INFO - 20:37:27: 86%|████████▌ | 120/140 [00:09<00:01, 13.12 it/sec, obj=-3.96e+3] INFO - 20:37:27: 86%|████████▋ | 121/140 [00:09<00:01, 13.16 it/sec, obj=-3.96e+3] WARNING - 20:37:27: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.9738634258039e-14 is still above the tolerance 1e-14. INFO - 20:37:27: 87%|████████▋ | 122/140 [00:09<00:01, 13.16 it/sec, obj=-3.96e+3] INFO - 20:37:27: 88%|████████▊ | 123/140 [00:09<00:01, 13.21 it/sec, obj=-3.96e+3] INFO - 20:37:27: 89%|████████▊ | 124/140 [00:09<00:01, 13.22 it/sec, obj=-3.96e+3] INFO - 20:37:27: 89%|████████▉ | 125/140 [00:09<00:01, 13.26 it/sec, obj=-3.96e+3] INFO - 20:37:27: 90%|█████████ | 126/140 [00:09<00:01, 13.30 it/sec, obj=-3.96e+3] INFO - 20:37:27: 91%|█████████ | 127/140 [00:09<00:00, 13.34 it/sec, obj=-3.96e+3] INFO - 20:37:27: 91%|█████████▏| 128/140 [00:09<00:00, 13.38 it/sec, obj=-3.96e+3] INFO - 20:37:27: 92%|█████████▏| 129/140 [00:09<00:00, 13.42 it/sec, obj=-3.96e+3] INFO - 20:37:27: 93%|█████████▎| 130/140 [00:09<00:00, 13.46 it/sec, obj=-3.96e+3] INFO - 20:37:27: 94%|█████████▎| 131/140 [00:09<00:00, 13.50 it/sec, obj=-3.96e+3] INFO - 20:37:27: 94%|█████████▍| 132/140 [00:09<00:00, 13.53 it/sec, obj=-3.96e+3] INFO - 20:37:27: 95%|█████████▌| 133/140 [00:09<00:00, 13.57 it/sec, obj=-3.96e+3] INFO - 20:37:27: 96%|█████████▌| 134/140 [00:09<00:00, 13.61 it/sec, obj=-3.96e+3] INFO - 20:37:27: 96%|█████████▋| 135/140 [00:09<00:00, 13.65 it/sec, obj=-3.96e+3] INFO - 20:37:27: 97%|█████████▋| 136/140 [00:09<00:00, 13.70 it/sec, obj=-3.96e+3] INFO - 20:37:28: 98%|█████████▊| 137/140 [00:09<00:00, 13.73 it/sec, obj=-3.96e+3] INFO - 20:37:28: 99%|█████████▊| 138/140 [00:10<00:00, 13.78 it/sec, obj=-3.96e+3] INFO - 20:37:28: 99%|█████████▉| 139/140 [00:10<00:00, 13.82 it/sec, obj=-3.96e+3] INFO - 20:37:28: 100%|██████████| 140/140 [00:10<00:00, 13.86 it/sec, obj=-3.96e+3] INFO - 20:37:28: Optimization result: INFO - 20:37:28: Optimizer info: INFO - 20:37:28: Status: None INFO - 20:37:28: Message: Maximum number of iterations reached. GEMSEO stopped the driver. INFO - 20:37:28: Number of calls to the objective function by the optimizer: 0 INFO - 20:37:28: Solution: INFO - 20:37:28: The solution is feasible. INFO - 20:37:28: Objective: -3963.4311907124807 INFO - 20:37:28: Standardized constraints: INFO - 20:37:28: g_1_g_2_g_3 = [-1.80586483e-02 -3.33446982e-02 -4.42481234e-02 -5.18335066e-02 INFO - 20:37:28: -5.73251488e-02 -1.37208650e-01 -1.02791350e-01 2.54476781e-06 INFO - 20:37:28: -7.67219801e-01 -2.32780199e-01 5.09885826e-05 -1.83255000e-01] INFO - 20:37:28: Design space: INFO - 20:37:28: +-------------+-------------+---------------------+-------------+-------+ INFO - 20:37:28: | Name | Lower bound | Value | Upper bound | Type | INFO - 20:37:28: +-------------+-------------+---------------------+-------------+-------+ INFO - 20:37:28: | x_shared[0] | 0.01 | 0.06000063619195205 | 0.09 | float | INFO - 20:37:28: | x_shared[1] | 30000 | 60000 | 60000 | float | INFO - 20:37:28: | x_shared[2] | 1.4 | 1.4 | 1.8 | float | INFO - 20:37:28: | x_shared[3] | 2.5 | 2.50000000000001 | 8.5 | float | INFO - 20:37:28: | x_shared[4] | 40 | 70 | 70 | float | INFO - 20:37:28: | x_shared[5] | 500 | 1500 | 1500 | float | INFO - 20:37:28: +-------------+-------------+---------------------+-------------+-------+ INFO - 20:37:28: *** End MDOScenario execution *** .. GENERATED FROM PYTHON SOURCE LINES 188-191 Plot the history of the MDA residuals ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For the first MDA: .. GENERATED FROM PYTHON SOURCE LINES 191-193 .. code-block:: Python system_scenario.formulation.mda1.plot_residual_history(save=False, show=True) .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_001.png :alt: MDAGaussSeidel: residual plot :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 194-195 For the second MDA: .. GENERATED FROM PYTHON SOURCE LINES 195-197 .. code-block:: Python system_scenario.formulation.mda2.plot_residual_history(save=False, show=True) .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_002.png :alt: MDAGaussSeidel: residual plot :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 198-200 Plot the system optimization history view ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 200-202 .. code-block:: Python system_scenario.post_process(post_name="OptHistoryView", save=False, show=True) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_003.png :alt: Evolution of the optimization variables :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_004.png :alt: Evolution of the objective value :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_004.png :class: sphx-glr-multi-img * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_005.png :alt: Evolution of the distance to the optimum :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_005.png :class: sphx-glr-multi-img * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_006.png :alt: Evolution of the inequality constraints :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_006.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 203-205 Plot the structure optimization histories of the 2 first iterations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 205-213 .. code-block:: Python struct_databases = system_scenario.formulation.scenario_adapters[2].databases for database in struct_databases[:2]: opt_problem = deepcopy(sc_str.formulation.optimization_problem) opt_problem.database = database execute_post(opt_problem, post_name="OptHistoryView", save=False, show=True) for disc in [propu, aero, mission, struct]: print(f"{disc.name}: {disc.execution_statistics.n_executions} calls.") .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_007.png :alt: Evolution of the optimization variables :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_007.png :class: sphx-glr-multi-img * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_008.png :alt: Evolution of the objective value :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_008.png :class: sphx-glr-multi-img * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_009.png :alt: Evolution of the distance to the optimum :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_009.png :class: sphx-glr-multi-img * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_010.png :alt: Evolution of the inequality constraints :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_010.png :class: sphx-glr-multi-img * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_011.png :alt: Evolution of the optimization variables :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_011.png :class: sphx-glr-multi-img * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_012.png :alt: Evolution of the objective value :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_012.png :class: sphx-glr-multi-img * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_013.png :alt: Evolution of the distance to the optimum :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_013.png :class: sphx-glr-multi-img * .. image-sg:: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_014.png :alt: Evolution of the inequality constraints :srcset: /examples/formulations/images/sphx_glr_plot_sobieski_bilevel_example_014.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none SobieskiPropulsion: None calls. SobieskiAerodynamics: None calls. SobieskiMission: None calls. SobieskiStructure: None calls. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 12.393 seconds) .. _sphx_glr_download_examples_formulations_plot_sobieski_bilevel_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_sobieski_bilevel_example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_sobieski_bilevel_example.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_sobieski_bilevel_example.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_