# Smart Topology Optimization Using Adaptive Neighborhood Simulated Annealing
## 4 SA in TO  
In TO with SA meta-heuristic, the optimization starts by assigning an initial random solution and the initial temperature. At each step, a new candidate is generated. The new candidate is the new material density and is calculated according to (2). Then, the objective function is evaluated using FEM with the just determined material density. If the new candidate improves the objective function in comparison with the current solution, the new candidate is directly accepted. Otherwise, the Boltzman probability is calculated using (1). If the Boltzman probability is larger than a random number, the new candidate is accepted.  
In both situations, if the new candidate is accepted, the crystallization factor receives negative feedback. It should be noted that the crystallization factor has 1 as the minimum value. In case the new candidate is rejected, the crystallization factor receives positive feedback. The crystallization factor has a maximum value, usually equal to 20 [38; 39]. This maximum crystallization factor value ensures a minimum standard deviation value for the probability density distribution. For each temperature, the process of new candidate generation and objective function evaluation is repeated for a predefined number of iterations before going to the next temperature. The SA must reach the thermal equilibrium in the current temperature before going to the next temperature. The thermal equilibrium is reached by evaluating the objective function \(m\) times or accepting new candidates \(m/2\) times. The value of \(m\) must be defined for each TO problem, is usually larger than 40 times the number of variables. A larger \(m\) increases the design domain exploration. On the other hand, very large \(m\) increases the computational cost, and perhaps less exploration is required. The value of \(m\) for each TO must be determined based on the number of elements (variables) and some trial runs. After reaching the thermal equilibrium, the temperature decreases by cooling factor \(alpha\). The cooling factor is another parameter to be determined, and a value between 0.8 and 0.95 is normally used. The SA converges when the frozen state is reached, this happens when no new candidate is accepted for a specific temperature.  
Since this optimization method works based on a probabilistic search, the results come with some discontinuity and gray areas. To reduce discontinuity in borders, a density filter is applied for each element. According to this filter, the density of each element is calculated by:  
\[x_{filter}=\frac{\sum_{j=1}^{N}w(x_{j})x_{j}}{\sum_{j=1}^{N}w(x_{j})} \tag{5}\]  
based on the weighted density of neighboring elements, where \(w(x_{j})\) is the weighting function and represents the distance of neighboring elements subtracted from the filter radius. At higher temperatures, most of the new candidates are accepted as the SA stays in an exploration phase. It is not reasonable to apply the density filter in this situation. The density filter will improve the convergence at lower temperatures, where the SA is already in the refinement phase. The transition from the exploration phase to the refinement phase is not clear. For criteria to start applying the density filter, it considered the situation where 80% or more of rejections happens to be in this transition. After reaching the convergence, a post-processing happens and the density filter is applied again to smoothen the borders and also to turn gray areas into black and white elements.