# Neural networks for topology optimization

## Abstract

In this research, we propose a deep learning based approach for speeding up the topology optimization methods. The problem we seek to solve is the layout problem. The main novelty of this work is to state the problem as an image segmentation task. We leverage the power of deep learning methods as the efficient pixel-wise image labeling technique to perform the topology optimization. We introduce convolutional encoder-decoder architecture and the overall approach of solving the above-described problem with high performance. The conducted experiments demonstrate the significant acceleration of the optimization process. The proposed approach has excellent generalization properties. We demonstrate the ability of the application of the proposed model to other problems. The successful results, as well as the drawbacks of the current method, are discussed.

## 1Introduction

Topology optimization solves the layout problem with the following formulation: how to distribute the material inside a design domain such that the obtained structure has optimal properties and satisfies the prescribed constraints? The most challenging formulation of the problem requires the solution to be binary i.e. it should state whether there is a material or a void for each of the parts of the design domain. One of the common examples of such an optimization is the minimization of elastic strain energy of a body for a given total weight and boundary conditions. Initiated by the demands of automotive and aerospace industry in the century, topology optimization has spread its application to a wide range of other disciplines: e.g. fluids, acoustics, electromagnetics, optics and combinations thereof [?].

All modern approaches for topology optimization used in commercial and academic software are based on finite element methods. SIMP (Simplified Isotropic Material with Penalization), which was introduced in 1989 [?], is currently a widely spread simple and efficient technique. It proposes to use penalization of the intermediate values of density of the material, which improves the convergence of the solution to binary. Topology optimization problem could be solved by using BESO (Bi-directional evolutionary structural optimization) [?] as an alternative. The key idea of this method is to remove the material where the stress is the lowest and add material where the stress is higher. The more detailed review is discussed in Section 2.

For all of the above-described methods, the process of optimization could be roughly divided into two stages: general redistribution of the material and the refinement. During the first one, the material layout varies a lot from iteration to iteration. While during the second stage the material distribution converges to the final result. The global structure remains unchanged and only local alteration could be observed.

In this paper, we propose a deep learning based approach for speeding up the most time-consuming part of a traditional topology optimization methods. The main novelty of this work is to state the problem as an image segmentation task. We leverage the power of deep learning methods as an efficient pixel-wise image labeling technique to accelerate modern topology optimization solvers. The key features of our approach are the following:

acceleration of optimization process;

excellent generalization properties;

absolutely scalable techniques;

## 2Topology Optimization Problem

Current research is devoted to topology optimization of mechanical structures. Consider a design domain , filled with a linear isotropic elastic material and discretized with square finite elements. The material distribution is described by the binary density variable that represents either absence (0) or presence (1) of the material at each point of the design domain. Therefore, the problem, that we seek to solve, can be written in mathematical form as:

where is a compliance, is the element displacement vector, is the element stiffness matrix for an element with unit Young’s modulus, and are the global displacement and force vectors, respectively and is the global stiffness matrix. and are the material volume and design domain volume, respectively. is the prescribed volume fraction.

The discrete nature of the problem makes it difficult to solve. Therefore, the last constraint in (Equation 1) is replaced with the following one: . The most common method for topology optimization problem with continuous design variables is so-called SIMP or power-law approach [?]. This is a gradient-based iterative method with the penalization of non-binary solutions, which is achieved by choosing Youngs modulus of a simple but very efficient form:

The exact implementation of SIMP algorithm is out of the scope of the current paper. The updating schemes, as well as different heuristics, can be found in excellent papers [?]. The topology optimization code in Matlab is described in details in [?] and the Python implementation of SIMP algorithm is represented in [?].

Standard half MBB-Beam problem is used to illustrate the process of topology optimization. The design domain, constraints, and loads are represented in Figure 1. The optimization of this problem is demonstrated in Figure ?. During the initial iterations, the general redistribution of the material inside of the design domain is performed. The rest of the optimization process includes the filtering of the pixels: the densities with intermediate values converge to binary values and the silhouette of the obtained structure remains almost unchanged.

## 3Learning Topology Optimization

As it was illustrated in Section 2, it is enough for the solver to perform a few number of iterations to obtain the preliminary view of a structure. The fraction of non-binary densities could be close to 1, however, the global layout pattern is close to the final one. The obtained image could be interpreted as a blurred image of a final structure, or an image distorted by other factors. The thing is that there are just two types of objects on this image: the material and the void. The image , obtained as a result of topology optimization does not contain intermediate values and, therefore, could be interpreted as the mask of image . According to this notation, starting from iteration the process of optimization mimics the process of image segmentation for two classes or foreground-background segmentation.

We propose the following pipeline for topology optimization: use SIMP method to perform the initial iterations and get the distribution with non-binary densities; use the neural network to perform the segmentation of the obtained image and converge the distribution to solution.

### 3.1Architecture

Here we introduce the ** Neural Network for Topology Optimization** — deep fully-convolutional neural network aimed to perform the convergence of densities during the topology optimization process. The input of the model is two grayscale images (or a two-channel image). The first one is the density distribution inside of the design domain which was obtained after the last performed iteration of topology optimization solver. The second input is the last performed update (gradient) of the densities , i.e. the difference between the densities after the -th iteration and -th iteration. The output of the proposed model is a grayscale image of the same resolution as an input, which represents the predicted final structure. The architecture of our model mimics the common for the image segmentation hourglass shape. The proposed model has an encoder network and a corresponding decoder network, followed by a final pixel-wise classification layer. The architecture is illustrated in Figure 2.

The encoder network consists of 6 convolutional layers. Each layer has kernels of size and is followed by ReLU nonlinearity. The first two layers have 16 convolutional kernels. This block is followed by the pooling of the maximal element from the window of size . The next two layers have 32 kernels and are also followed by MaxPooling layer. The last block consists of 2 layers with 64 kernels each.

The decoder network copies the architecture of the encoder part and reverses it. The MaxPooling layers are replaced with Upsampling layers followed by the concatenation with features from the corresponding low-level layer as it is performed in U-Net [?]. The pooling operation introduces the invariance of the subsequent network to small translations of the input. The concatenation of features from different layers allows one to benefit from the use of both the raw low-level representation and significantly encoded parametrization from the higher levels. The decoder is followed by the Convolutional layer with 1 kernel and sigmoid activation function. We included 2 Dropout layers [?] as the regularization for our network.

The width and height of the input image could vary, however, they must be divisible by 4 in order to guarantee the coherence of the shapes of tensors in the computational graph. The proposed neural network has just 192,113 parameters.

### 3.2Dataset

To train the above-described model, we need example solutions to the System Equation 1. The collection of a large dataset from the real-life examples is difficult or even impossible. Therefore, we use synthetic data generated by using Topy [?] — an open source solver for 2D and 3D topology optimization, based on SIMP approach.

To generate the dataset we sampled the pseudo-random problem formulations and performed 100 iterations of standard SIMP method. Each problem is defined by the constraints and the loads. The strategy of sampling is the following:

The number of nodes with fixed and translations and the number of loads is sampled from the Poisson distribution:

The nodes for each of the above-described constraints are sampled from the distribution defined on the grid. The probability of choosing the boundary node is 100 times higher than that for an inner node.

The load values are chosen as .

The volume fraction is sampled from the Normal distribution

The obtained dataset^{1}

### 3.3Training

We used dataset, described in Section 3.2, to train our model. During the training process we “stopped” SIMP solver after iterations and used the obtained design variables as an input for our model. The input images were augmented with transformations from group D4: horizontal and vertical flips and rotation by 90 degrees. was sampled from some certain distribution . Poisson distribution and discrete uniform distribution are of interest to us. For training the network we used the objective function of the following form:

where the confidence loss is a binary cross-entropy:

where is the resolution of the image. The second summand in Equation (Equation 3) represents the volume fraction constraint:

We used ADAM [?] optimizer with default parameters. We halved the learning rate once during the training process. All code is written in Python^{2}

## 4Results

The goal of our experiments is to demonstrate that the proposed model and the overall pipeline are useful for solving topology optimization problems. We compare the performance of our approach with standard SIMP solver [?] in terms of the accuracy of the obtained structure and the average time consumption.

We report two metrics from common image segmentation evaluation: Binary Accuracy and Intersection over Union (IoU). Let be the total number of pixels of class . The is a total number of pixels of class predicted to belong to class . Therefore:

We examine 4 neural networks with the same architecture but trained with different policies. The number of iterations after which we “stopped” SIMP algorithm was sampled from different distributions. We trained one neural network by choosing discrete uniform distribution and another three models were trained with Poisson distribution with .

### 4.1Accuracy and performance

We conducted several experiments to illustrate the results of the application of the proposed pipeline and the exact model to mechanical problems. Figure 3 demonstrates that our neural network restores the final structure while being used even after 5 iterations. The output of the model is close to that of SIMP algorithm. The overall topology of the structure is the same. Furthermore, the time consumption of the proposed method, in this case, is almost 20 times smaller.

Neural networks trained with different policies produce close results: models preserve the final structure up to some rare pixel-wise changes. However, the accuracy of these models depends on the number of the initial iterations performed by SIMP algorithm. Tables ?, ? summarize the results obtained in the series of experiments. The trained models demonstrate the sufficiently more accurate results comparing to the thresholding applied after the same number of iterations of SIMP method. Some models benefit when they are applied after 5-10 iterations, while others demonstrate better result in the middle or at the end of the process. The proposed pipeline could significantly accelerate the overall algorithm with minimal reduction in accuracy, especially when CNN is used at the beginning of the optimization process.

The neural network which used discrete uniform distribution during the training process does not demonstrate the highest binary accuracy and IoU comparing to other models till the latest iterations. However, this model allows one to outperform the SIMP algorithm with thresholding throughout the optimization process.

Method | 5 | 10 | 15 | 20 | 30 | 40 | 50 | 60 | 80 |

Thresholding | 92.9 | 95.4 | 96.5 | 97.1 | 97.7 | 98.1 | 98.4 | 98.6 | 98.9 |

CNN | 95.8 |
97.3 | 97.7 | 97.9 | 98.2 | 98.4 | 98.5 | 98.6 | 98.7 |

CNN | 95.4 | 97.6 |
98.1 |
98.4 | 98.7 | 98.9 | 99.0 | 99.0 | 99.0 |

CNN | 92.7 | 96.3 | 97.8 | 98.5 |
99.0 |
99.2 |
99.4 |
99.5 |
99.6 |

CNN | 94.7 | 96.8 | 97.7 | 98.2 | 98.7 | 99.0 | 99.3 | 99.4 | 99.6 |

Method | 5 | 10 | 15 | 20 | 30 | 40 | 50 | 60 | 80 |

Thresholding | 86.8 | 91.2 | 93.3 | 94.3 | 95.6 | 96.3 | 96.8 | 97.3 | 97.9 |

CNN | 92.0 |
94.7 | 95.4 | 96.0 | 96.5 | 96.9 | 97.1 | 97.3 | 97.4 |

CNN | 91.1 | 95.3 |
96.4 |
96.9 | 97.4 | 97.8 | 98.0 | 98.0 | 98.1 |

CNN | 86.4 | 92.9 | 95.7 | 97.0 |
98.1 |
98.5 |
98.8 |
99.0 |
99.2 |

CNN | 90.0 | 93.9 | 95.5 | 96.4 | 97.5 | 98.1 | 98.6 | 98.8 | 99.2 |

### 4.2Transferability

This research is dedicated to the application of neural networks to the topology optimization of minimal compliance problems. Nevertheless, the proposed model does not rely on any prior knowledge of the nature of the problem. Despite the fact that we used mechanical dataset during the training, other types of problems from topology optimization framework could be solved by using the proposed pipeline. To examine the generalization properties of our model, we generated the small dataset of heat conduction problems defined on regular grid. The exact solution and the intermediate densities for the problems were obtained in absolutely the same way as it was described in Section 3.

The conducted experiments are summarized in Table ?, ?. During the initial part of the optimization process, the results of the pre-trained CNNs are more accurate than this of thresholding. Our model approximates the mapping to the final structure precisely when the training dataset and the validation dataset are from the same distribution. However, it mimics updates of SIMP method during the initial iterations even when CNN is applied to another dataset. Therefore, this pipeline could be useful for the fast prediction of the rough structure in various topology optimization problems.

The neural network described in Section 3 is fully-convolutional, i.e. it consists of Convolutional, Pooling, Upsampling and Dropout layers. The architecture itself does not have any constraints on the size of the input data. In this experiment, we checked the scalable properties of our method. The model we examined had been trained on the original dataset with square images of size . Figure 4 visualizes the result of the application of CNN to the problems defined on grids with different resolution. Here we can see that changes in the aspect ratio and reasonable changes in the resolution of the input data do not affect the accuracy of the model. Pre-trained neural network successfully reconstructs the final structure for a given problem. Significant changes of the size of the input data require additional training of the model because the typical size of a common patterns changes with the increase of the resolution of an image. Nevertheless, demonstrated cases did not require one to tune neural network and allowed to transfer model from one resolution to another.

Method | 5 | 10 | 15 | 20 | 30 | 40 | 50 | 60 | 80 |

Thresholding | 97.5 | 98.4 | 98.8 | 99.1 | 99.4 | 99.6 |
99.7 |
99.8 |
99.9 |

CNN | 98.1 | 98.7 | 99.0 | 99.2 | 99.4 | 99.5 | 99.6 | 99.7 | 99.7 |

CNN | 98.1 |
98.8 | 99.0 | 99.2 | 99.4 | 99.5 | 99.6 | 99.7 | 99.8 |

CNN | 97.3 | 99.0 |
99.2 |
99.4 |
99.5 |
99.6 | 99.7 | 99.7 | 99.8 |

CNN | 97.8 | 98.8 | 99.1 | 99.3 | 99.5 | 99.6 | 99.7 | 99.7 | 99.8 |

Method | 5 | 10 | 15 | 20 | 30 | 40 | 50 | 60 | 80 |

Thresholding | 95.1 | 96.8 | 97.6 | 98.1 | 98.8 | 99.2 |
99.4 |
99.6 |
99.9 |

CNN | 96.2 | 97.5 | 98.0 | 98.4 | 98.8 | 99.0 | 99.2 | 99.3 | 99.5 |

CNN | 96.3 |
97.6 | 98.1 | 98.4 | 98.9 | 99.1 | 99.3 | 99.4 | 99.5 |

CNN | 94.8 | 98.0 |
98.5 |
98.7 |
99.0 |
99.2 | 99.3 | 99.4 | 99.5 |

CNN | 95.7 | 97.7 | 98.2 | 98.6 | 98.9 | 99.2 | 99.3 | 99.4 | 99.6 |

## 5Related work

The current research is supposed to be the first one which utilizes deep learning approach for the topology optimization problem. It is inspired by the recent successful application of deep learning to problems in computational physics. Greff at al. [?] used the fully-connected neural network as a mapping function from the nano-material configuration and the input voltage to the output current. The adaptation of restricted Boltzmann machine for solving the Quantum Many-Body Problem was demonstrated in paper [?]. Mills et al. [?] used the machinery of deep learning to learn the mapping between potential and energy, bypassing the need to numerically solve the Schrödinger equation and the need for computing wave functions. Tompson et al. [?] and Kiwon et al. [?] accelerated the process of modeling of liquids by the application of neural networks. The paper [?] demonstrates how a deep neural network trained on quantum mechanical density functional theory calculations can learn an accurate and transferable potential for organic molecules. The cutting-edge research [?] shows how generative adversarial networks could be used for simulating 3D high-energy particle showers in multi-layer electromagnetic calorimeters.

## 6Conclusion

In this paper, we proposed a neural network as an effective tool for the acceleration of topology optimization process. Out model learned the mapping from the intermediate result of the iterative method to the final structure of the design domain. It allowed us to stop SIMP method earlier and significantly decrease the total time consumption.

We demonstrated that the model trained on the dataset of minimal compliance problems could produce the rough approximation of the solution for other types of topology optimization problems. Various experiments showed that the proposed neural network transfers successfully from the dataset with a small resolution to the problems defined on the grids with better resolution.

## ADataset

## BResults

### Footnotes

- The dataset and the related code is available at https://github.com/ISosnovik/top
- The implementation is available at https://github.com/ISosnovik/nn4topopt