Skip to main content
  • Research article
  • Open access
  • Published:

A firefly algorithm based hybrid method for structural topology optimization


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 stress-based 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 two-dimensional benchmark problems and the results were compared with results using the OC method. Weight percentage reduction, maximum stress-induced, 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 end-users, 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.


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/Bi-directional 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, ESO-based methods have been recommended to solve problems having pin-jointed 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 algorithm-based 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 nature-based optimization algorithm developed by Xin-She Yang in late 2007 [15, 16]. It is a stochastic, meta-heuristic 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 nature-inspired algorithms, including genetic and particle-swarm optimization algorithms [19, 22,23,24]. FA and its variants have been applied for different optimization and engineering problems as shown in Fig. 1.

Fig. 1
figure 1

Taxonomy of firefly application [22]

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. 1.

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

  2. 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. 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):

Fig. 2
figure 2

Pseudo code of firefly algorithm [15]

  • 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), $$

    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:

$$ x_{ik} = x_{ik} + \beta \left( {x_{ik} - x_{jk} } \right) + { }\alpha S_{k} \left( {rand - 0.5} \right), $$

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:

$$ {\varvec{\beta}} = {\varvec{\beta}}_{0} {\varvec{e}}^{{\user2{\gamma r}_{{{\varvec{ij}}}} }} , $$

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:

$$ {\varvec{r}}_{{{\varvec{ij}}}} = \left| {{\varvec{x}}_{{\varvec{i}}} - {\varvec{x}}_{{\varvec{j}}} } \right| = \sqrt {\mathop \sum \limits_{{{\varvec{k}} = 1}}^{{\varvec{d}}} \left( {{\varvec{x}}_{{{\varvec{i}},{\varvec{k}}}} - {\varvec{x}}_{{{\varvec{j}},{\varvec{k}}}} } \right)^{2} } . $$

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:

$$ {\varvec{S}}_{{\varvec{k}}} = \left| {{\varvec{u}}_{{\varvec{k}}} - {\varvec{l}}_{{\varvec{k}}} } \right|. $$

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 constraint-handling mechanism used in the FA is given by:

$$ {\varvec{x}}_{{{\varvec{ik}}}} = \left\{ {\begin{array}{*{20}ll} { {\varvec{l}}_{{\varvec{k}}}, \quad if \quad{\varvec{x}}_{{{\varvec{ik}}}} < {\varvec{l}}_{{\varvec{k}}} } \\ { {\varvec{u}}_{{\varvec{k}}},\quad if \quad{\varvec{x}}_{{{\varvec{ik}}}} >{\varvec{l}}_{{\varvec{k}}} } \\ \end{array} } \right.. $$

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:

$$ {\varvec{\alpha}}\left( {\varvec{t}} \right) = {\varvec{\alpha}}\left( {{\varvec{t}} - 1} \right).{\varvec{\theta}}^{{\frac{1}{{{\varvec{MCN}}}}}} , $$

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

$$ {\varvec{r}}_{{{\varvec{ij}}}} = \left| {{\varvec{x}}_{{\varvec{i}}} - {\varvec{x}}_{{\varvec{j}}} } \right| = \sqrt {\mathop \sum \limits_{{{\varvec{k}} = 1}}^{{\varvec{d}}} \left( {{\varvec{x}}_{{{\varvec{i}},{\varvec{k}}}} - {\varvec{x}}_{{{\varvec{j}},{\varvec{k}}}} } \right)^{2 } } . $$

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:

$$ {\varvec{I}}\left( {\varvec{\gamma}} \right) = \frac{{{\varvec{I}}_{{\varvec{s}}} }}{{{\varvec{r}}^{2} }}, $$

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:

$$ {\varvec{I}} = {\varvec{I}}_{\mathbf{0}} {\varvec{e}}^{{ - \user2{\gamma r}}} , $$

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:

$$ {{\varvec{\upbeta}}} = {\varvec{\beta}}_{\mathbf{0}} {\varvec{e}}^{{\user2{\gamma r}^{2} }} , $$

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:

$$ {\varvec{x}}_{{\varvec{i}}}^{{{\varvec{t}} + 1}} = {\varvec{x}}_{{\varvec{i}}}^{{\varvec{t}}} + {\varvec{\beta}}_{\mathbf{0}} {\varvec{e}}^{{ - \user2{\gamma r}^{2} }} \left( {{\varvec{x}}_{{\varvec{j}}}^{{\varvec{t}}} - {\varvec{x}}_{{\varvec{i}}}^{{\varvec{t}}} } \right) + \user2{\alpha \in }_{{\varvec{i}}}^{{\varvec{t}}} , $$

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 three-dimensional mass minimization can be defined as:

$$ \begin{aligned} _{X}^{Min} V & = \mathop \sum \limits_{e = 1}^{N} x_{e}^{P} v_{e} \\ {\text{Subjected}}\;{\text{to}}:\user2{ g}\left( {{\varvec{x}}_{{\varvec{e}}} } \right) & = \frac{{{\varvec{\sigma}}^{{{\varvec{vm}}}} }}{{{\varvec{\sigma}}_{{{\varvec{yield}}}} }} < {\mathbf{1}} \\ :KU &= F \\ 0 < x_{min} & \le x_{e} \le 1, \\ \end{aligned} $$

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.

Fig. 3
figure 3

Discretized design domain

Stress and strain analysis

A two-dimensional 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}}}}\).

Fig. 4
figure 4

Two-dimensional element stress state

Like the stress state, there are three strain components which are directly proportional to the displacements in the respective direction can be expressed as:

$$ {\varvec{\varepsilon}}_{{{\varvec{xx}}}} =\frac{{\partial {\varvec{u}}}}{{\partial {\varvec{x}}}},{\varvec{\varepsilon}}_{{{\varvec{yy}}}} =\frac{{\partial {\varvec{v}}}}{{\partial {\varvec{y}}}},{\varvec{\varepsilon}}_{{{\varvec{xy}}}} = \frac{{\partial {\varvec{v}}}}{{\partial {\varvec{x}}}} + \frac{{\partial {\varvec{u}}}}{{\partial {\varvec{y}}}}, $$

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 stress-induced in the material can be related with the strain as:

$$ \left\{ {\varvec{\sigma}} \right\} = \left[ {\varvec{D}} \right]\left\{ {\varvec{\varepsilon}} \right\}, $$

where \(D\) is the constitutive matrix, which can be related to the Young’s modulus and Poisson’s ratio as:

$$ \left[ {\varvec{D}} \right] = \frac{{\varvec{E}}}{{1 - {\varvec{v}}^{2} }}\left[ {\begin{array}{*{20}c} 1 & {\varvec{v}} & \mathbf{0} \\ {\varvec{v}} & \mathbf{1} & \mathbf{0} \\ \mathbf{0} & \mathbf{0} & {\frac{{\mathbf{1} - {\varvec{v}}}}{\mathbf{2}}} \\ \end{array} } \right], $$

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 stress-induced and elemental stiffness matrix the displacement is approximated using shape functions as:

$$\left[ \varvec{N} \right] = \left\lceil {\begin{matrix} {\varvec{N}\mathbf{1}} &\mathbf{0} & \varvec{N}{\mathbf{2}} & \mathbf{0} & {\varvec{N}}{\mathbf{3}} & \mathbf{0} & {\varvec{N}}{\mathbf{4}} & \mathbf{0} \\ \mathbf{0} & {\varvec{N}}{\mathbf{1}} & \mathbf{0} & {\varvec{N}}{\mathbf{2}} & \mathbf{0} & {\varvec{N}}{\mathbf{3}} & \mathbf{0} & {\varvec{N}}{\mathbf{4}} \\ \end{matrix} } \right\rceil ,$$


$$ N1 = \frac{1}{4}\left( {1 - \xi } \right)\left( {1 - \eta } \right)\quad N3 = \frac{1}{4}\left( {1 + \xi } \right)(1 + \eta ), $$
$$ N2 = \frac{1}{4}\left( {1 + \xi } \right)\left( {1 - \eta } \right)\quad N4 = \frac{1}{4}\left( {1 - \xi } \right)\left( {1 + \eta } \right). $$
Fig. 5
figure 5

Square finite element in the Natural coordinate system

Strain–displacement matrix

The displacement vector can be approximated in terms of the shape functions as:

$$ \begin{aligned} \left\{ {\varvec{u}} \right\} & = \left[ {\varvec{N}} \right]\left\{ {\varvec{d}} \right\} \\ \left\{ {\varvec{\varepsilon}} \right\} & = \left[ \varvec\partial \right]\left\{{\varvec{u}} \right\} \\ \left\{{\varvec{\varepsilon}} \right\} & = \left[ \varvec\partial \right]\left[ {\varvec{N}} \right]\left\{{\varvec{d}} \right\}, \\ \end{aligned} $$

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:

$$ \left[ {\varvec{B}} \right] = \left[ {\begin{array}{*{20}c} {\frac{{\varvec\partial {\varvec{N}}_{1} }}{{\varvec\partial {\varvec{x}}}}} & \mathbf{0} \\ \mathbf{0} & {\frac{{\varvec\partial {\varvec{N}}_{1} }}{{\varvec\partial {\varvec{y}}}}} \\ {\frac{{\varvec\partial {\varvec{N}}_{1} }}{{\varvec\partial {\varvec{y}}}}} &{\frac{{\varvec\partial {\varvec{N}}_{1} }}{{\varvec\partial {\varvec{x}}}}} \\ \end{array} \begin{array}{*{20}c} {\frac{{\varvec\partial {\varvec{N}}_{2} }}{{\varvec\partial {\varvec{x}}}}} & \mathbf{0} \\ \mathbf{0} & {\frac{{\varvec\partial {\varvec{N}}_{2} }}{\varvec{\partial {\varvec{x}}}}} \\ {\frac{{\varvec\partial {\varvec{N}}_{2} }}{{\varvec\partial {\varvec{y}}}}} & {\frac{{\varvec\partial {\varvec{N}}_{2} }}{{\varvec\partial {\varvec{x}}}}} \\ \end{array} \begin{array}{*{20}c} {\frac{{\varvec\partial {\varvec{N}}_{3} }}{{\varvec\partial {\varvec{x}}}}} & \mathbf{0} \\ \mathbf{0} & {\frac{{\varvec\partial {\varvec{N}}_{3} }}{{\varvec\partial {\varvec{x}}}}} \\ {\frac{{\varvec\partial {\varvec{N}}_{3} }}{{\varvec\partial {\varvec{y}}}}} & {\frac{{\varvec\partial {\varvec{N}}_{3} }}{{\varvec\partial {\varvec{x}}}}} \\ \end{array} \begin{array}{*{20}c} {\frac{{\varvec\partial {\varvec{N}}_{4} }}{{\varvec\partial {\varvec{x}}}}} & \mathbf{0} \\ \mathbf{0} & {\frac{{\varvec\partial {\varvec{N}}_{4} }}{{\varvec\partial {\varvec{x}}}}} \\ {\frac{{\varvec\partial {\varvec{N}}_{4} }}{{\varvec\partial {\varvec{y}}}}} & {\frac{{\varvec\partial {\varvec{N}}_{4} }}{{\varvec\partial {\varvec{x}}}}} \\ \end{array} } \right]. $$

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:

$$ \begin{gathered} {\varvec{if}} {\varvec{x}}_{{\varvec{e}}} {\varvec{\beta}}_{{\varvec{e}}}^{{\varvec{\eta}}} \le {\mathbf{max}}\left( {{\varvec{x}}_{{{\varvec{min}}}} ,{\varvec{x}}_{{\varvec{e}}} - {\varvec{m}}} \right) \hfill \\ {\varvec{x}}_{{\varvec{e}}}^{{{\varvec{new}}}} = {\mathbf{max}}\left( {{\varvec{x}}_{{{\varvec{min}}}} ,{\varvec{x}}_{{\varvec{e}}} - {\varvec{m}}} \right) \hfill \\ {\mathbf{if}} {\mathbf{max}}\left( {{\mathbf{x}}_{{{\mathbf{min}}}} ,{\mathbf{x}}_{{\mathbf{e}}} - {\mathbf{m}}} \right) < {\mathbf{x}}_{{\mathbf{e}}} {{\varvec{\upbeta}}}_{{\mathbf{e}}}^{{{\varvec{\upeta}}}} \le {\mathbf{min}}\left( {1,{\mathbf{x}}_{{\mathbf{e}}} + {\mathbf{m}}} \right) \hfill \\ {\varvec{x}}_{{\varvec{e}}}^{{{\varvec{new}}}} = {\varvec{x}}_{{\varvec{e}}} {\varvec{\beta}}_{{\varvec{e}}}^{{\varvec{\eta}}} \hfill \\ {\varvec{if}}\min \left( {1,{\varvec{x}}_{{\varvec{e}}} + {\varvec{m}}} \right) < {\varvec{x}}_{{\varvec{e}}} {\varvec{\beta}}_{{\varvec{e}}}^{{\varvec{\eta}}} \hfill \\ {\varvec{x}}_{{\varvec{e}}}^{{{\varvec{new}}}} = \min \left( {1,{\varvec{x}}_{{\varvec{e}}} + {\varvec{m}}} \right), \hfill \\ \end{gathered} $$

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:

$$ {\varvec{\beta}}_{{\varvec{e}}} = \frac{{\frac{{\partial {\varvec{v}}}}{{\partial {\varvec{x}}}}}}{{{\varvec{\lambda}}\frac{{\partial {\varvec{g}}}}{{\partial {\varvec{x}}}}}}, $$

where \({{\varvec{\uplambda}}}\) is a Lagrangian multiplier. Here, the value is found from a bi-sectioning algorithm. The sensitivity analysis for problems defined in Eq. 21 can be calculated as:

$$ \frac{{\frac{{\partial {\varvec{v}}}}{{\partial {\varvec{x}}}}}}{{\frac{{\partial {\varvec{g}}}}{{\partial {\varvec{x}}}}}} = \frac{1}{{\frac{\partial }{{\partial {\varvec{x}}}}\left( {\frac{{{\varvec{\sigma}}^{{{\varvec{vm}}}} }}{{{\varvec{\sigma}}_{{{\varvec{yield}}}} }} - 1} \right)}}. $$

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:

$$ {\varvec{\sigma}}\left( {\varvec{x}} \right) = \frac{{{\varvec{D}}_{{\varvec{e}}} \left( {\varvec{x}} \right)\overline{\user2{\varepsilon }}\left( {\varvec{x}} \right)}}{{{\varvec{x}}^{{\varvec{q}}} }}, $$

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 power-law 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.

$$ {\varvec{D}}_{{\varvec{e}}} \left( {\varvec{x}} \right) = {\varvec{x}}^{{\varvec{P}}} {\varvec{D}}_{0} , $$
$$ {\varvec{\varepsilon}}\left( {\varvec{x}} \right) = {\varvec{Bu}}_{{\varvec{e}}} . $$

Substituting Eqs. 24 and 25 into Eq. 23, the stress at any material point with the given design domain can be expressed as:

$$ \varvec\sigma \left( \varvec{x} \right) = \varvec{x}^{\varvec{P} - \varvec{q}} \varvec{D}_{\mathbf{0}} \varvec{B}_{\varvec{e}} \varvec{u}_{\varvec{e}} . $$

From Eq. 26 the partial derivative of the constraint function in Eq. 22 can be expressed as:

$$ \frac{\varvec{\partial g}}{{\varvec{\partial x}}} = \left( {\varvec{p} - \varvec{q}} \right) \varvec{x}^{\varvec{P} -\varvec{q} - \mathbf{1}} \varvec{D}_{\mathbf{0}} \varvec{B}_{\varvec{e}} \varvec{u}_{\varvec{e}} + \varvec{x}^{\varvec{P} - \varvec{q}} \varvec{D}_{\mathbf{0}} \varvec{B}_{\varvec{e}} \frac{{\varvec\partial \varvec{u}_{\varvec{e}} }}{\varvec{\partial x}}. $$

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:

$$ \frac{\varvec{\partial g}}{{\varvec{\partial x}}} = \left( {\varvec{p} - \varvec{q}} \right)\varvec{x}^{\varvec{P} - \varvec{q} - \mathbf{1}} \varvec{D}_{\mathbf{0}} \varvec{B}_{\varvec{e}} \varvec{u}_{\varvec{e}} - \varvec{x}^{\varvec{P} - \varvec{q}} \varvec{D}_{\mathbf{0}} \varvec{B}_{\varvec{e}} \frac{\varvec{\partial k}}{{\varvec{\partial x}}}\frac{\varvec{u}}{{k}}. $$

Therefore, the sensitivity analysis for stress-based topology optimization becomes:

$$\frac{{\frac{{\varvec{\partial v}}}{{\varvec{\partial x}}}}}{{\frac{{\varvec{\partial g}}}{{\varvec{\partial x}}}}} = \frac{\mathbf{1}}{{\left( {\varvec{p} - \varvec{q}} \right){\varvec{x}^{\varvec{P} -\varvec{q} - \mathbf{1}}}{\varvec{D}_\mathbf{0}}{\varvec{B}_{\varvec{e}}}{\varvec{u}_{\varvec{e}}} - {\varvec{x}^{\varvec{P} -\varvec{q}}}{\varvec{D}_\mathbf{0}}{\varvec{B}_{\varvec{e}}}\frac{{\varvec{\partial k}}}{{\varvec{\partial x}}}\frac{\varvec{u}}{\varvec{k}}}}$$

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.

Fig. 6
figure 6

Effect of variation of function evaluation on 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.

Fig. 7
figure 7

Effect of number of fireflies on 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.

Fig. 8
figure 8

a Design domain and b generated material distribution

Fig. 9
figure 9

A schematic diagram of structural topology optimization using discrete firefly

Fig. 10
figure 10

Convergence history of hybrid method

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.

Fig. 11
figure 11

Boundary and loading condition

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.

Fig. 12
figure 12

Optimal material plots for numerous sizes of design domain a 45 × 32, b 60 × 80, c 80 × 30, d 100 × 40, e 120 × 60 and f 200 × 70

The generated topologies for the Cantilever beam under loading and boundary conditions in Fig. 11b, c are presented in Figs. 13 and 14, respectively.

Fig. 13
figure 13

Optimal material plots for numerous sizes of design domain a 40 × 40, b 60 × 30, c 80 × 30, and d 120 × 60

Fig. 14
figure 14

Optimal material plots for numerous sizes of design domain a 40 × 20, b 60 × 30, c 60 × 60, and d 80 × 30

L-shape beam

The other benchmark problem considered to be solved using the proposed method is an L-shape 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.

Table 1 Boundary and loading condition with respective topologies under various discretization size L-shape variant 1
Table 2 Boundary and loading condition with respective topologies under various discretization size L-shape variant 2

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.

Fig. 15
figure 15

Definition of boundary and loading conditions

Fig. 16
figure 16

Optimal material plots for different sizes of design domain a 60 × 20, b 80 × 30, c 120 × 60, and d 100 × 40

Comparison of results

The optimization results using the proposed method were compared with results from OC-method 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.

Table 3 Generated optimal topologies using proposed method and optimality criteria (OC) method
Table 4 Performance evaluation of proposed method on different design domains


This paper presented a firefly algorithm (FA)-based hybrid method for stress-based 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 OC-based 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%.


  1. Bendsoe MP. Optimal shape design as a material distribution problem. Struct Optim. 1989;1:193–202.

    Article  Google Scholar 

  2. Xie YM, Steven GP. Evolutionary structural optimization. London: Springer; 1997.

    Book  Google Scholar 

  3. Querin OM, Steven GP, Xie YM. Evolutionary structural optimisation (ESO) using a bidirectional algorithm. Eng Comput. 1998;15(8):1031–48.

    Article  Google Scholar 

  4. Huang X, Xie YM. Evolutionary topology optimization of continuum structures. New Delhi: Wiley; 2010.

    Book  Google Scholar 

  5. Wang S, Tai K, Wang MY. An enhanced genetic algorithm for structural topology optimization. Int J Numer Methods Eng. 2006;65(1):18–44.

    Article  MathSciNet  Google Scholar 

  6. Hadidi A, Azad SK, Azad SK. Structural optimization using artificial bee colony algorithm. In: 2nd international conference on engineering optimization. 2010. p. 6–9.

  7. Hare W, Nutini J, Tesfamariam S. A survey of non-gradient optimization methods in structural engineering. Adv Eng Softw. 2013;59:19–28.

    Article  Google Scholar 

  8. Wang SY, Tai K. Structural topology design optimization using genetic algorithms with a bit-array representation. Comput Methods Appl Mech Eng. 2005;194(36):3749–70.

    Article  Google Scholar 

  9. Sandgren E, Jensen E. Topological design of structural components using genetic optimization method. 1990.

  10. Tejani GG, Kumar S, Gandomi AH. Multi-objective heat transfer search algorithm for truss optimization. Eng Comput. 2019, pp. 1–22.

  11. Tejani GG, et al. Multiobjective adaptive symbiotic organisms search for truss optimization problems. Knowl Based Syst. 2018a;161:398–414.

    Article  Google Scholar 

  12. Tejani GG, et al. Structural optimization using multi-objective modified adaptive symbiotic organisms search. Expert Syst Appl. 2019;125:425–41.

    Article  Google Scholar 

  13. 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.

    Article  Google Scholar 

  14. 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.

    Google Scholar 

  15. Yang XS. Nature-inspired metaheuristic algorithms. Frome: Luniver press; 2010a.

    Google Scholar 

  16. Yang X-S. Firefly algorithms for multimodal optimization. In: International symposium on stochastic algorithms. Berlin: Springer; 2009. p. 169–78.

    Google Scholar 

  17. Kumbharana SN, Pandey GM. Solving travelling salesman problem using firefly algorithm. Int J Res Sci Adv Technol. 2013;2(2):53–7.

    Google Scholar 

  18. Jati GK. Evolutionary discrete firefly algorithm for travelling salesman problem. In: International conference on adaptive and intelligent systems. Berlin: Springer; 2011. p. 393–403.

    Chapter  Google Scholar 

  19. Lukasik S, Zak S. Firefly algorithm for continuous constrained optimization tasks. In: International conference on computational collective intelligence. Berlin: Springer; 2009. p. 97–106.

  20. Apostolopoulos T, Vlachos A. Application of the firefly algorithm for solving the economic emissions load dispatch problem. Int J Comb. 2010, p. 2011.

  21. Yang XS. Firefly algorithm, Levy flights and global optimization. In: Research and development in intelligent systems XXVI. London: Springer; 2010. p. 209–18.

    Chapter  Google Scholar 

  22. Fister I, Yang X-S, Brest J. A comprehensive review of firefly algorithms. Swarm Evolut Comput. 2013;13:34–46.

    Article  Google Scholar 

  23. Hönig U. A firefly algorithm-based approach for scheduling task graphs in homogeneous systems. Proc Inform. 2010, p. 724.

  24. Pal SK, Rai C, Singh AP. Comparative study of firefly algorithm and particle swarm optimization for noisy non-linear optimization problems. Int J Intell Syst Appl. 2012;4(10):50.

    Google Scholar 

  25. Chandrupatla TR, et al. Introduction to finite elements in engineering. Upper Saddle River: Prentice Hall; 2002.

    Google Scholar 

  26. Liu K, Tovar A. An efficient 3D topology optimization code written in Matlab. Struct Multidiscip Optim. 2014;50(6):1175–96.

    Article  MathSciNet  Google Scholar 

  27. Andreassen E, et al. Efficient topology optimization in MATLAB using 88 lines of code. Struct Multidiscip Optim. 2011;43:1–16.

    Article  Google Scholar 

  28. Sigmund O. A 99 line topology optimization code written in Matlab. Struct Multidiscip Optim. 2001;21:120–7.

    Article  Google Scholar 

  29. Erik A, et al. Efficient topology optimization in MATLAB using 88 lines of code. Struct Multidiscip Optim. 2011;43:1–16.

    Article  Google Scholar 

  30. Biyikli E, To AC. Proportional topology optimization: a new non-sensitivity method for solving stress constrained and minimum compliance problems and its implementation in MATLAB. PLoS ONE. 2015;10(12):e0145041.

    Article  Google Scholar 

  31. 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.

Download references

Author information

Authors and Affiliations



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

Correspondence to Hailu Shimels Gebremedhen.

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

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

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).

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI: