.. 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-38 .. code-block:: Python from __future__ import annotations from copy import deepcopy from logging import WARNING 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 .. GENERATED FROM PYTHON SOURCE LINES 39-46 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 46-53 .. code-block:: Python propu, aero, mission, struct = create_discipline([ "SobieskiPropulsion", "SobieskiAerodynamics", "SobieskiMission", "SobieskiStructure", ]) .. GENERATED FROM PYTHON SOURCE LINES 54-62 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 62-64 .. code-block:: Python design_space = SobieskiDesignSpace() .. GENERATED FROM PYTHON SOURCE LINES 65-68 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 68-87 .. 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 88-91 Build a sub-scenario for Propulsion ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This sub-scenario will minimize SFC. .. GENERATED FROM PYTHON SOURCE LINES 91-101 .. 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 102-105 Build a sub-scenario for Aerodynamics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This sub-scenario will minimize L/D. .. GENERATED FROM PYTHON SOURCE LINES 105-116 .. 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 117-121 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 121-132 .. 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 133-137 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 137-157 .. 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 158-168 .. 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 170-177 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 177-179 .. code-block:: Python system_scenario.xdsmize(save_html=False) .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 180-182 Execute the main scenario ^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 182-184 .. code-block:: Python system_scenario.execute(cobyla_settings) .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 16:24:09: *** Start MDOScenario execution *** INFO - 16:24:09: MDOScenario INFO - 16:24:09: Disciplines: AerodynamicsScenario PropulsionScenario SobieskiMission StructureScenario INFO - 16:24:09: MDO formulation: BiLevel INFO - 16:24:09: Optimization problem: INFO - 16:24:09: minimize -y_4(x_shared) INFO - 16:24:09: with respect to x_shared INFO - 16:24:09: under the inequality constraints INFO - 16:24:09: g_1_g_2_g_3(x_shared) <= 0 INFO - 16:24:09: over the design space: INFO - 16:24:09: +-------------+-------------+-------+-------------+-------+ INFO - 16:24:09: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:24:09: +-------------+-------------+-------+-------------+-------+ INFO - 16:24:09: | x_shared[0] | 0.01 | 0.05 | 0.09 | float | INFO - 16:24:09: | x_shared[1] | 30000 | 45000 | 60000 | float | INFO - 16:24:09: | x_shared[2] | 1.4 | 1.6 | 1.8 | float | INFO - 16:24:09: | x_shared[3] | 2.5 | 5.5 | 8.5 | float | INFO - 16:24:09: | x_shared[4] | 40 | 55 | 70 | float | INFO - 16:24:09: | x_shared[5] | 500 | 1000 | 1500 | float | INFO - 16:24:09: +-------------+-------------+-------+-------------+-------+ INFO - 16:24:09: Solving optimization problem with algorithm NLOPT_COBYLA: INFO - 16:24:09: 1%| | 1/140 [00:00<00:08, 15.99 it/sec, feas=True, obj=-553] WARNING - 16:24:09: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:09: The solution is not feasible. INFO - 16:24:09: 1%|▏ | 2/140 [00:00<00:08, 16.04 it/sec, feas=False, obj=-574] WARNING - 16:24:09: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:09: The solution is not feasible. INFO - 16:24:09: 2%|▏ | 3/140 [00:00<00:07, 19.03 it/sec, feas=False, obj=-813] WARNING - 16:24:09: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:09: The solution is not feasible. INFO - 16:24:09: 3%|▎ | 4/140 [00:00<00:06, 21.50 it/sec, feas=False, obj=-751] WARNING - 16:24:09: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:09: The solution is not feasible. INFO - 16:24:09: 4%|▎ | 5/140 [00:00<00:06, 20.05 it/sec, feas=False, obj=-734] WARNING - 16:24:10: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:10: The solution is not feasible. WARNING - 16:24:10: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.973863233521246e-14 is still above the tolerance 1e-14. INFO - 16:24:10: 4%|▍ | 6/140 [00:00<00:06, 20.34 it/sec, feas=False, obj=-977] WARNING - 16:24:10: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:10: The solution is not feasible. INFO - 16:24:10: 5%|▌ | 7/140 [00:00<00:06, 21.10 it/sec, feas=False, obj=-1.05e+3] WARNING - 16:24:10: 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 - 16:24:10: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:10: The solution is not feasible. INFO - 16:24:10: 6%|▌ | 8/140 [00:00<00:06, 20.95 it/sec, feas=False, obj=-1.45e+3] INFO - 16:24:10: 6%|▋ | 9/140 [00:00<00:06, 21.05 it/sec, feas=True, obj=-2.15e+3] INFO - 16:24:10: 7%|▋ | 10/140 [00:00<00:06, 21.32 it/sec, feas=True, obj=-2.9e+3] INFO - 16:24:10: 8%|▊ | 11/140 [00:00<00:06, 21.16 it/sec, feas=True, obj=-2.44e+3] WARNING - 16:24:10: 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 - 16:24:10: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:10: The solution is not feasible. INFO - 16:24:10: 9%|▊ | 12/140 [00:00<00:06, 21.15 it/sec, feas=False, obj=-2.59e+3] WARNING - 16:24:10: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.973863233521246e-14 is still above the tolerance 1e-14. INFO - 16:24:10: 9%|▉ | 13/140 [00:00<00:05, 21.56 it/sec, feas=True, obj=-2.84e+3] INFO - 16:24:10: 10%|█ | 14/140 [00:00<00:05, 21.59 it/sec, feas=True, obj=-2.85e+3] WARNING - 16:24:10: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:10: The solution is not feasible. WARNING - 16:24:10: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 7.947726467042492e-14 is still above the tolerance 1e-14. INFO - 16:24:10: 11%|█ | 15/140 [00:00<00:05, 21.12 it/sec, feas=False, obj=-3.91e+3] INFO - 16:24:10: 11%|█▏ | 16/140 [00:00<00:05, 21.65 it/sec, feas=True, obj=-3.35e+3] WARNING - 16:24:10: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:10: The solution is not feasible. INFO - 16:24:10: 12%|█▏ | 17/140 [00:00<00:05, 21.35 it/sec, feas=False, obj=-3.59e+3] WARNING - 16:24:10: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:10: The solution is not feasible. INFO - 16:24:10: 13%|█▎ | 18/140 [00:00<00:05, 21.52 it/sec, feas=False, obj=-3.64e+3] INFO - 16:24:10: 14%|█▎ | 19/140 [00:00<00:05, 21.92 it/sec, feas=True, obj=-3.56e+3] INFO - 16:24:10: 14%|█▍ | 20/140 [00:00<00:05, 21.81 it/sec, feas=True, obj=-3.24e+3] WARNING - 16:24:10: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:10: The solution is not feasible. INFO - 16:24:10: 15%|█▌ | 21/140 [00:00<00:05, 21.63 it/sec, feas=False, obj=-3.61e+3] WARNING - 16:24:10: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:10: The solution is not feasible. INFO - 16:24:10: 16%|█▌ | 22/140 [00:01<00:05, 21.51 it/sec, feas=False, obj=-3.47e+3] INFO - 16:24:10: 16%|█▋ | 23/140 [00:01<00:05, 21.77 it/sec, feas=True, obj=-3.56e+3] WARNING - 16:24:10: 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 - 16:24:10: 17%|█▋ | 24/140 [00:01<00:05, 22.00 it/sec, feas=True, obj=-3.61e+3] INFO - 16:24:10: 18%|█▊ | 25/140 [00:01<00:05, 22.29 it/sec, feas=True, obj=-3.56e+3] INFO - 16:24:10: 19%|█▊ | 26/140 [00:01<00:05, 22.50 it/sec, feas=True, obj=-3.91e+3] WARNING - 16:24:10: 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 - 16:24:10: 19%|█▉ | 27/140 [00:01<00:04, 22.68 it/sec, feas=True, obj=-3.71e+3] WARNING - 16:24:10: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:10: The solution is not feasible. WARNING - 16:24:10: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.973863233521246e-14 is still above the tolerance 1e-14. INFO - 16:24:10: 20%|██ | 28/140 [00:01<00:04, 22.86 it/sec, feas=False, obj=-3.83e+3] INFO - 16:24:10: 21%|██ | 29/140 [00:01<00:04, 23.03 it/sec, feas=True, obj=-3.79e+3] INFO - 16:24:11: 21%|██▏ | 30/140 [00:01<00:04, 23.30 it/sec, feas=True, obj=-3.79e+3] WARNING - 16:24:11: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:11: The solution is not feasible. INFO - 16:24:11: 22%|██▏ | 31/140 [00:01<00:04, 23.19 it/sec, feas=False, obj=-3.84e+3] INFO - 16:24:11: 23%|██▎ | 32/140 [00:01<00:04, 23.40 it/sec, feas=True, obj=-3.89e+3] INFO - 16:24:11: 24%|██▎ | 33/140 [00:01<00:04, 23.60 it/sec, feas=True, obj=-3.85e+3] INFO - 16:24:11: 24%|██▍ | 34/140 [00:01<00:04, 23.78 it/sec, feas=True, obj=-3.79e+3] WARNING - 16:24:11: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:11: The solution is not feasible. INFO - 16:24:11: 25%|██▌ | 35/140 [00:01<00:04, 23.92 it/sec, feas=False, obj=-3.9e+3] WARNING - 16:24:11: Optimization found no feasible point; the least infeasible point is selected. WARNING - 16:24:11: The solution is not feasible. INFO - 16:24:11: 26%|██▌ | 36/140 [00:01<00:04, 24.04 it/sec, feas=False, obj=-3.74e+3] INFO - 16:24:11: 26%|██▋ | 37/140 [00:01<00:04, 24.17 it/sec, feas=True, obj=-3.95e+3] INFO - 16:24:11: 27%|██▋ | 38/140 [00:01<00:04, 24.39 it/sec, feas=True, obj=-3.93e+3] INFO - 16:24:11: 28%|██▊ | 39/140 [00:01<00:04, 24.57 it/sec, feas=True, obj=-3.93e+3] INFO - 16:24:11: 29%|██▊ | 40/140 [00:01<00:04, 24.69 it/sec, feas=True, obj=-3.94e+3] INFO - 16:24:11: 29%|██▉ | 41/140 [00:01<00:03, 24.87 it/sec, feas=True, obj=-3.94e+3] INFO - 16:24:11: 30%|███ | 42/140 [00:01<00:03, 25.02 it/sec, feas=True, obj=-3.93e+3] INFO - 16:24:11: 31%|███ | 43/140 [00:01<00:03, 25.12 it/sec, feas=True, obj=-3.94e+3] INFO - 16:24:11: 31%|███▏ | 44/140 [00:01<00:03, 25.25 it/sec, feas=True, obj=-3.92e+3] INFO - 16:24:11: 32%|███▏ | 45/140 [00:01<00:03, 25.35 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:11: 33%|███▎ | 46/140 [00:01<00:03, 25.59 it/sec, feas=True, obj=-3.95e+3] INFO - 16:24:11: 34%|███▎ | 47/140 [00:01<00:03, 25.72 it/sec, feas=True, obj=-3.92e+3] INFO - 16:24:11: 34%|███▍ | 48/140 [00:01<00:03, 25.82 it/sec, feas=True, obj=-3.95e+3] INFO - 16:24:11: 35%|███▌ | 49/140 [00:01<00:03, 25.89 it/sec, feas=True, obj=-3.94e+3] INFO - 16:24:11: 36%|███▌ | 50/140 [00:01<00:03, 25.98 it/sec, feas=True, obj=-3.94e+3] INFO - 16:24:11: 36%|███▋ | 51/140 [00:01<00:03, 26.09 it/sec, feas=True, obj=-3.94e+3] WARNING - 16:24:11: 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 - 16:24:11: 37%|███▋ | 52/140 [00:01<00:03, 26.11 it/sec, feas=True, obj=-3.95e+3] WARNING - 16:24:11: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.973863233521246e-14 is still above the tolerance 1e-14. INFO - 16:24:11: 38%|███▊ | 53/140 [00:02<00:03, 26.18 it/sec, feas=True, obj=-3.95e+3] WARNING - 16:24:11: 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 - 16:24:11: 39%|███▊ | 54/140 [00:02<00:03, 26.20 it/sec, feas=True, obj=-3.94e+3] INFO - 16:24:11: 39%|███▉ | 55/140 [00:02<00:03, 26.27 it/sec, feas=True, obj=-3.95e+3] INFO - 16:24:11: 40%|████ | 56/140 [00:02<00:03, 26.32 it/sec, feas=True, obj=-3.93e+3] INFO - 16:24:11: 41%|████ | 57/140 [00:02<00:03, 26.39 it/sec, feas=True, obj=-3.94e+3] WARNING - 16:24:11: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.973863233521246e-14 is still above the tolerance 1e-14. INFO - 16:24:11: 41%|████▏ | 58/140 [00:02<00:03, 26.39 it/sec, feas=True, obj=-3.95e+3] WARNING - 16:24:11: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 7.947726467042492e-14 is still above the tolerance 1e-14. INFO - 16:24:11: 42%|████▏ | 59/140 [00:02<00:03, 26.45 it/sec, feas=True, obj=-3.94e+3] INFO - 16:24:12: 43%|████▎ | 60/140 [00:02<00:03, 26.51 it/sec, feas=True, obj=-3.95e+3] WARNING - 16:24:12: 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 - 16:24:12: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 7.947726467042492e-14 is still above the tolerance 1e-14. INFO - 16:24:12: 44%|████▎ | 61/140 [00:02<00:02, 26.49 it/sec, feas=True, obj=-3.95e+3] INFO - 16:24:12: 44%|████▍ | 62/140 [00:02<00:02, 26.55 it/sec, feas=True, obj=-3.94e+3] INFO - 16:24:12: 45%|████▌ | 63/140 [00:02<00:02, 26.68 it/sec, feas=True, obj=-3.94e+3] INFO - 16:24:12: 46%|████▌ | 64/140 [00:02<00:02, 26.75 it/sec, feas=True, obj=-3.93e+3] INFO - 16:24:12: 46%|████▋ | 65/140 [00:02<00:02, 26.83 it/sec, feas=True, obj=-3.95e+3] INFO - 16:24:12: 47%|████▋ | 66/140 [00:02<00:02, 26.87 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 48%|████▊ | 67/140 [00:02<00:02, 26.95 it/sec, feas=True, obj=-3.95e+3] INFO - 16:24:12: 49%|████▊ | 68/140 [00:02<00:02, 27.03 it/sec, feas=True, obj=-3.95e+3] INFO - 16:24:12: 49%|████▉ | 69/140 [00:02<00:02, 27.16 it/sec, feas=True, obj=-3.95e+3] INFO - 16:24:12: 50%|█████ | 70/140 [00:02<00:02, 27.23 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 51%|█████ | 71/140 [00:02<00:02, 27.31 it/sec, feas=True, obj=-3.96e+3] WARNING - 16:24:12: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 7.947726467042492e-14 is still above the tolerance 1e-14. INFO - 16:24:12: 51%|█████▏ | 72/140 [00:02<00:02, 27.31 it/sec, feas=True, obj=-3.95e+3] INFO - 16:24:12: 52%|█████▏ | 73/140 [00:02<00:02, 27.36 it/sec, feas=True, obj=-3.95e+3] INFO - 16:24:12: 53%|█████▎ | 74/140 [00:02<00:02, 27.40 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 54%|█████▎ | 75/140 [00:02<00:02, 27.55 it/sec, feas=True, obj=-3.96e+3] WARNING - 16:24:12: 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 - 16:24:12: 54%|█████▍ | 76/140 [00:02<00:02, 27.59 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 55%|█████▌ | 77/140 [00:02<00:02, 27.66 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 56%|█████▌ | 78/140 [00:02<00:02, 27.75 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 56%|█████▋ | 79/140 [00:02<00:02, 27.89 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 57%|█████▋ | 80/140 [00:02<00:02, 27.94 it/sec, feas=True, obj=-3.96e+3] WARNING - 16:24:12: 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 - 16:24:12: 58%|█████▊ | 81/140 [00:02<00:02, 27.94 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 59%|█████▊ | 82/140 [00:02<00:02, 28.01 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 59%|█████▉ | 83/140 [00:02<00:02, 28.05 it/sec, feas=True, obj=-3.96e+3] WARNING - 16:24:12: 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 - 16:24:12: 60%|██████ | 84/140 [00:02<00:01, 28.06 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 61%|██████ | 85/140 [00:03<00:01, 28.11 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 61%|██████▏ | 86/140 [00:03<00:01, 28.21 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 62%|██████▏ | 87/140 [00:03<00:01, 28.29 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 63%|██████▎ | 88/140 [00:03<00:01, 28.35 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 64%|██████▎ | 89/140 [00:03<00:01, 28.44 it/sec, feas=True, obj=-3.96e+3] WARNING - 16:24:12: 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 - 16:24:12: 64%|██████▍ | 90/140 [00:03<00:01, 28.43 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 65%|██████▌ | 91/140 [00:03<00:01, 28.52 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 66%|██████▌ | 92/140 [00:03<00:01, 28.61 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:12: 66%|██████▋ | 93/140 [00:03<00:01, 28.71 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 67%|██████▋ | 94/140 [00:03<00:01, 28.80 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 68%|██████▊ | 95/140 [00:03<00:01, 28.91 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 69%|██████▊ | 96/140 [00:03<00:01, 29.00 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 69%|██████▉ | 97/140 [00:03<00:01, 29.09 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 70%|███████ | 98/140 [00:03<00:01, 29.16 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 71%|███████ | 99/140 [00:03<00:01, 29.24 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 71%|███████▏ | 100/140 [00:03<00:01, 29.31 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 72%|███████▏ | 101/140 [00:03<00:01, 29.41 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 73%|███████▎ | 102/140 [00:03<00:01, 29.51 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 74%|███████▎ | 103/140 [00:03<00:01, 29.59 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 74%|███████▍ | 104/140 [00:03<00:01, 29.67 it/sec, feas=True, obj=-3.96e+3] WARNING - 16:24:13: 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 - 16:24:13: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.973863233521246e-14 is still above the tolerance 1e-14. INFO - 16:24:13: 75%|███████▌ | 105/140 [00:03<00:01, 29.66 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 76%|███████▌ | 106/140 [00:03<00:01, 29.74 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 76%|███████▋ | 107/140 [00:03<00:01, 29.81 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 77%|███████▋ | 108/140 [00:03<00:01, 29.91 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 78%|███████▊ | 109/140 [00:03<00:01, 29.96 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 79%|███████▊ | 110/140 [00:03<00:00, 30.06 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 79%|███████▉ | 111/140 [00:03<00:00, 30.15 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 80%|████████ | 112/140 [00:03<00:00, 30.23 it/sec, feas=True, obj=-3.96e+3] WARNING - 16:24:13: 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 - 16:24:13: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 3.973863233521246e-14 is still above the tolerance 1e-14. INFO - 16:24:13: 81%|████████ | 113/140 [00:03<00:00, 30.23 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 81%|████████▏ | 114/140 [00:03<00:00, 30.29 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 82%|████████▏ | 115/140 [00:03<00:00, 30.36 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 83%|████████▎ | 116/140 [00:03<00:00, 30.42 it/sec, feas=True, obj=-3.96e+3] WARNING - 16:24:13: 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 - 16:24:13: MDAGaussSeidel has reached its maximum number of unsuccessful iterations, but the normalized residual norm 7.947726467042492e-14 is still above the tolerance 1e-14. INFO - 16:24:13: 84%|████████▎ | 117/140 [00:03<00:00, 30.41 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 84%|████████▍ | 118/140 [00:03<00:00, 30.48 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 85%|████████▌ | 119/140 [00:03<00:00, 30.53 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 86%|████████▌ | 120/140 [00:03<00:00, 30.60 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 86%|████████▋ | 121/140 [00:03<00:00, 30.68 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 87%|████████▋ | 122/140 [00:03<00:00, 30.71 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 88%|████████▊ | 123/140 [00:03<00:00, 30.78 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 89%|████████▊ | 124/140 [00:04<00:00, 30.83 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 89%|████████▉ | 125/140 [00:04<00:00, 30.89 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 90%|█████████ | 126/140 [00:04<00:00, 30.93 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 91%|█████████ | 127/140 [00:04<00:00, 31.00 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 91%|█████████▏| 128/140 [00:04<00:00, 31.09 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 92%|█████████▏| 129/140 [00:04<00:00, 31.15 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 93%|█████████▎| 130/140 [00:04<00:00, 31.21 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 94%|█████████▎| 131/140 [00:04<00:00, 31.29 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: 94%|█████████▍| 132/140 [00:04<00:00, 31.35 it/sec, feas=True, obj=-3.96e+3] INFO - 16:24:13: Optimization result: INFO - 16:24:13: Optimizer info: INFO - 16:24:13: Status: None INFO - 16:24:13: Message: Successive iterates of the objective function are closer than ftol_rel or ftol_abs. GEMSEO stopped the driver. INFO - 16:24:13: Solution: INFO - 16:24:13: The solution is feasible. INFO - 16:24:13: Objective: -3961.5283906802492 INFO - 16:24:13: Standardized constraints: INFO - 16:24:13: g_1_g_2_g_3 = [-1.73785497e-02 -3.28550438e-02 -4.38672869e-02 -5.15223115e-02 INFO - 16:24:13: -5.70621940e-02 -1.37208650e-01 -1.02791350e-01 -2.22321174e-04 INFO - 16:24:13: -7.67541611e-01 -2.32458389e-01 2.52561943e-06 -1.83255000e-01] INFO - 16:24:13: Design space: INFO - 16:24:13: +-------------+-------------+---------------------+-------------+-------+ INFO - 16:24:13: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:24:13: +-------------+-------------+---------------------+-------------+-------+ INFO - 16:24:13: | x_shared[0] | 0.01 | 0.05994441970638024 | 0.09 | float | INFO - 16:24:13: | x_shared[1] | 30000 | 60000 | 60000 | float | INFO - 16:24:13: | x_shared[2] | 1.4 | 1.4 | 1.8 | float | INFO - 16:24:13: | x_shared[3] | 2.5 | 2.5 | 8.5 | float | INFO - 16:24:13: | x_shared[4] | 40 | 70 | 70 | float | INFO - 16:24:13: | x_shared[5] | 500 | 1500 | 1500 | float | INFO - 16:24:13: +-------------+-------------+---------------------+-------------+-------+ INFO - 16:24:13: *** End MDOScenario execution *** .. GENERATED FROM PYTHON SOURCE LINES 185-188 Plot the history of the MDA residuals ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For the first MDA: .. GENERATED FROM PYTHON SOURCE LINES 188-190 .. 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 191-192 For the second MDA: .. GENERATED FROM PYTHON SOURCE LINES 192-194 .. 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 195-197 Plot the system optimization history view ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 197-199 .. 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 200-202 Plot the structure optimization histories of the 2 first iterations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 202-210 .. 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 6.221 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 `_