**3. Principles and complexity of firefly local search algorithm**

This part concerns a brief description of the smart local search optimization methods, called firefly algorithm, we used to solve the diet problem (P).

*Firefly algorithm:* The Firefly Algorithm (FirA) was originally pioneered by Xin-She Yang [17, 18], on the basis of flashing and behavior models of fireflies. Essentially, FA employs three rules:


Because the attractiveness of a firefly is shown to be proportional to the brightness seen by nearby fireflies, given to firefly *i* and *j*, the variability of attractiveness *δij*, given the distance *dij*, is given by:

$$\delta\_{\vec{\eta}} = \delta\_0 \exp\left(-\sigma d\_{\vec{\eta}}^2\right) \tag{2}$$

Where *δ*<sup>0</sup> is the basic attracness and *σ* is a parameter chosen by the user and *σ* can be chosen based on the formula *<sup>σ</sup>* <sup>¼</sup> ffiffiffi *L* p �<sup>1</sup> , such that *L* depends on the large scale of the problem.

Given the current position of the ith *x<sup>t</sup> <sup>i</sup>* and jth *x<sup>t</sup> <sup>j</sup>* fireflies and the distance between these particles, noted *dij*, the position of the ith firefly is updated by:

$$\mathbf{x}\_{\rm i}^{t+1} = \mathbf{x}\_{\rm i}^{t} + \delta\_{\rm ij} \left(\mathbf{x}\_{\rm j}^{t} - \mathbf{x}\_{\rm i}^{t}\right) + \alpha\_{\rm t} e\_{\rm i}^{t} \tag{3}$$

The **Figure 1** illustrates the behavior of the ith firefly considering the nearest strong firefly; The random term permits to explore more regions.

*α<sup>t</sup>* is a global random serie of parameters and *ε<sup>t</sup> <sup>i</sup>* is personalized local random serie of of parameters linked to the ith firefly. The **Figure 2** gives different steps of the FA algorithm.

*Parameters:* A good way to control the algorithm randomness is consists on updating *<sup>α</sup><sup>t</sup>* based on the formula *<sup>α</sup><sup>t</sup>* <sup>¼</sup> *<sup>α</sup>*0*at* where *<sup>a</sup>*<sup>∈</sup> ½ � *:*95*:*<sup>97</sup> ; *<sup>α</sup>*<sup>0</sup> represents the initial randomness control factor [18] and can be chosen using the formula *α*<sup>0</sup> ¼ *:*001*L*.

*Complexity:* Considering the two loops of FA, the complexity at the extreme case is *O N*<sup>2</sup> *T* � �, where N is the number of generated individuals and T is the number of

**Figure 1.** *Ullistration of the behavior of the ith firefly considering the nearst strong firefly.*

*Swarm Intelligence - Recent Advances and Current Applications*

iterations. To reduce the complexity of FA, we can rank the attractiveness or brightness using sorting algorithms and the complexity becomes *O TNlog N* ð Þ ð Þ .

*Variants:* In the case of combinatorial optimization Problems, variants of FA were developed with improved efficiency [19–21].
