 Research article
 Open Access
 Published:
A firefly algorithm based hybrid method for structural topology optimization
Advanced Modeling and Simulation in Engineering Sciences volume 7, Article number: 44 (2020)
Abstract
In this paper, a firefly algorithm based hybrid algorithm through retaining global convergence of firefly algorithm and ability to generate connected topologies of optimality criteria (OC) method is proposed as an alternative method to solve stressbased topology optimization problems. The lower and upper limit of design variables (0 and 1) were used to find initial material distribution to initialize the firefly algorithm based section of the hybrid algorithm. Input parameters, the number of fireflies, and the number of function evaluations were determined before the implementation of the firefly algorithm to solve formulated problems. Since the direct application of the firefly algorithm cannot generate connected topologies, outputs from the firefly algorithm were used as an initial input material distribution for the OC method. The proposed method was validated using twodimensional benchmark problems and the results were compared with results using the OC method. Weight percentage reduction, maximum stressinduced, optimal material distribution, and compliance were used to compare results. Results from the proposed method showed that the proposed method can generate connected topologies which are free from the interference of endusers, and only depend on boundary conditions or design variables. From the results, the objective function (weight of the design domain) can be further reduced in the range of 5 to 15% compared to the OC method.
Introduction
Continuum structural topology optimization as a generalized shape optimization problem that has received extensive attention and considerable progress over the past few years. Different methods have been developed based on this concept. One of the most established methods is a homogenization method where a structure is represented by micro scale void materials. Evaluation and orientation of optimal microstructures is one of the major challenges in homogenization. Another approach, named the SIMP method, originally proposed by Bendsoe [1], has gained a general acceptance due to its conceptual simplicity and computational efficiency. However, the existence of transition elements and local convergence has been a major challenge in SIMP method. Filtering techniques and parameter constraints have been used to address these challenges. Evolutionary Structural Topology Optimization/Bidirectional Structural Topology Optimization (ESO/BESO) methods are other techniques proposed to solve structural topology optimization [2,3,4]. Due to truss like optimal layouts it generates, ESObased methods have been recommended to solve problems having pinjointed connections. The other variation is level set method which is based on the optimization of implicit interfaces. The boundaries move according to the stress on them. This method is very sensitive to the initial guess and easily caught in local minima [5]. For real world problems, globally optimum solutions are preferable and methods which can generate these solutions are getting more attention for solving optimization problems. Metaheuristic algorithmbased methods are also attractive when solving structural topology optimization problems [5,6,7,8,9,10,11,12,13,14].
Firefly algorithm (FA) is a naturebased optimization algorithm developed by XinShe Yang in late 2007 [15, 16]. It is a stochastic, metaheuristic algorithm which has been implemented for solving different optimization problems. FA is inspired by the flashing behavior of fireflies, whose lighting behavior attracts mating partners and send warnings of a potential predators. This algorithm has been used to solve different numerical problems [17,18,19,20,21] and shows an outstanding performance in terms of convergence and efficiency over the other natureinspired algorithms, including genetic and particleswarm optimization algorithms [19, 22,23,24]. FA and its variants have been applied for different optimization and engineering problems as shown in Fig. 1.
Principle of firefly algorithm
The FA idealizes several aspects of fireflies in nature. For example, a real firefly flashes in discrete patterns, whereas the modeled fireflies are always glowing. Then, three rules are used to model fireflies behavior and govern the algorithm [15]:

1.
The fireflies are unisex which leads fireflies to be attracted to another firefly irrespective of their sex.

2.
Attractiveness is proportional to the brightness, where both decrease as the distance between two fireflies increase. For any two fireflies within the domain considered, less bright fireflies are attracted to brighter ones. If all fireflies have equal brightness, the fireflies will move randomly.

3.
The brightness of a firefly is proportional to the value of the function being maximized and can be considered as the value of the objective function.
Based on these three rules, the basic FA can be summarized by a pseudo code as (Fig. 2):

Step 1. (Generating initial population of solution)
The FA generates a randomly initial population of solutions, \(x_{ik}\).
$$ {\text{where }}i = 1,2, \ldots SP{\text{ and }}k = 1,2,3 \ldots D. $$$$ {\varvec{x}}_{{{\varvec{ik}}}} = {\varvec{l}}_{{\varvec{k}}} + \left( {{\varvec{u}}_{{\varvec{b}}}  {\varvec{l}}_{{\varvec{b}}} } \right)*{\varvec{rand}}\left( {{\varvec{size}}\left( {{\varvec{l}}_{{\varvec{b}}} } \right)} \right), $$(1)where SP is the population size, D is a dimension of the problem, \(u_{b} { }\) and \(l_{b}\) are the lower and upper limit of the parameter or design variable \(x_{ik} .\) After the generation of the initial population, the objective function values for all solutions \(x_{i}\) will be calculated and variable \(t\), which is the number of iteration, is set to 1.

Step 2. (Calculate the new population)
Each solution of the new population is created from the appropriate solution \(x_{i}\) as follows:
For each solution \({ }x_{i}\), the algorithm examines every solution \(x_{j} ,{ }j = 1,2,3, \ldots i\), iteratively, starting from \(j = 1\). If solution \(x_{j}\) has a higher objective function value than \(x_{i}\) (\(x_{j}\) is brighter than \(x_{i}\)), the parameter values \(x_{ik} ,k = 1,2,3, \ldots ,D\) are updated by:
where the first, second and third terms are the Cartesian distances, due to the attraction and randomization term. In the second term, \({ }\beta\) is a monotonically decreasing exponential function which describes a firefly’s attractiveness:
where \(r_{ij}\) is the distance between firefly \(i\) and firefly \( j\), while \(\beta_{0} { }\) and \(\gamma { }\) are predetermined algorithm parameters, maximum attractiveness value, and absorption coefficient, respectively. Distance \(r_{ij}\) is obtained by the Cartesian distance as:
Control parameter \(\beta_{0}\) describes attractiveness when two fireflies are found at the same point of search space, i.e. at \(r = 0{ }\) the variation of attractiveness with increasing distance from a communicated firefly is determined by the control parameter \(\gamma\).
\(\alpha \in \left[ {0,1} \right]\) in the third term in Eq. 2 is a randomization parameter,\({ }S_{k}\) and \(rand_{k}\) are scaling parameter and random number uniformly distributed between 0 and 1, respectively. The scaling parameters \({ }S_{k}\) are calculated by:
In addition, whenever the values of the solution \({ }{\varvec{x}}_{{{\varvec{ik}}}}\) are changed, the FA controls the boundary conditions of created solutions and memorizes the new objective function value instead of the old one. The boundary constrainthandling mechanism used in the FA is given by:
The last solution obtained by Eq. 6 will be taken as the final solution of the new population which will be transformed the next iteration of the FA.

Step 3. (Reduce the randomization parameter)
The solution quality can be enhanced by reducing the randomization parameter \(\alpha\) with a geometric progression reduction scheme which can be expressed as:
where MCN is the maximum cycle number, \({ }t\) is the current iteration number, \(\theta \in { }\left( {0, 1} \right]{ } \) is the randomness reduction constant. In most applications, we can use \( \theta = { }0.95{ } \sim { }0.99{ }\) and \({\upalpha }_{0} = 1\) [15].

Step 4. (Record the best solution)
Ranks the fireflies by their light intensity/objectives and memorizes the best solution so far \({\varvec{x}}_{{{\varvec{best}}}}\) and increase the variable \({\varvec{t}}\) by one.

Step 5. (Check the termination criterion)
If \({\varvec{t}}\) is equal to the maximum number of iterations then the algorithm is finished, else go to step 2.
In the simplest case for the maximum optimization problem, the brightness I of a firefly at a location x can be chosen I(x) \(\propto { }\) f(x) However, the attractiveness \({\varvec{\beta}}\) will be judged by other fireflies. Thus, it varies with the distance \(r_{ij}\) between firefly \(i\) and \( {\text{j}}\). The distance between any two fireflies \(i\) and \(j\) at \(x_{i}\) and \(x_{j}\) respectively is the Cartesian distance
Thus, the light intensity decreases with the distance from its source and the light is also absorbed in the media. The light intensity \(I\left( \gamma \right)\) varies according to the inverse square law:
where \(I_{s}\) is the intensity at the source. For a given medium with a fixed light absorption coefficient \(\gamma\), the light intensity \(I\) varies with the distance \(r\) which can be expressed as:
where \(I_{0}\) is the original light intensity at zero distance \( r \approx 0\). Since a firefly’s attractiveness is proportional to the light intensity seen by the adjacent fireflies, which can be defined as:
where \(\beta_{0}\) is the attractiveness at \(r = 0.\) The movement of a firefly \(i\) to another, more attractive (i.e. brighter) firefly \(j\) is determined as:
where the first term is the Cartesian distance between two fireflies, and the second term is due to the attraction. The third term describes the randomization, with \(\alpha\) being the randomization parameter having a value of [0, 1] and \(\in_{i}\) is a vector of random numbers drawn from a Gaussian distribution or uniform distribution.
Optimization process
Problem formulation
Based on von Mises stress failure theory a ductile material will fail when the von Mises stress induced in the material is higher than the yield strength of the material. Taking this failure into account, generalized stress constrained topology optimization problem for two and threedimensional mass minimization can be defined as:
where \({\varvec{V}}\) is a volume (objective function), \({ }{\varvec{N}}\) the total number of elements which defines the design domain,\({ }{\varvec{e}}\) elements within the design domain, \({\varvec{ve}}\) is volume of each element in the design domain, \({\varvec{\sigma}}_{{{\varvec{vm}}}} { }\) von Mises stress, \({\varvec{\sigma}}_{{{\varvec{yield}}}}\) is maximum (yield stress). \({\varvec{K}}{ }\) is a global stiffness matrix, \({\varvec{U}}\) is a global displacement vector, \({\varvec{F}}\) a global force vector, \({\varvec{x}}_{{\varvec{e}}}\) is relative density/design variable, \({\varvec{x}}_{{{\varvec{min}}}}\) is the minimum relative density to control the singularity phenomenon associated with the design variable.
Finite element analysis
For 2D problems, all the design domains are assumed to be rectangular and discretized by a square finite element as shown in Fig. 3. Element numbering and the degree of freedoms for each node are also defined in the Figure.
Stress and strain analysis
A twodimensional stress state consists of three different stress components as shown in Fig. 4, which are the normal stresses \({\varvec{\sigma}}_{{{\varvec{yy}}}}\) and \({\varvec{\sigma}}_{{{\varvec{xx}}}}\) and the shear stress \( {\varvec{\sigma}}_{{{\varvec{xy}}}} = {\varvec{\sigma}}_{{{\varvec{yx}}}}\).
Like the stress state, there are three strain components which are directly proportional to the displacements in the respective direction can be expressed as:
where \(\varepsilon_{xx,} \varepsilon_{xx} \) and \(\varepsilon_{xy}\) are the strains in \(X ,Y\) and \(XY\) plane, respectively. \(u\) and \(v\) are the displacement in \(X\) and \(Y\) direction, respectively. The stressinduced in the material can be related with the strain as:
where \(D\) is the constitutive matrix, which can be related to the Young’s modulus and Poisson’s ratio as:
where \(E\) is Young’s modulus which is a measure of the ratio of axial stress to axial strain in uniaxial tension. Poisson’s ratio, respectively. \(v \) is the Poisson’s ratio which is the negative ratio of lateral strain to axial strain, these values range between 0.25 and 0.35 [25].
Shape function
Shape functions are used to interpolate the displacement field within the design domain. For a linear displacement, the shape functions in a local coordinate, as shown in Fig. 5, can be expressed as shown in Eq. 17. To calculate the stressinduced and elemental stiffness matrix the displacement is approximated using shape functions as:
where
Strain–displacement matrix
The displacement vector can be approximated in terms of the shape functions as:
where \(\left\{ {\varvec{d}} \right\}\) is the nodal displacement vector, \(\left\{ {\varvec{u}} \right\}\) is the displacement vector and \(\left[ {\varvec{N}} \right]\) is a vector of shape function. For computing the stress, strain, and stiffness the matrix the strain–displacement matrix having a size of 3 × 8.
The term \(\left[ \varvec\partial \right]\left\{ {\varvec{N}} \right\}\) is described as a strain displacement matrix which can be expressed as:
Solving formulated problems
The proposed hybrid method has two stages for solving the proposed problem: the first stage will generate the values for design variables using the FA algorithm, and generated values of the design variables will be used as input for the second stage, OC method. The design variables at the second stage of the proposed method are updated using the following scheme:
where \({\varvec{m}}\) is a positive limit, which usually takes a value of 0.2, \( {\varvec{\eta}}\) is a numerical damping coefficient with a value of 0.5 [26,27,28], \( {\varvec{\beta}}\) which will be dependent on the type of problems defined below:
where \({{\varvec{\uplambda}}}\) is a Lagrangian multiplier. Here, the value is found from a bisectioning algorithm. The sensitivity analysis for problems defined in Eq. 21 can be calculated as:
In this paper, the stress is calculated at the centroid of an element [28,29,30]. To relate the macro and micro stress levels, local stress interpolation scheme proposed by Duysinx and Sigmund [31] is used as:
where \(\sigma {\text{(x)}}\) is local stress at a material point, \({\varvec{D}}_{{\varvec{e}}} \left( {\varvec{x}} \right)\) is macroscopic elastic tensor which can be related to the constitutive elasticity tensor \({\varvec{D}}_{0}\) by a powerlaw approach as shown in Eq. 24, \(\overline{\user2{\varepsilon }}\left( {\varvec{x}} \right)\) is the average strain of a material point which can be expressed in terms of strain displacement matrix \( {\varvec{B}}_{{\varvec{e}}}\) and elemental displacement vector \({\varvec{u}}_{{\varvec{e}}}\). The exponent \({\varvec{q}} > 1\) is a constant to preserve physical consistency in the material model.
Substituting Eqs. 24 and 25 into Eq. 23, the stress at any material point with the given design domain can be expressed as:
From Eq. 26 the partial derivative of the constraint function in Eq. 22 can be expressed as:
From equilibrium equation we have, \({\varvec{KU}} = {\varvec{F}}\), differentiating both sides of the equilibrium equation with respect to the design variable yields:
Substituting Eq. 20 for partial derivative of the displacement vector in Eq. 27 yields the sensitivity analysis for stress constraint defined in Eq. 22 as:
Therefore, the sensitivity analysis for stressbased topology optimization becomes:
Once the sensitivity analysis for both formulation was completed, a Matlab code is written for the stress based topology optimization and an existing Matlab code was used for compliance [28, 29]
Determination input parameters
Before using FA to solve stressed based topology optimization problems, input parameters must first be determined. These parameters include the number of fireflies, the maximum number of iterations, the randomness parameter \({\varvec{\alpha}}\) and initial brightness value \({\varvec{\beta}}\). Among these parameters, the effect of the number of fireflies and the number of iterations were studied, and the best combination of these parameters was selected for further implementation of the algorithm. The following sections will discuss the determination of these parameters (number of iteration and number of fireflies). The value of other parameters was directly adopted from other applications of FA [17, 19].
Number of fireflies
To assess the effect of a number of function evaluations on the efficiency of FA, a range between [50 and 500] function evaluations was considered. A design domain was formulated and solved using a FA for the range of function evaluations for 100 test runs. Then, the variation of best, meaning, and worst values of the objective function with function evaluation was studied through plotting these values with the number of fireflies, as shown in Fig. 6. From the figure, the objective function is minimum when the number of function evaluations is 200, and the number of fireflies is 30 as shown in Fig. 6a but the variation of the objective is not stable with the variation of the number of fireflies as shown in Fig. 6b, c. From the figure, it can be noticed that variation of the objective function is less sensitive for the number of fireflies greater than 35. Range of fireflies > 35 and function evaluations > 250 is the optimum range for best values of the objective function.
Number of iterations
An optimization problem based on Eq. 13 was formulated and solved using FA for the range of function evaluations for 100 test runs. Then, the variation of best, mean, and worst values of the objective function with the variation of the number of fireflies was studied through plotting these values of the objective function with the number of fireflies, as shown in Fig. 7. From the figure, it can be noticed that the variation of the objective function is less sensitive to the number of function evaluations when > 350. For function evaluations > 350, the range of the number of fireflies > 30 is the range for best values of the objective function.
Since the direct implementation of the FA yields a topology full of transition elements and highly affected by the checkerboard effect as shown in Fig. 8. A hybrid method was proposed to overcome this issue as described in Fig. 9. One of the challenges in the currently available methods is the dependency of initial material distributions [5]. From the initial topology generated from the firefly algorithm, we can have the best values for the design variables which leads to the best values of the objective function. Even if it generates values of design variables, generated topologies are full of disconnected elements which are unwanted from an engineering perspective. To address this issue in direct implementation of FA and dependence of OC method on initial material, the outputs of the design variable values using FA as an input for the OC method. From the convergence history shown in Fig. 10, the proposed method can generate connected optimal plots.
Result and discussion
The proposed method was used to solve benchmark problems under different discretization size and the results are compared with solutions using an OC method.
Numerical results
Cantilever beam
The first case studies considered was a cantilever beam under loading and boundary conditions defined in Fig. 11.
The first study was solved using the proposed method with a design domain and loading conditions defined in Fig. 11a and the generated topologies for different discretization size of the design domain are presented in Fig. 12.
The generated topologies for the Cantilever beam under loading and boundary conditions in Fig. 11b, c are presented in Figs. 13 and 14, respectively.
Lshape beam
The other benchmark problem considered to be solved using the proposed method is an Lshape beam under different boundary and loading conditions. Generated topologies for the design domains using the proposed method are shown in Tables 1 and 2, respectively.
Simply supported
The other benchmark problem used for validation of the proposed method was a simply supported beam under the loading and boundary condition defined in Fig. 15 and generated topologies are shown in Fig. 16 under different discretization sizes.
Comparison of results
The optimization results using the proposed method were compared with results from OCmethod topologies. Table 3 shows the composition of generated optimal topologies using the proposed method and optimal topologies using OC based method for different benchmark problems. Optimal topologies using the proposed method have less weight reduction percentage than the topologies generated using the OC method as shown in Table 4. Even if the weight reduction percentage is less for respective design domains, generated topologies using the proposed method are more complex than the OC method.
Conclusion
This paper presented a firefly algorithm (FA)based hybrid method for stressbased topology optimization of 2D structures. The advantages of generating globally convergent solutions from FA, and the ability to generate connected topologies of the OC method, are crucial elements in the proposed method. In the proposed method, initial parameters for the SIMP method were determined using FA and also used as an input from the OCbased method, then optimal topologies were generated. The proposed method was validated using different benchmark problems to address global convergence and dependence of optimal material distribution on initial values of design variables of the OC method. Generated topologies and simulation results show the objective function, which is the weight of the design domain, can be further minimized in the range of 5–15%.
References
Bendsoe MP. Optimal shape design as a material distribution problem. Struct Optim. 1989;1:193–202.
Xie YM, Steven GP. Evolutionary structural optimization. London: Springer; 1997.
Querin OM, Steven GP, Xie YM. Evolutionary structural optimisation (ESO) using a bidirectional algorithm. Eng Comput. 1998;15(8):1031–48.
Huang X, Xie YM. Evolutionary topology optimization of continuum structures. New Delhi: Wiley; 2010.
Wang S, Tai K, Wang MY. An enhanced genetic algorithm for structural topology optimization. Int J Numer Methods Eng. 2006;65(1):18–44.
Hadidi A, Azad SK, Azad SK. Structural optimization using artificial bee colony algorithm. In: 2nd international conference on engineering optimization. 2010. p. 6–9.
Hare W, Nutini J, Tesfamariam S. A survey of nongradient optimization methods in structural engineering. Adv Eng Softw. 2013;59:19–28.
Wang SY, Tai K. Structural topology design optimization using genetic algorithms with a bitarray representation. Comput Methods Appl Mech Eng. 2005;194(36):3749–70.
Sandgren E, Jensen E. Topological design of structural components using genetic optimization method. 1990.
Tejani GG, Kumar S, Gandomi AH. Multiobjective heat transfer search algorithm for truss optimization. Eng Comput. 2019, pp. 1–22.
Tejani GG, et al. Multiobjective adaptive symbiotic organisms search for truss optimization problems. Knowl Based Syst. 2018a;161:398–414.
Tejani GG, et al. Structural optimization using multiobjective modified adaptive symbiotic organisms search. Expert Syst Appl. 2019;125:425–41.
Tejani GG, et al. Topology and size optimization of trusses with static and dynamic bounds by modified symbiotic organisms search. J Comput Civil Eng. 2018b;32(2):04017085.
Tejani GG, Savsani VJ, Patel VK. Adaptive symbiotic organisms search (SOS) algorithm for structural design optimization. J Comput Des Eng. 2016;3(3):226–49.
Yang XS. Natureinspired metaheuristic algorithms. Frome: Luniver press; 2010a.
Yang XS. Firefly algorithms for multimodal optimization. In: International symposium on stochastic algorithms. Berlin: Springer; 2009. p. 169–78.
Kumbharana SN, Pandey GM. Solving travelling salesman problem using firefly algorithm. Int J Res Sci Adv Technol. 2013;2(2):53–7.
Jati GK. Evolutionary discrete firefly algorithm for travelling salesman problem. In: International conference on adaptive and intelligent systems. Berlin: Springer; 2011. p. 393–403.
Lukasik S, Zak S. Firefly algorithm for continuous constrained optimization tasks. In: International conference on computational collective intelligence. Berlin: Springer; 2009. p. 97–106.
Apostolopoulos T, Vlachos A. Application of the firefly algorithm for solving the economic emissions load dispatch problem. Int J Comb. 2010, p. 2011.
Yang XS. Firefly algorithm, Levy flights and global optimization. In: Research and development in intelligent systems XXVI. London: Springer; 2010. p. 209–18.
Fister I, Yang XS, Brest J. A comprehensive review of firefly algorithms. Swarm Evolut Comput. 2013;13:34–46.
Hönig U. A firefly algorithmbased approach for scheduling task graphs in homogeneous systems. Proc Inform. 2010, p. 724.
Pal SK, Rai C, Singh AP. Comparative study of firefly algorithm and particle swarm optimization for noisy nonlinear optimization problems. Int J Intell Syst Appl. 2012;4(10):50.
Chandrupatla TR, et al. Introduction to finite elements in engineering. Upper Saddle River: Prentice Hall; 2002.
Liu K, Tovar A. An efficient 3D topology optimization code written in Matlab. Struct Multidiscip Optim. 2014;50(6):1175–96.
Andreassen E, et al. Efficient topology optimization in MATLAB using 88 lines of code. Struct Multidiscip Optim. 2011;43:1–16.
Sigmund O. A 99 line topology optimization code written in Matlab. Struct Multidiscip Optim. 2001;21:120–7.
Erik A, et al. Efficient topology optimization in MATLAB using 88 lines of code. Struct Multidiscip Optim. 2011;43:1–16.
Biyikli E, To AC. Proportional topology optimization: a new nonsensitivity method for solving stress constrained and minimum compliance problems and its implementation in MATLAB. PLoS ONE. 2015;10(12):e0145041.
Duysinx P, Sigmund O. New developments in handling stress constraints in optimal material distribution. In: 7th AIAA/USAF/NASA/ISSMO symposium on multidisciplinary analysis and optimization. St. Louis, Missouri. 1998; p. 4906.
Author information
Authors and Affiliations
Contributions
HSG carried out the model development, writing the program code to solve developed model and simulation of results. DEW carried out checking the reporting of results and over all structure of the paper. FMH has done the reading the paper and worked on the language and asscoiated things within the paper. All authors read and approved the final manuscript.
Corresponding author
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Gebremedhen, H.S., Woldemichael, D.E. & Hashim, F.M. A firefly algorithm based hybrid method for structural topology optimization. Adv. Model. and Simul. in Eng. Sci. 7, 44 (2020). https://doi.org/10.1186/s40323020001830
Received:
Accepted:
Published:
DOI: https://doi.org/10.1186/s40323020001830
Keywords
 Firefly algorithm
 FEA
 Stress based topology optimization