# 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 - 17:20:12: Generating HTML XDSM file in : xdsm.html


Execute the scenario:

scenario.execute(input_data={"max_iter": 200, "algo": "NLOPT_MMA"})

    INFO - 17:20:12:
INFO - 17:20:12: *** Start MDOScenario execution ***
INFO - 17:20:12: MDOScenario
INFO - 17:20:12:    Disciplines: DensityFilter FininiteElementAnalysis MaterialModelInterpolation VolumeFraction
INFO - 17:20:12:    MDO formulation: DisciplinaryOpt
INFO - 17:20:12: Optimization problem:
INFO - 17:20:12:    minimize compliance(x)
INFO - 17:20:12:    with respect to x
INFO - 17:20:12:    subject to constraints:
INFO - 17:20:12:       volume fraction(x) <= 0.3
INFO - 17:20:12: Solving optimization problem with algorithm NLOPT_MMA:
INFO - 17:20:12: ...   0%|          | 0/200 [00:00<?, ?it]
INFO - 17:20:12: ...   0%|          | 1/200 [00:00<00:26,  7.57 it/sec, obj=1.46e+3]
INFO - 17:20:13: ...   1%|          | 2/200 [00:00<00:47,  4.15 it/sec, obj=1.46e+3]
INFO - 17:20:13: ...   2%|▏         | 3/200 [00:00<00:42,  4.67 it/sec, obj=1.45e+3]
INFO - 17:20:13: ...   2%|▏         | 4/200 [00:00<00:39,  5.00 it/sec, obj=1.45e+3]
INFO - 17:20:13: ...   2%|▎         | 5/200 [00:00<00:37,  5.20 it/sec, obj=1.45e+3]
INFO - 17:20:13: ...   3%|▎         | 6/200 [00:01<00:36,  5.34 it/sec, obj=1.43e+3]
INFO - 17:20:13: ...   4%|▎         | 7/200 [00:01<00:35,  5.37 it/sec, obj=1.4e+3]
INFO - 17:20:14: ...   4%|▍         | 8/200 [00:01<00:35,  5.45 it/sec, obj=1.36e+3]
INFO - 17:20:14: ...   4%|▍         | 9/200 [00:01<00:34,  5.50 it/sec, obj=1.2e+3]
INFO - 17:20:14: ...   5%|▌         | 10/200 [00:01<00:34,  5.55 it/sec, obj=1.01e+3]
INFO - 17:20:14: ...   6%|▌         | 11/200 [00:01<00:33,  5.61 it/sec, obj=756]
INFO - 17:20:14: ...   6%|▌         | 12/200 [00:02<00:33,  5.66 it/sec, obj=573]
INFO - 17:20:14: ...   6%|▋         | 13/200 [00:02<00:32,  5.67 it/sec, obj=509]
INFO - 17:20:15: ...   7%|▋         | 14/200 [00:02<00:32,  5.71 it/sec, obj=448]
INFO - 17:20:15: ...   8%|▊         | 15/200 [00:02<00:32,  5.75 it/sec, obj=399]
INFO - 17:20:15: ...   8%|▊         | 16/200 [00:02<00:31,  5.78 it/sec, obj=360]
INFO - 17:20:15: ...   8%|▊         | 17/200 [00:02<00:31,  5.81 it/sec, obj=329]
INFO - 17:20:15: ...   9%|▉         | 18/200 [00:03<00:31,  5.82 it/sec, obj=304]
INFO - 17:20:15: ...  10%|▉         | 19/200 [00:03<00:31,  5.83 it/sec, obj=278]
INFO - 17:20:16: ...  10%|█         | 20/200 [00:03<00:30,  5.85 it/sec, obj=251]
INFO - 17:20:16: ...  10%|█         | 21/200 [00:03<00:30,  5.87 it/sec, obj=231]
INFO - 17:20:16: ...  11%|█         | 22/200 [00:03<00:30,  5.89 it/sec, obj=213]
INFO - 17:20:16: ...  12%|█▏        | 23/200 [00:03<00:30,  5.88 it/sec, obj=193]
INFO - 17:20:16: ...  12%|█▏        | 24/200 [00:04<00:29,  5.89 it/sec, obj=175]
INFO - 17:20:16: ...  12%|█▎        | 25/200 [00:04<00:29,  5.90 it/sec, obj=161]
INFO - 17:20:16: ...  13%|█▎        | 26/200 [00:04<00:29,  5.91 it/sec, obj=153]
INFO - 17:20:17: ...  14%|█▎        | 27/200 [00:04<00:29,  5.93 it/sec, obj=148]
INFO - 17:20:17: ...  14%|█▍        | 28/200 [00:04<00:28,  5.95 it/sec, obj=145]
INFO - 17:20:17: ...  14%|█▍        | 29/200 [00:04<00:28,  5.97 it/sec, obj=143]
INFO - 17:20:17: ...  15%|█▌        | 30/200 [00:05<00:28,  5.99 it/sec, obj=142]
INFO - 17:20:17: ...  16%|█▌        | 31/200 [00:05<00:28,  5.99 it/sec, obj=141]
INFO - 17:20:17: ...  16%|█▌        | 32/200 [00:05<00:27,  6.01 it/sec, obj=140]
INFO - 17:20:18: ...  16%|█▋        | 33/200 [00:05<00:27,  6.02 it/sec, obj=140]
INFO - 17:20:18: ...  17%|█▋        | 34/200 [00:05<00:27,  6.04 it/sec, obj=140]
INFO - 17:20:18: ...  18%|█▊        | 35/200 [00:05<00:27,  6.06 it/sec, obj=139]
INFO - 17:20:18: ...  18%|█▊        | 36/200 [00:05<00:26,  6.12 it/sec, obj=139]
INFO - 17:20:18: ...  18%|█▊        | 37/200 [00:06<00:26,  6.12 it/sec, obj=139]
INFO - 17:20:18: ...  19%|█▉        | 38/200 [00:06<00:26,  6.13 it/sec, obj=139]
INFO - 17:20:18: ...  20%|█▉        | 39/200 [00:06<00:26,  6.13 it/sec, obj=139]
INFO - 17:20:19: ...  20%|██        | 40/200 [00:06<00:26,  6.14 it/sec, obj=139]
INFO - 17:20:19: ...  20%|██        | 41/200 [00:06<00:25,  6.16 it/sec, obj=139]
INFO - 17:20:19: ...  21%|██        | 42/200 [00:06<00:25,  6.16 it/sec, obj=138]
INFO - 17:20:19: ...  22%|██▏       | 43/200 [00:06<00:25,  6.16 it/sec, obj=138]
INFO - 17:20:19: ...  22%|██▏       | 44/200 [00:07<00:25,  6.17 it/sec, obj=138]
INFO - 17:20:19: ...  22%|██▎       | 45/200 [00:07<00:25,  6.17 it/sec, obj=138]
INFO - 17:20:20: ...  23%|██▎       | 46/200 [00:07<00:24,  6.18 it/sec, obj=138]
INFO - 17:20:20: ...  24%|██▎       | 47/200 [00:07<00:24,  6.19 it/sec, obj=138]
INFO - 17:20:20: ...  24%|██▍       | 48/200 [00:07<00:24,  6.20 it/sec, obj=138]
INFO - 17:20:20: ...  24%|██▍       | 49/200 [00:07<00:24,  6.20 it/sec, obj=138]
INFO - 17:20:20: ...  25%|██▌       | 50/200 [00:08<00:24,  6.21 it/sec, obj=138]
INFO - 17:20:20: ...  26%|██▌       | 51/200 [00:08<00:23,  6.21 it/sec, obj=138]
INFO - 17:20:20: ...  26%|██▌       | 52/200 [00:08<00:23,  6.22 it/sec, obj=138]
INFO - 17:20:21: ...  26%|██▋       | 53/200 [00:08<00:23,  6.22 it/sec, obj=138]
INFO - 17:20:21: ...  27%|██▋       | 54/200 [00:08<00:23,  6.23 it/sec, obj=137]
INFO - 17:20:21: ...  28%|██▊       | 55/200 [00:08<00:23,  6.22 it/sec, obj=137]
INFO - 17:20:21: ...  28%|██▊       | 56/200 [00:08<00:23,  6.23 it/sec, obj=137]
INFO - 17:20:21: ...  28%|██▊       | 57/200 [00:09<00:22,  6.23 it/sec, obj=137]
INFO - 17:20:21: ...  29%|██▉       | 58/200 [00:09<00:22,  6.24 it/sec, obj=137]
INFO - 17:20:22: ...  30%|██▉       | 59/200 [00:09<00:22,  6.24 it/sec, obj=137]
INFO - 17:20:22: ...  30%|███       | 60/200 [00:09<00:22,  6.25 it/sec, obj=137]
INFO - 17:20:22: ...  30%|███       | 61/200 [00:09<00:22,  6.25 it/sec, obj=137]
INFO - 17:20:22: ...  31%|███       | 62/200 [00:09<00:22,  6.24 it/sec, obj=137]
INFO - 17:20:22: ...  32%|███▏      | 63/200 [00:10<00:21,  6.24 it/sec, obj=137]
INFO - 17:20:22: ...  32%|███▏      | 64/200 [00:10<00:21,  6.24 it/sec, obj=137]
INFO - 17:20:22: ...  32%|███▎      | 65/200 [00:10<00:21,  6.25 it/sec, obj=137]
INFO - 17:20:23: ...  33%|███▎      | 66/200 [00:10<00:21,  6.25 it/sec, obj=137]
INFO - 17:20:23: ...  34%|███▎      | 67/200 [00:10<00:21,  6.25 it/sec, obj=137]
INFO - 17:20:23: ...  34%|███▍      | 68/200 [00:10<00:21,  6.26 it/sec, obj=137]
INFO - 17:20:23: ...  34%|███▍      | 69/200 [00:11<00:20,  6.26 it/sec, obj=137]
INFO - 17:20:23: ...  35%|███▌      | 70/200 [00:11<00:20,  6.27 it/sec, obj=137]
INFO - 17:20:23: ...  36%|███▌      | 71/200 [00:11<00:20,  6.27 it/sec, obj=137]
INFO - 17:20:24: ...  36%|███▌      | 72/200 [00:11<00:20,  6.28 it/sec, obj=137]
INFO - 17:20:24: ...  36%|███▋      | 73/200 [00:11<00:20,  6.27 it/sec, obj=137]
INFO - 17:20:24: ...  37%|███▋      | 74/200 [00:11<00:20,  6.28 it/sec, obj=137]
INFO - 17:20:24: ...  38%|███▊      | 75/200 [00:11<00:19,  6.26 it/sec, obj=137]
INFO - 17:20:24: ...  38%|███▊      | 76/200 [00:12<00:19,  6.26 it/sec, obj=137]
INFO - 17:20:24: ...  38%|███▊      | 77/200 [00:12<00:19,  6.27 it/sec, obj=137]
INFO - 17:20:25: ...  39%|███▉      | 78/200 [00:12<00:19,  6.27 it/sec, obj=137]
INFO - 17:20:25: ...  40%|███▉      | 79/200 [00:12<00:19,  6.27 it/sec, obj=137]
INFO - 17:20:25: ...  40%|████      | 80/200 [00:12<00:19,  6.27 it/sec, obj=137]
INFO - 17:20:25: ...  40%|████      | 81/200 [00:12<00:18,  6.28 it/sec, obj=137]
INFO - 17:20:25: ...  41%|████      | 82/200 [00:13<00:18,  6.28 it/sec, obj=137]
INFO - 17:20:25: ...  42%|████▏     | 83/200 [00:13<00:18,  6.29 it/sec, obj=137]
INFO - 17:20:25: ...  42%|████▏     | 84/200 [00:13<00:18,  6.29 it/sec, obj=137]
INFO - 17:20:26: ...  42%|████▎     | 85/200 [00:13<00:18,  6.28 it/sec, obj=137]
INFO - 17:20:26: ...  43%|████▎     | 86/200 [00:13<00:18,  6.29 it/sec, obj=137]
INFO - 17:20:26: ...  44%|████▎     | 87/200 [00:13<00:17,  6.29 it/sec, obj=137]
INFO - 17:20:26: ...  44%|████▍     | 88/200 [00:13<00:17,  6.30 it/sec, obj=137]
INFO - 17:20:26: ...  44%|████▍     | 89/200 [00:14<00:17,  6.30 it/sec, obj=137]
INFO - 17:20:26: ...  45%|████▌     | 90/200 [00:14<00:17,  6.31 it/sec, obj=137]
INFO - 17:20:27: ...  46%|████▌     | 91/200 [00:14<00:17,  6.30 it/sec, obj=137]
INFO - 17:20:27: ...  46%|████▌     | 92/200 [00:14<00:17,  6.31 it/sec, obj=137]
INFO - 17:20:27: ...  46%|████▋     | 93/200 [00:14<00:16,  6.31 it/sec, obj=137]
INFO - 17:20:27: ...  47%|████▋     | 94/200 [00:14<00:16,  6.31 it/sec, obj=137]
INFO - 17:20:27: ...  48%|████▊     | 95/200 [00:15<00:16,  6.32 it/sec, obj=137]
INFO - 17:20:27: ...  48%|████▊     | 96/200 [00:15<00:16,  6.32 it/sec, obj=137]
INFO - 17:20:27: ...  48%|████▊     | 97/200 [00:15<00:16,  6.31 it/sec, obj=137]
INFO - 17:20:28: ...  49%|████▉     | 98/200 [00:15<00:16,  6.32 it/sec, obj=137]
INFO - 17:20:28: ...  50%|████▉     | 99/200 [00:15<00:15,  6.32 it/sec, obj=137]
INFO - 17:20:28: ...  50%|█████     | 100/200 [00:15<00:15,  6.33 it/sec, obj=137]
INFO - 17:20:28: ...  50%|█████     | 101/200 [00:15<00:15,  6.35 it/sec, obj=137]
INFO - 17:20:28: ...  51%|█████     | 102/200 [00:16<00:15,  6.36 it/sec, obj=137]
INFO - 17:20:28: ...  52%|█████▏    | 103/200 [00:16<00:15,  6.35 it/sec, obj=137]
INFO - 17:20:28: ...  52%|█████▏    | 104/200 [00:16<00:15,  6.36 it/sec, obj=137]
INFO - 17:20:29: ...  52%|█████▎    | 105/200 [00:16<00:14,  6.36 it/sec, obj=137]
INFO - 17:20:29: ...  53%|█████▎    | 106/200 [00:16<00:14,  6.36 it/sec, obj=137]
INFO - 17:20:29: ...  54%|█████▎    | 107/200 [00:16<00:14,  6.36 it/sec, obj=137]
INFO - 17:20:29: ...  54%|█████▍    | 108/200 [00:16<00:14,  6.37 it/sec, obj=137]
INFO - 17:20:29: ...  55%|█████▍    | 109/200 [00:17<00:14,  6.36 it/sec, obj=137]
INFO - 17:20:29: ...  55%|█████▌    | 110/200 [00:17<00:14,  6.36 it/sec, obj=137]
INFO - 17:20:30: ...  56%|█████▌    | 111/200 [00:17<00:13,  6.37 it/sec, obj=137]
INFO - 17:20:30: ...  56%|█████▌    | 112/200 [00:17<00:13,  6.37 it/sec, obj=137]
INFO - 17:20:30: ...  56%|█████▋    | 113/200 [00:17<00:13,  6.37 it/sec, obj=137]
INFO - 17:20:30: ...  57%|█████▋    | 114/200 [00:17<00:13,  6.39 it/sec, obj=137]
INFO - 17:20:30: ...  57%|█████▊    | 115/200 [00:18<00:13,  6.38 it/sec, obj=137]
INFO - 17:20:30: ...  58%|█████▊    | 116/200 [00:18<00:13,  6.39 it/sec, obj=137]
INFO - 17:20:30: ...  58%|█████▊    | 117/200 [00:18<00:12,  6.39 it/sec, obj=137]
INFO - 17:20:31: ...  59%|█████▉    | 118/200 [00:18<00:12,  6.39 it/sec, obj=137]
INFO - 17:20:31: ...  60%|█████▉    | 119/200 [00:18<00:12,  6.39 it/sec, obj=137]
INFO - 17:20:31: ...  60%|██████    | 120/200 [00:18<00:12,  6.40 it/sec, obj=137]
INFO - 17:20:31: ...  60%|██████    | 121/200 [00:18<00:12,  6.39 it/sec, obj=137]
INFO - 17:20:31: ...  61%|██████    | 122/200 [00:19<00:12,  6.40 it/sec, obj=137]
INFO - 17:20:31: ...  62%|██████▏   | 123/200 [00:19<00:12,  6.39 it/sec, obj=137]
INFO - 17:20:31: ...  62%|██████▏   | 124/200 [00:19<00:11,  6.40 it/sec, obj=137]
INFO - 17:20:32: ...  62%|██████▎   | 125/200 [00:19<00:11,  6.40 it/sec, obj=137]
INFO - 17:20:32: ...  63%|██████▎   | 126/200 [00:19<00:11,  6.40 it/sec, obj=137]
INFO - 17:20:32: ...  64%|██████▎   | 127/200 [00:19<00:11,  6.40 it/sec, obj=137]
INFO - 17:20:32: ...  64%|██████▍   | 128/200 [00:19<00:11,  6.41 it/sec, obj=137]
INFO - 17:20:32: ...  64%|██████▍   | 129/200 [00:20<00:11,  6.41 it/sec, obj=137]
INFO - 17:20:32: ...  65%|██████▌   | 130/200 [00:20<00:10,  6.41 it/sec, obj=137]
INFO - 17:20:33: ...  66%|██████▌   | 131/200 [00:20<00:10,  6.41 it/sec, obj=137]
INFO - 17:20:33: ...  66%|██████▌   | 132/200 [00:20<00:10,  6.41 it/sec, obj=137]
INFO - 17:20:33: ...  66%|██████▋   | 133/200 [00:20<00:10,  6.40 it/sec, obj=137]
INFO - 17:20:33: ...  67%|██████▋   | 134/200 [00:20<00:10,  6.41 it/sec, obj=137]
INFO - 17:20:33: ...  68%|██████▊   | 135/200 [00:21<00:10,  6.41 it/sec, obj=137]
INFO - 17:20:33: ...  68%|██████▊   | 136/200 [00:21<00:09,  6.41 it/sec, obj=137]
INFO - 17:20:33: ...  68%|██████▊   | 137/200 [00:21<00:09,  6.41 it/sec, obj=137]
INFO - 17:20:34: ...  69%|██████▉   | 138/200 [00:21<00:09,  6.41 it/sec, obj=137]
INFO - 17:20:34: ...  70%|██████▉   | 139/200 [00:21<00:09,  6.41 it/sec, obj=137]
INFO - 17:20:34: ...  70%|███████   | 140/200 [00:21<00:09,  6.41 it/sec, obj=137]
INFO - 17:20:34: ...  70%|███████   | 141/200 [00:21<00:09,  6.43 it/sec, obj=137]
INFO - 17:20:34: ...  71%|███████   | 142/200 [00:22<00:09,  6.43 it/sec, obj=137]
INFO - 17:20:34: ...  72%|███████▏  | 143/200 [00:22<00:08,  6.43 it/sec, obj=137]
INFO - 17:20:34: ...  72%|███████▏  | 144/200 [00:22<00:08,  6.44 it/sec, obj=137]
INFO - 17:20:35: ...  72%|███████▎  | 145/200 [00:22<00:08,  6.44 it/sec, obj=137]
INFO - 17:20:35: ...  73%|███████▎  | 146/200 [00:22<00:08,  6.44 it/sec, obj=137]
INFO - 17:20:35: ...  74%|███████▎  | 147/200 [00:22<00:08,  6.44 it/sec, obj=137]
INFO - 17:20:35: ...  74%|███████▍  | 148/200 [00:22<00:08,  6.44 it/sec, obj=137]
INFO - 17:20:35: ...  74%|███████▍  | 149/200 [00:23<00:07,  6.45 it/sec, obj=137]
INFO - 17:20:35: ...  75%|███████▌  | 150/200 [00:23<00:07,  6.45 it/sec, obj=137]
INFO - 17:20:36: ...  76%|███████▌  | 151/200 [00:23<00:07,  6.44 it/sec, obj=137]
INFO - 17:20:36: ...  76%|███████▌  | 152/200 [00:23<00:07,  6.44 it/sec, obj=137]
INFO - 17:20:36: ...  76%|███████▋  | 153/200 [00:23<00:07,  6.45 it/sec, obj=137]
INFO - 17:20:36: ...  77%|███████▋  | 154/200 [00:23<00:07,  6.45 it/sec, obj=137]
INFO - 17:20:36: ...  78%|███████▊  | 155/200 [00:23<00:06,  6.46 it/sec, obj=137]
INFO - 17:20:36: ...  78%|███████▊  | 156/200 [00:24<00:06,  6.46 it/sec, obj=137]
INFO - 17:20:36: ...  78%|███████▊  | 157/200 [00:24<00:06,  6.46 it/sec, obj=137]
INFO - 17:20:37: ...  79%|███████▉  | 158/200 [00:24<00:06,  6.46 it/sec, obj=137]
INFO - 17:20:37: ...  80%|███████▉  | 159/200 [00:24<00:06,  6.46 it/sec, obj=137]
INFO - 17:20:37: ...  80%|████████  | 160/200 [00:24<00:06,  6.46 it/sec, obj=137]
INFO - 17:20:37: ...  80%|████████  | 161/200 [00:24<00:06,  6.46 it/sec, obj=137]
INFO - 17:20:37: ...  81%|████████  | 162/200 [00:25<00:05,  6.46 it/sec, obj=137]
INFO - 17:20:37: ...  82%|████████▏ | 163/200 [00:25<00:05,  6.46 it/sec, obj=137]
INFO - 17:20:37: ...  82%|████████▏ | 164/200 [00:25<00:05,  6.46 it/sec, obj=137]
INFO - 17:20:38: ...  82%|████████▎ | 165/200 [00:25<00:05,  6.46 it/sec, obj=137]
INFO - 17:20:38: ...  83%|████████▎ | 166/200 [00:25<00:05,  6.46 it/sec, obj=137]
INFO - 17:20:38: ...  84%|████████▎ | 167/200 [00:25<00:05,  6.46 it/sec, obj=137]
INFO - 17:20:38: ...  84%|████████▍ | 168/200 [00:26<00:04,  6.46 it/sec, obj=137]
INFO - 17:20:38: ...  84%|████████▍ | 169/200 [00:26<00:04,  6.45 it/sec, obj=137]
INFO - 17:20:38: ...  85%|████████▌ | 170/200 [00:26<00:04,  6.46 it/sec, obj=137]
INFO - 17:20:39: ...  86%|████████▌ | 171/200 [00:26<00:04,  6.46 it/sec, obj=137]
INFO - 17:20:39: ...  86%|████████▌ | 172/200 [00:26<00:04,  6.46 it/sec, obj=137]
INFO - 17:20:39: ...  86%|████████▋ | 173/200 [00:26<00:04,  6.46 it/sec, obj=137]
INFO - 17:20:39: ...  87%|████████▋ | 174/200 [00:26<00:04,  6.46 it/sec, obj=137]
INFO - 17:20:39: ...  88%|████████▊ | 175/200 [00:27<00:03,  6.46 it/sec, obj=137]
INFO - 17:20:39: ...  88%|████████▊ | 176/200 [00:27<00:03,  6.46 it/sec, obj=137]
INFO - 17:20:40: ...  88%|████████▊ | 177/200 [00:27<00:03,  6.46 it/sec, obj=137]
INFO - 17:20:40: ...  89%|████████▉ | 178/200 [00:27<00:03,  6.46 it/sec, obj=137]
INFO - 17:20:40: ...  90%|████████▉ | 179/200 [00:27<00:03,  6.46 it/sec, obj=137]
INFO - 17:20:40: ...  90%|█████████ | 180/200 [00:27<00:03,  6.46 it/sec, obj=137]
INFO - 17:20:40: ...  90%|█████████ | 181/200 [00:28<00:02,  6.46 it/sec, obj=137]
INFO - 17:20:40: ...  91%|█████████ | 182/200 [00:28<00:02,  6.46 it/sec, obj=137]
INFO - 17:20:40: ...  92%|█████████▏| 183/200 [00:28<00:02,  6.46 it/sec, obj=137]
INFO - 17:20:41: ...  92%|█████████▏| 184/200 [00:28<00:02,  6.46 it/sec, obj=137]
INFO - 17:20:41: ...  92%|█████████▎| 185/200 [00:28<00:02,  6.46 it/sec, obj=137]
INFO - 17:20:41: ...  93%|█████████▎| 186/200 [00:28<00:02,  6.50 it/sec, obj=Not evaluated]
INFO - 17:20:41: Optimization result:
INFO - 17:20:41:    Optimizer info:
INFO - 17:20:41:       Status: None
INFO - 17:20:41:       Message: Successive iterates of the objective function are closer than ftol_rel or ftol_abs. GEMSEO Stopped the driver
INFO - 17:20:41:       Number of calls to the objective function by the optimizer: 186
INFO - 17:20:41:    Solution:
INFO - 17:20:41:       The solution is feasible.
INFO - 17:20:41:       Objective: 136.56131771172448
INFO - 17:20:41:       Standardized constraints:
INFO - 17:20:41:          volume fraction - 0.3 = -1.0460364907594055e-08
INFO - 17:20:41: *** End MDOScenario execution (time: 0:00:28.668505) ***

{'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 0x7fccd31050d0>


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 29.654 seconds)

Gallery generated by Sphinx-Gallery