Note
Click here to download the full example code
Parametric scalable MDO problem - MDF¶
We define a scalable problem based on two strongly coupled disciplines and a weakly one, with the following properties:
3 shared design parameters,
2 local design parameters for the first strongly coupled discipline,
2 coupling variables for the first strongly coupled discipline,
4 local design parameters for the second strongly coupled discipline,
3 coupling variables for the second strongly coupled discipline.
We would like to solve this MDO problem by means of an MDF formulation.
from __future__ import division, unicode_literals
from matplotlib import pyplot as plt
from gemseo.api import configure_logger, create_scenario, generate_n2_plot
from gemseo.problems.scalable.parametric.problem import TMScalableProblem
configure_logger()
Out:
<RootLogger root (INFO)>
Instantiation of the scalable problem¶
n_shared = 3
n_local = [2, 4]
n_coupling = [2, 3]
problem = TMScalableProblem(n_shared, n_local, n_coupling)
Out:
INFO - 09:23:36: *** Create a new parameter space ***
Display the coupling structure¶
generate_n2_plot(problem.disciplines, save=False, show=True)
Solve the MDO using an MDF formulation¶
scenario = create_scenario(problem.disciplines, "MDF", "obj", problem.design_space)
scenario.add_constraint("cstr_0", "ineq")
scenario.add_constraint("cstr_1", "ineq")
scenario.execute({"algo": "NLOPT_SLSQP", "max_iter": 100})
Out:
INFO - 09:23:36:
INFO - 09:23:36: *** Start MDO Scenario execution ***
INFO - 09:23:36: MDOScenario
INFO - 09:23:36: Disciplines: MainModel SubModel_0 SubModel_1
INFO - 09:23:36: MDOFormulation: MDF
INFO - 09:23:36: Algorithm: NLOPT_SLSQP
INFO - 09:23:36: Optimization problem:
INFO - 09:23:36: Minimize: obj(x_local_0, x_local_1, x_shared)
INFO - 09:23:36: With respect to: x_local_0, x_local_1, x_shared
INFO - 09:23:36: Subject to constraints:
INFO - 09:23:36: cstr_0(x_local_0, x_local_1, x_shared) <= 0.0
INFO - 09:23:36: cstr_1(x_local_0, x_local_1, x_shared) <= 0.0
INFO - 09:23:36: +------------------------------------------------------------------------------+
INFO - 09:23:36: | Parameter space |
INFO - 09:23:36: +-----------+-------------+-------+-------------+-------+----------------------+
INFO - 09:23:36: | name | lower_bound | value | upper_bound | type | Initial distribution |
INFO - 09:23:36: +-----------+-------------+-------+-------------+-------+----------------------+
INFO - 09:23:36: | x_local_0 | 0 | 0.5 | 1 | float | |
INFO - 09:23:36: | x_local_0 | 0 | 0.5 | 1 | float | |
INFO - 09:23:36: | x_local_1 | 0 | 0.5 | 1 | float | |
INFO - 09:23:36: | x_local_1 | 0 | 0.5 | 1 | float | |
INFO - 09:23:36: | x_local_1 | 0 | 0.5 | 1 | float | |
INFO - 09:23:36: | x_local_1 | 0 | 0.5 | 1 | float | |
INFO - 09:23:36: | x_shared | 0 | 0.5 | 1 | float | |
INFO - 09:23:36: | x_shared | 0 | 0.5 | 1 | float | |
INFO - 09:23:36: | x_shared | 0 | 0.5 | 1 | float | |
INFO - 09:23:36: +-----------+-------------+-------+-------------+-------+----------------------+
INFO - 09:23:36: Optimization: 0%| | 0/100 [00:00<?, ?it]
WARNING - 09:23:36: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:36: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.06535831 -0.1012953 -0.15365405 -0.04796975 -0.03817772 -0.09325931]
WARNING - 09:23:36: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.06535831 -0.1012953 -0.15365405 -0.04796975 -0.03817772 -0.09325931]
WARNING - 09:23:36: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:36: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.11021098 -0.17164181 -0.27147077 -0.0834051 -0.06725633 -0.16440469
WARNING - 09:23:37: -0.2374275 -0.41605455 -0.19216792]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
INFO - 09:23:37: Optimization: 3%|▎ | 3/100 [00:00<00:00, 995.58 it/sec, obj=0.761]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.10676616 -0.16636559 -0.26721994 -0.08208378 -0.06636862 -0.16217295
WARNING - 09:23:37: -0.18820449 -0.38824109 -0.1892308 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.09997637 -0.1561866 -0.25926184 -0.07957677 -0.06476275 -0.1581117
WARNING - 09:23:37: -0.12069412 -0.38099617 -0.18369013]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.09887809 -0.15463781 -0.2588136 -0.07924044 -0.06457881 -0.15769541
WARNING - 09:23:37: -0.14366232 -0.39044485 -0.18296192]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
INFO - 09:23:37: Optimization: 6%|▌ | 6/100 [00:00<00:00, 385.05 it/sec, obj=0.682]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.09765871 -0.15296585 -0.25910732 -0.07894811 -0.06443323 -0.15743311
WARNING - 09:23:37: -0.22542896 -0.38987695 -0.18230891]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.09736863 -0.15256742 -0.25917601 -0.07887843 -0.06439823 -0.15736984
WARNING - 09:23:37: -0.24490951 -0.38973614 -0.18215301]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.09736908 -0.15256735 -0.25917469 -0.07887842 -0.06439792 -0.15736906
WARNING - 09:23:37: -0.24490739 -0.38973054 -0.18215271]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
INFO - 09:23:37: Optimization: 9%|▉ | 9/100 [00:00<00:00, 239.98 it/sec, obj=0.671]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.09737789 -0.15258012 -0.25917314 -0.07887164 -0.06439523 -0.15736355
WARNING - 09:23:37: -0.2449149 -0.38973511 -0.18214681]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.09742174 -0.15264383 -0.25916558 -0.07883787 -0.0643819 -0.1573362
WARNING - 09:23:37: -0.24495263 -0.38975866 -0.18211746]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.09763371 -0.15295179 -0.25912905 -0.07867458 -0.06431742 -0.15720398
WARNING - 09:23:37: -0.24513503 -0.3898725 -0.18197561]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
INFO - 09:23:37: Optimization: 12%|█▏ | 12/100 [00:00<00:00, 172.32 it/sec, obj=0.671]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.09851788 -0.15423633 -0.25897667 -0.07799349 -0.06404848 -0.15665247
WARNING - 09:23:37: -0.24589585 -0.39034734 -0.1813839 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.0987004 -0.1545015 -0.25894521 -0.07785289 -0.06399296 -0.15653862
WARNING - 09:23:37: -0.24605291 -0.39044536 -0.18126175]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.0987004 -0.1545015 -0.25894521 -0.07785289 -0.06399296 -0.15653862
WARNING - 09:23:37: -0.24605291 -0.39044536 -0.18126175]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
INFO - 09:23:37: Optimization: 15%|█▌ | 15/100 [00:00<00:00, 134.58 it/sec, obj=0.67]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. lower bounds violated : [-0.0987004 -0.1545015 -0.25894521 -0.07785289 -0.06399296 -0.15653862
WARNING - 09:23:37: -0.24605291 -0.39044536 -0.18126175]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
WARNING - 09:23:37: All components of the normalized vector should be between 0 and 1. upper bounds violated : [1.35778211 1.8801818 1.13744624 1.68888531 1.6401472 ]
INFO - 09:23:37: Optimization: 16%|█▌ | 16/100 [00:00<00:00, 125.49 it/sec, obj=0.67]
INFO - 09:23:37: Optimization result:
INFO - 09:23:37: Objective value = 0.6704638786393968
INFO - 09:23:37: The result is feasible.
INFO - 09:23:37: Status: None
INFO - 09:23:37: Optimizer message: Successive iterates of the objective function are closer than ftol_rel or ftol_abs. GEMSEO Stopped the driver
INFO - 09:23:37: Number of calls to the objective function by the optimizer: 16
INFO - 09:23:37: Constraints values w.r.t. 0:
INFO - 09:23:37: cstr_0 = [-0.01693211 -5.62972098]
INFO - 09:23:37: cstr_1 = [-1.0547295e+00 4.4408921e-16 -1.8114265e+00]
INFO - 09:23:37: +----------------------------------------------------------------------------------------------+
INFO - 09:23:37: | Parameter space |
INFO - 09:23:37: +-----------+-------------+-----------------------+-------------+-------+----------------------+
INFO - 09:23:37: | name | lower_bound | value | upper_bound | type | Initial distribution |
INFO - 09:23:37: +-----------+-------------+-----------------------+-------------+-------+----------------------+
INFO - 09:23:37: | x_local_0 | 0 | 0.5931064439648844 | 1 | float | |
INFO - 09:23:37: | x_local_0 | 0 | 0.9999999999999999 | 1 | float | |
INFO - 09:23:37: | x_local_1 | 0 | 9.23352249654198e-16 | 1 | float | |
INFO - 09:23:37: | x_local_1 | 0 | 0.9546530639346679 | 1 | float | |
INFO - 09:23:37: | x_local_1 | 0 | 6.181331182052104e-16 | 1 | float | |
INFO - 09:23:37: | x_local_1 | 0 | 9.664271167627181e-16 | 1 | float | |
INFO - 09:23:37: | x_shared | 0 | 0 | 1 | float | |
INFO - 09:23:37: | x_shared | 0 | 1.702522254618302e-16 | 1 | float | |
INFO - 09:23:37: | x_shared | 0 | 2.859684434892608e-16 | 1 | float | |
INFO - 09:23:37: +-----------+-------------+-----------------------+-------------+-------+----------------------+
INFO - 09:23:37: *** MDO Scenario run terminated in 0:00:00.815165 ***
{'algo': 'NLOPT_SLSQP', 'max_iter': 100}
Post-process the results¶
scenario.post_process("OptHistoryView", save=False, show=False)
# Workaround for HTML rendering, instead of ``show=True``
plt.show()
Total running time of the script: ( 0 minutes 2.458 seconds)