Note
Click here to download the full example code
Solve a 2D short cantilever topology optimization problem¶
from __future__ import annotations
import matplotlib.pyplot as plt
from gemseo.api import configure_logger
from gemseo.api import create_scenario
from gemseo.problems.topo_opt.topopt_initialize import (
initialize_design_space_and_discipline_to,
)
from matplotlib import colors
configure_logger()
<RootLogger root (INFO)>
Setup the topology optimization problem¶
Define the target volume fraction:
volume_fraction = 0.3
Define the problem type:
problem_name = "Short_Cantilever"
Define the number of elements in the x- and y- directions:
n_x = 50
n_y = 25
Define the full material Young’s modulus and Poisson’s ratio:
e0 = 1
nu = 0.3
Define the penalty of the SIMP approach:
penalty = 3
Define the minimum member size in the solution:
min_memeber_size = 1.5
Instantiate the DesignSpace
and the disciplines:
design_space, disciplines = initialize_design_space_and_discipline_to(
problem=problem_name,
n_x=n_x,
n_y=n_y,
e0=e0,
nu=nu,
penalty=penalty,
min_member_size=min_memeber_size,
vf0=volume_fraction,
)
Solve the topology optimization problem¶
Generate a MDOScenario
:
scenario = create_scenario(
disciplines,
formulation="DisciplinaryOpt",
objective_name="compliance",
design_space=design_space,
)
Add the volume fraction constraint to the scenario:
scenario.add_constraint("volume fraction", "ineq", value=volume_fraction)
Generate the XDSM:
scenario.xdsmize()
INFO - 09:02:40: Generating HTML XDSM file in : xdsm.html
Execute the scenario:
scenario.execute(input_data={"max_iter": 200, "algo": "NLOPT_MMA"})
INFO - 09:02:40:
INFO - 09:02:40: *** Start MDOScenario execution ***
INFO - 09:02:40: MDOScenario
INFO - 09:02:40: Disciplines: DensityFilter FininiteElementAnalysis MaterialModelInterpolation VolumeFraction
INFO - 09:02:40: MDO formulation: DisciplinaryOpt
INFO - 09:02:40: Optimization problem:
INFO - 09:02:40: minimize compliance(x)
INFO - 09:02:40: with respect to x
INFO - 09:02:40: subject to constraints:
INFO - 09:02:40: volume fraction(x) <= 0.3
INFO - 09:02:40: Solving optimization problem with algorithm NLOPT_MMA:
INFO - 09:02:40: ... 0%| | 0/200 [00:00<?, ?it]
INFO - 09:02:40: ... 0%| | 1/200 [00:00<00:18, 10.96 it/sec, obj=1.46e+3]
INFO - 09:02:40: ... 1%| | 2/200 [00:00<00:32, 6.14 it/sec, obj=1.46e+3]
INFO - 09:02:40: ... 2%|▏ | 3/200 [00:00<00:28, 6.86 it/sec, obj=1.45e+3]
INFO - 09:02:40: ... 2%|▏ | 4/200 [00:00<00:26, 7.48 it/sec, obj=1.45e+3]
INFO - 09:02:40: ... 2%|▎ | 5/200 [00:00<00:25, 7.72 it/sec, obj=1.45e+3]
INFO - 09:02:41: ... 3%|▎ | 6/200 [00:00<00:24, 8.02 it/sec, obj=1.43e+3]
INFO - 09:02:41: ... 4%|▎ | 7/200 [00:00<00:23, 8.15 it/sec, obj=1.4e+3]
INFO - 09:02:41: ... 4%|▍ | 8/200 [00:00<00:23, 8.32 it/sec, obj=1.36e+3]
INFO - 09:02:41: ... 4%|▍ | 9/200 [00:01<00:22, 8.37 it/sec, obj=1.2e+3]
INFO - 09:02:41: ... 5%|▌ | 10/200 [00:01<00:22, 8.49 it/sec, obj=1.01e+3]
INFO - 09:02:41: ... 6%|▌ | 11/200 [00:01<00:22, 8.52 it/sec, obj=756]
INFO - 09:02:41: ... 6%|▌ | 12/200 [00:01<00:21, 8.63 it/sec, obj=573]
INFO - 09:02:41: ... 6%|▋ | 13/200 [00:01<00:21, 8.65 it/sec, obj=509]
INFO - 09:02:41: ... 7%|▋ | 14/200 [00:01<00:21, 8.74 it/sec, obj=448]
INFO - 09:02:41: ... 8%|▊ | 15/200 [00:01<00:21, 8.75 it/sec, obj=399]
INFO - 09:02:42: ... 8%|▊ | 16/200 [00:01<00:20, 8.83 it/sec, obj=360]
INFO - 09:02:42: ... 8%|▊ | 17/200 [00:01<00:20, 8.84 it/sec, obj=329]
INFO - 09:02:42: ... 9%|▉ | 18/200 [00:02<00:20, 8.89 it/sec, obj=304]
INFO - 09:02:42: ... 10%|▉ | 19/200 [00:02<00:20, 8.91 it/sec, obj=278]
INFO - 09:02:42: ... 10%|█ | 20/200 [00:02<00:20, 8.95 it/sec, obj=251]
INFO - 09:02:42: ... 10%|█ | 21/200 [00:02<00:20, 8.94 it/sec, obj=231]
INFO - 09:02:42: ... 11%|█ | 22/200 [00:02<00:19, 9.00 it/sec, obj=213]
INFO - 09:02:42: ... 12%|█▏ | 23/200 [00:02<00:19, 9.00 it/sec, obj=193]
INFO - 09:02:42: ... 12%|█▏ | 24/200 [00:02<00:19, 9.04 it/sec, obj=175]
INFO - 09:02:43: ... 12%|█▎ | 25/200 [00:02<00:19, 9.04 it/sec, obj=161]
INFO - 09:02:43: ... 13%|█▎ | 26/200 [00:02<00:19, 9.08 it/sec, obj=153]
INFO - 09:02:43: ... 14%|█▎ | 27/200 [00:02<00:19, 9.08 it/sec, obj=148]
INFO - 09:02:43: ... 14%|█▍ | 28/200 [00:03<00:18, 9.12 it/sec, obj=145]
INFO - 09:02:43: ... 14%|█▍ | 29/200 [00:03<00:18, 9.12 it/sec, obj=143]
INFO - 09:02:43: ... 15%|█▌ | 30/200 [00:03<00:18, 9.16 it/sec, obj=142]
INFO - 09:02:43: ... 16%|█▌ | 31/200 [00:03<00:18, 9.16 it/sec, obj=141]
INFO - 09:02:43: ... 16%|█▌ | 32/200 [00:03<00:18, 9.20 it/sec, obj=140]
INFO - 09:02:43: ... 16%|█▋ | 33/200 [00:03<00:18, 9.20 it/sec, obj=140]
INFO - 09:02:43: ... 17%|█▋ | 34/200 [00:03<00:17, 9.23 it/sec, obj=140]
INFO - 09:02:44: ... 18%|█▊ | 35/200 [00:03<00:17, 9.24 it/sec, obj=139]
INFO - 09:02:44: ... 18%|█▊ | 36/200 [00:03<00:17, 9.26 it/sec, obj=139]
INFO - 09:02:44: ... 18%|█▊ | 37/200 [00:03<00:17, 9.27 it/sec, obj=139]
INFO - 09:02:44: ... 19%|█▉ | 38/200 [00:04<00:17, 9.30 it/sec, obj=139]
INFO - 09:02:44: ... 20%|█▉ | 39/200 [00:04<00:17, 9.29 it/sec, obj=139]
INFO - 09:02:44: ... 20%|██ | 40/200 [00:04<00:17, 9.32 it/sec, obj=139]
INFO - 09:02:44: ... 20%|██ | 41/200 [00:04<00:17, 9.32 it/sec, obj=139]
INFO - 09:02:44: ... 21%|██ | 42/200 [00:04<00:16, 9.34 it/sec, obj=138]
INFO - 09:02:44: ... 22%|██▏ | 43/200 [00:04<00:16, 9.34 it/sec, obj=138]
INFO - 09:02:44: ... 22%|██▏ | 44/200 [00:04<00:16, 9.36 it/sec, obj=138]
INFO - 09:02:45: ... 22%|██▎ | 45/200 [00:04<00:16, 9.36 it/sec, obj=138]
INFO - 09:02:45: ... 23%|██▎ | 46/200 [00:04<00:16, 9.38 it/sec, obj=138]
INFO - 09:02:45: ... 24%|██▎ | 47/200 [00:05<00:16, 9.37 it/sec, obj=138]
INFO - 09:02:45: ... 24%|██▍ | 48/200 [00:05<00:16, 9.39 it/sec, obj=138]
INFO - 09:02:45: ... 24%|██▍ | 49/200 [00:05<00:16, 9.39 it/sec, obj=138]
INFO - 09:02:45: ... 25%|██▌ | 50/200 [00:05<00:15, 9.41 it/sec, obj=138]
INFO - 09:02:45: ... 26%|██▌ | 51/200 [00:05<00:15, 9.40 it/sec, obj=138]
INFO - 09:02:45: ... 26%|██▌ | 52/200 [00:05<00:15, 9.41 it/sec, obj=138]
INFO - 09:02:45: ... 26%|██▋ | 53/200 [00:05<00:15, 9.40 it/sec, obj=138]
INFO - 09:02:45: ... 27%|██▋ | 54/200 [00:05<00:15, 9.42 it/sec, obj=137]
INFO - 09:02:46: ... 28%|██▊ | 55/200 [00:05<00:15, 9.43 it/sec, obj=137]
INFO - 09:02:46: ... 28%|██▊ | 56/200 [00:05<00:15, 9.44 it/sec, obj=137]
INFO - 09:02:46: ... 28%|██▊ | 57/200 [00:06<00:15, 9.44 it/sec, obj=137]
INFO - 09:02:46: ... 29%|██▉ | 58/200 [00:06<00:15, 9.46 it/sec, obj=137]
INFO - 09:02:46: ... 30%|██▉ | 59/200 [00:06<00:14, 9.45 it/sec, obj=137]
INFO - 09:02:46: ... 30%|███ | 60/200 [00:06<00:14, 9.47 it/sec, obj=137]
INFO - 09:02:46: ... 30%|███ | 61/200 [00:06<00:14, 9.46 it/sec, obj=137]
INFO - 09:02:46: ... 31%|███ | 62/200 [00:06<00:14, 9.48 it/sec, obj=137]
INFO - 09:02:46: ... 32%|███▏ | 63/200 [00:06<00:14, 9.47 it/sec, obj=137]
INFO - 09:02:47: ... 32%|███▏ | 64/200 [00:06<00:14, 9.48 it/sec, obj=137]
INFO - 09:02:47: ... 32%|███▎ | 65/200 [00:06<00:14, 9.47 it/sec, obj=137]
INFO - 09:02:47: ... 33%|███▎ | 66/200 [00:06<00:14, 9.49 it/sec, obj=137]
INFO - 09:02:47: ... 34%|███▎ | 67/200 [00:07<00:14, 9.48 it/sec, obj=137]
INFO - 09:02:47: ... 34%|███▍ | 68/200 [00:07<00:13, 9.49 it/sec, obj=137]
INFO - 09:02:47: ... 34%|███▍ | 69/200 [00:07<00:13, 9.49 it/sec, obj=137]
INFO - 09:02:47: ... 35%|███▌ | 70/200 [00:07<00:13, 9.49 it/sec, obj=137]
INFO - 09:02:47: ... 36%|███▌ | 71/200 [00:07<00:13, 9.48 it/sec, obj=137]
INFO - 09:02:47: ... 36%|███▌ | 72/200 [00:07<00:13, 9.49 it/sec, obj=137]
INFO - 09:02:47: ... 36%|███▋ | 73/200 [00:07<00:13, 9.48 it/sec, obj=137]
INFO - 09:02:48: ... 37%|███▋ | 74/200 [00:07<00:13, 9.49 it/sec, obj=137]
INFO - 09:02:48: ... 38%|███▊ | 75/200 [00:07<00:13, 9.49 it/sec, obj=137]
INFO - 09:02:48: ... 38%|███▊ | 76/200 [00:08<00:13, 9.50 it/sec, obj=137]
INFO - 09:02:48: ... 38%|███▊ | 77/200 [00:08<00:12, 9.49 it/sec, obj=137]
INFO - 09:02:48: ... 39%|███▉ | 78/200 [00:08<00:12, 9.50 it/sec, obj=137]
INFO - 09:02:48: ... 40%|███▉ | 79/200 [00:08<00:12, 9.49 it/sec, obj=137]
INFO - 09:02:48: ... 40%|████ | 80/200 [00:08<00:12, 9.50 it/sec, obj=137]
INFO - 09:02:48: ... 40%|████ | 81/200 [00:08<00:12, 9.50 it/sec, obj=137]
INFO - 09:02:48: ... 41%|████ | 82/200 [00:08<00:12, 9.51 it/sec, obj=137]
INFO - 09:02:48: ... 42%|████▏ | 83/200 [00:08<00:12, 9.50 it/sec, obj=137]
INFO - 09:02:49: ... 42%|████▏ | 84/200 [00:08<00:12, 9.51 it/sec, obj=137]
INFO - 09:02:49: ... 42%|████▎ | 85/200 [00:08<00:12, 9.50 it/sec, obj=137]
INFO - 09:02:49: ... 43%|████▎ | 86/200 [00:09<00:11, 9.51 it/sec, obj=137]
INFO - 09:02:49: ... 44%|████▎ | 87/200 [00:09<00:11, 9.51 it/sec, obj=137]
INFO - 09:02:49: ... 44%|████▍ | 88/200 [00:09<00:11, 9.52 it/sec, obj=137]
INFO - 09:02:49: ... 44%|████▍ | 89/200 [00:09<00:11, 9.51 it/sec, obj=137]
INFO - 09:02:49: ... 45%|████▌ | 90/200 [00:09<00:11, 9.51 it/sec, obj=137]
INFO - 09:02:49: ... 46%|████▌ | 91/200 [00:09<00:11, 9.51 it/sec, obj=137]
INFO - 09:02:49: ... 46%|████▌ | 92/200 [00:09<00:11, 9.51 it/sec, obj=137]
INFO - 09:02:50: ... 46%|████▋ | 93/200 [00:09<00:11, 9.51 it/sec, obj=137]
INFO - 09:02:50: ... 47%|████▋ | 94/200 [00:09<00:11, 9.52 it/sec, obj=137]
INFO - 09:02:50: ... 48%|████▊ | 95/200 [00:09<00:11, 9.52 it/sec, obj=137]
INFO - 09:02:50: ... 48%|████▊ | 96/200 [00:10<00:10, 9.52 it/sec, obj=137]
INFO - 09:02:50: ... 48%|████▊ | 97/200 [00:10<00:10, 9.52 it/sec, obj=137]
INFO - 09:02:50: ... 49%|████▉ | 98/200 [00:10<00:10, 9.53 it/sec, obj=137]
INFO - 09:02:50: ... 50%|████▉ | 99/200 [00:10<00:10, 9.53 it/sec, obj=137]
INFO - 09:02:50: ... 50%|█████ | 100/200 [00:10<00:10, 9.53 it/sec, obj=137]
INFO - 09:02:50: ... 50%|█████ | 101/200 [00:10<00:10, 9.53 it/sec, obj=137]
INFO - 09:02:50: ... 51%|█████ | 102/200 [00:10<00:10, 9.54 it/sec, obj=137]
INFO - 09:02:51: ... 52%|█████▏ | 103/200 [00:10<00:10, 9.53 it/sec, obj=137]
INFO - 09:02:51: ... 52%|█████▏ | 104/200 [00:10<00:10, 9.54 it/sec, obj=137]
INFO - 09:02:51: ... 52%|█████▎ | 105/200 [00:11<00:09, 9.53 it/sec, obj=137]
INFO - 09:02:51: ... 53%|█████▎ | 106/200 [00:11<00:09, 9.54 it/sec, obj=137]
INFO - 09:02:51: ... 54%|█████▎ | 107/200 [00:11<00:09, 9.53 it/sec, obj=137]
INFO - 09:02:51: ... 54%|█████▍ | 108/200 [00:11<00:09, 9.54 it/sec, obj=137]
INFO - 09:02:51: ... 55%|█████▍ | 109/200 [00:11<00:09, 9.53 it/sec, obj=137]
INFO - 09:02:51: ... 55%|█████▌ | 110/200 [00:11<00:09, 9.53 it/sec, obj=137]
INFO - 09:02:51: ... 56%|█████▌ | 111/200 [00:11<00:09, 9.53 it/sec, obj=137]
INFO - 09:02:52: ... 56%|█████▌ | 112/200 [00:11<00:09, 9.54 it/sec, obj=137]
INFO - 09:02:52: ... 56%|█████▋ | 113/200 [00:11<00:09, 9.54 it/sec, obj=137]
INFO - 09:02:52: ... 57%|█████▋ | 114/200 [00:11<00:09, 9.54 it/sec, obj=137]
INFO - 09:02:52: ... 57%|█████▊ | 115/200 [00:12<00:08, 9.54 it/sec, obj=137]
INFO - 09:02:52: ... 58%|█████▊ | 116/200 [00:12<00:08, 9.55 it/sec, obj=137]
INFO - 09:02:52: ... 58%|█████▊ | 117/200 [00:12<00:08, 9.55 it/sec, obj=137]
INFO - 09:02:52: ... 59%|█████▉ | 118/200 [00:12<00:08, 9.55 it/sec, obj=137]
INFO - 09:02:52: ... 60%|█████▉ | 119/200 [00:12<00:08, 9.55 it/sec, obj=137]
INFO - 09:02:52: ... 60%|██████ | 120/200 [00:12<00:08, 9.55 it/sec, obj=137]
INFO - 09:02:52: ... 60%|██████ | 121/200 [00:12<00:08, 9.55 it/sec, obj=137]
INFO - 09:02:53: ... 61%|██████ | 122/200 [00:12<00:08, 9.55 it/sec, obj=137]
INFO - 09:02:53: ... 62%|██████▏ | 123/200 [00:12<00:08, 9.55 it/sec, obj=137]
INFO - 09:02:53: ... 62%|██████▏ | 124/200 [00:12<00:07, 9.55 it/sec, obj=137]
INFO - 09:02:53: ... 62%|██████▎ | 125/200 [00:13<00:07, 9.55 it/sec, obj=137]
INFO - 09:02:53: ... 63%|██████▎ | 126/200 [00:13<00:07, 9.55 it/sec, obj=137]
INFO - 09:02:53: ... 64%|██████▎ | 127/200 [00:13<00:07, 9.55 it/sec, obj=137]
INFO - 09:02:53: ... 64%|██████▍ | 128/200 [00:13<00:07, 9.55 it/sec, obj=137]
INFO - 09:02:53: ... 64%|██████▍ | 129/200 [00:13<00:07, 9.55 it/sec, obj=137]
INFO - 09:02:53: ... 65%|██████▌ | 130/200 [00:13<00:07, 9.56 it/sec, obj=137]
INFO - 09:02:53: ... 66%|██████▌ | 131/200 [00:13<00:07, 9.55 it/sec, obj=137]
INFO - 09:02:54: ... 66%|██████▌ | 132/200 [00:13<00:07, 9.56 it/sec, obj=137]
INFO - 09:02:54: ... 66%|██████▋ | 133/200 [00:13<00:07, 9.56 it/sec, obj=137]
INFO - 09:02:54: ... 67%|██████▋ | 134/200 [00:14<00:06, 9.56 it/sec, obj=137]
INFO - 09:02:54: ... 68%|██████▊ | 135/200 [00:14<00:06, 9.56 it/sec, obj=137]
INFO - 09:02:54: ... 68%|██████▊ | 136/200 [00:14<00:06, 9.56 it/sec, obj=137]
INFO - 09:02:54: ... 68%|██████▊ | 137/200 [00:14<00:06, 9.56 it/sec, obj=137]
INFO - 09:02:54: ... 69%|██████▉ | 138/200 [00:14<00:06, 9.57 it/sec, obj=137]
INFO - 09:02:54: ... 70%|██████▉ | 139/200 [00:14<00:06, 9.56 it/sec, obj=137]
INFO - 09:02:54: ... 70%|███████ | 140/200 [00:14<00:06, 9.57 it/sec, obj=137]
INFO - 09:02:55: ... 70%|███████ | 141/200 [00:14<00:06, 9.56 it/sec, obj=137]
INFO - 09:02:55: ... 71%|███████ | 142/200 [00:14<00:06, 9.57 it/sec, obj=137]
INFO - 09:02:55: ... 72%|███████▏ | 143/200 [00:14<00:05, 9.56 it/sec, obj=137]
INFO - 09:02:55: ... 72%|███████▏ | 144/200 [00:15<00:05, 9.57 it/sec, obj=137]
INFO - 09:02:55: ... 72%|███████▎ | 145/200 [00:15<00:05, 9.56 it/sec, obj=137]
INFO - 09:02:55: ... 73%|███████▎ | 146/200 [00:15<00:05, 9.57 it/sec, obj=137]
INFO - 09:02:55: ... 74%|███████▎ | 147/200 [00:15<00:05, 9.57 it/sec, obj=137]
INFO - 09:02:55: ... 74%|███████▍ | 148/200 [00:15<00:05, 9.58 it/sec, obj=137]
INFO - 09:02:55: ... 74%|███████▍ | 149/200 [00:15<00:05, 9.57 it/sec, obj=137]
INFO - 09:02:55: ... 75%|███████▌ | 150/200 [00:15<00:05, 9.58 it/sec, obj=137]
INFO - 09:02:56: ... 76%|███████▌ | 151/200 [00:15<00:05, 9.58 it/sec, obj=137]
INFO - 09:02:56: ... 76%|███████▌ | 152/200 [00:15<00:05, 9.58 it/sec, obj=137]
INFO - 09:02:56: ... 76%|███████▋ | 153/200 [00:15<00:04, 9.58 it/sec, obj=137]
INFO - 09:02:56: ... 77%|███████▋ | 154/200 [00:16<00:04, 9.58 it/sec, obj=137]
INFO - 09:02:56: ... 78%|███████▊ | 155/200 [00:16<00:04, 9.58 it/sec, obj=137]
INFO - 09:02:56: ... 78%|███████▊ | 156/200 [00:16<00:04, 9.58 it/sec, obj=137]
INFO - 09:02:56: ... 78%|███████▊ | 157/200 [00:16<00:04, 9.58 it/sec, obj=137]
INFO - 09:02:56: ... 79%|███████▉ | 158/200 [00:16<00:04, 9.58 it/sec, obj=137]
INFO - 09:02:56: ... 80%|███████▉ | 159/200 [00:16<00:04, 9.58 it/sec, obj=137]
INFO - 09:02:56: ... 80%|████████ | 160/200 [00:16<00:04, 9.59 it/sec, obj=137]
INFO - 09:02:57: ... 80%|████████ | 161/200 [00:16<00:04, 9.58 it/sec, obj=137]
INFO - 09:02:57: ... 81%|████████ | 162/200 [00:16<00:03, 9.59 it/sec, obj=137]
INFO - 09:02:57: ... 82%|████████▏ | 163/200 [00:17<00:03, 9.59 it/sec, obj=137]
INFO - 09:02:57: ... 82%|████████▏ | 164/200 [00:17<00:03, 9.59 it/sec, obj=137]
INFO - 09:02:57: ... 82%|████████▎ | 165/200 [00:17<00:03, 9.59 it/sec, obj=137]
INFO - 09:02:57: ... 83%|████████▎ | 166/200 [00:17<00:03, 9.59 it/sec, obj=137]
INFO - 09:02:57: ... 84%|████████▎ | 167/200 [00:17<00:03, 9.59 it/sec, obj=137]
INFO - 09:02:57: ... 84%|████████▍ | 168/200 [00:17<00:03, 9.59 it/sec, obj=137]
INFO - 09:02:57: ... 84%|████████▍ | 169/200 [00:17<00:03, 9.59 it/sec, obj=137]
INFO - 09:02:57: ... 85%|████████▌ | 170/200 [00:17<00:03, 9.60 it/sec, obj=137]
INFO - 09:02:58: ... 86%|████████▌ | 171/200 [00:17<00:03, 9.59 it/sec, obj=137]
INFO - 09:02:58: ... 86%|████████▌ | 172/200 [00:17<00:02, 9.60 it/sec, obj=137]
INFO - 09:02:58: ... 86%|████████▋ | 173/200 [00:18<00:02, 9.60 it/sec, obj=137]
INFO - 09:02:58: ... 87%|████████▋ | 174/200 [00:18<00:02, 9.60 it/sec, obj=137]
INFO - 09:02:58: ... 88%|████████▊ | 175/200 [00:18<00:02, 9.60 it/sec, obj=137]
INFO - 09:02:58: ... 88%|████████▊ | 176/200 [00:18<00:02, 9.60 it/sec, obj=137]
INFO - 09:02:58: ... 88%|████████▊ | 177/200 [00:18<00:02, 9.60 it/sec, obj=137]
INFO - 09:02:58: ... 89%|████████▉ | 178/200 [00:18<00:02, 9.60 it/sec, obj=137]
INFO - 09:02:58: ... 90%|████████▉ | 179/200 [00:18<00:02, 9.60 it/sec, obj=137]
INFO - 09:02:59: ... 90%|█████████ | 180/200 [00:18<00:02, 9.60 it/sec, obj=137]
INFO - 09:02:59: ... 90%|█████████ | 181/200 [00:18<00:01, 9.60 it/sec, obj=137]
INFO - 09:02:59: ... 91%|█████████ | 182/200 [00:18<00:01, 9.60 it/sec, obj=137]
INFO - 09:02:59: ... 92%|█████████▏| 183/200 [00:19<00:01, 9.60 it/sec, obj=137]
INFO - 09:02:59: ... 92%|█████████▏| 184/200 [00:19<00:01, 9.61 it/sec, obj=137]
INFO - 09:02:59: ... 92%|█████████▎| 185/200 [00:19<00:01, 9.60 it/sec, obj=137]
INFO - 09:02:59: ... 93%|█████████▎| 186/200 [00:19<00:01, 9.65 it/sec, obj=Not evaluated]
INFO - 09:02:59: Optimization result:
INFO - 09:02:59: Optimizer info:
INFO - 09:02:59: Status: None
INFO - 09:02:59: Message: Successive iterates of the objective function are closer than ftol_rel or ftol_abs. GEMSEO Stopped the driver
INFO - 09:02:59: Number of calls to the objective function by the optimizer: 186
INFO - 09:02:59: Solution:
INFO - 09:02:59: The solution is feasible.
INFO - 09:02:59: Objective: 136.56131771172448
INFO - 09:02:59: Standardized constraints:
INFO - 09:02:59: volume fraction - 0.3 = -1.0460364907594055e-08
INFO - 09:02:59: *** End MDOScenario execution (time: 0:00:19.290318) ***
{'max_iter': 200, 'algo': 'NLOPT_MMA'}
Results¶
Post-process the optimization history:
scenario.post_process(
"BasicHistory",
variable_names=["compliance"],
save=True,
show=False,
file_name=problem_name + "_history.png",
)
<gemseo.post.basic_history.BasicHistory object at 0x7fd3a0491fd0>

Plot the solution:
plt.ion() # Ensure that redrawing is possible
fig, ax = plt.subplots()
im = ax.imshow(
-scenario.optimization_result.x_opt.reshape((n_x, n_y)).T,
cmap="gray",
interpolation="none",
norm=colors.Normalize(vmin=-1, vmax=0),
)
fig.show()
im.set_array(-scenario.optimization_result.x_opt.reshape((n_x, n_y)).T)
fig.canvas.draw()
plt.savefig(problem_name + "_solution.png")


Total running time of the script: ( 0 minutes 19.897 seconds)