## 2 Optimization Problem and the Method of Finding the Optimal Solution
### Firefly Algorithm  
Firefly Algorithm is another mathematical model that describes the natural phenomena which is the behavior of fireflies during the searching of a parter [26]. The search is dependent on many factorssuch as blinking, distance or even perception by other individuals, and this introduces several factors that describes the behavior of that insects and the environment  
* light absorption coefficient,
* coefficient of motion randomness,
* attractiveness ratio,
* light intensity.  
A firefly moves into the most attractive individuals in the current environment based on the distance and the light intensity of a potential partner. In order to model this behavior, suppose that the distance between two individuals \(i\) and \(j\) will be be labeled as \(r_{ij}\) and it is calculated as  
\[r_{ij}^{t}=\|\overline{x_{i}^{t}}-\overline{x_{j}^{t}}\|=\sqrt{\sum_{k=1}^{N} \left(x_{ijk}^{t}-x_{j,k}^{t}\right)^{2}}, \tag{14}\]  
where \(t\) is the current iteration and \(x_{i,k}^{t}\), \(x_{k,j}^{t}\) - k-th components of the spatial coordinates. Attractiveness between individuals is dependent on this distance - the greater the distance is, they are less attractive to each another. Moreover, the light is absorbed by the air, because of that and simplifying the model, the following assumptions are applied to the model  
* Each firefly is unisex,
* The attractiveness is proportional to the brightness, which means that the less attractive firefly will move to more attractive,
* The distance is greater, the attractiveness is lower,
* If there is no attractive partner in the neighborhood, then firefly moves randomly.  
Reception of light intensity \(I_{ij}^{t}\) from \(i\) by \(j\) decreases as the distance \(r_{ij}^{t}\) between them increases. Moreover, the light in nature is absorbed by different media, so attractiveness depends not only on the distance but also on absorption, so light intensity \(I_{ij}^{t}\) is modeled as  
\[I_{ij}^{t}\left(r_{ij}^{t}\right)=I_{pop}\cdot e^{-\zeta\cdot\left(r_{ij}^{t} \right)^{2}}, \tag{15}\]  
where \(\zeta\) is the parameter that describes light absorption mapping natural conditions of nature.  
One of the assumption says that the attractiveness \(\beta_{ij}\) is proportional to the brightness (or firefly's lightness) what is defined as  
\[\beta_{ij}\left(r_{ij}^{t}\right)=\beta_{pop}\cdot e^{-\zeta\cdot\left(r_{ij} ^{t}\right)^{2}}, \tag{16}\]  
where \(\beta_{pop}\) is firefly attractiveness coefficient.  
The movement of fireflies is primarily dependent on the quality of the neighborhood. The primary equation that describes that movement depends on all dependencies described above what is shown in the following formula  
\[\overline{x_{i}^{t+1}}=\overline{x_{i}^{t}}+\left(\overline{x_{j}^{t}}- \overline{x_{i}^{t}}\right)\cdot\beta_{ij}^{t}\left(r_{ij}^{t}\right)\cdot I _{ij}^{t}\left(r_{ij}^{t}\right)+\kappa\cdot e_{i}, \tag{17}\]  
where \(\zeta\) is light absorption coefficient, \(\kappa\) is coefficient mapping natural randomness of fireflies, \(e_{i}\) is vector defined random change of position. In each iteration, all fireflies move to find the best position according to fitness condition \(f(\cdot)\). Described model is presented in Algorithm 4.  
```
Start,  Define all coefficients and the number of iteration \(T\) and size of population,  Define fitness function \(f(\cdot)\),  Create at initial population, \(t:=0\), while\(t\leq T\)do  Calculate all distances between individuals in whole population according to Equation (14),  Calculate all light intensity between individuals in whole population according to Equation (15),  Calculate attractiveness between individuals in whole population according to Equation (16),  Evaluate and sort population,  Move each firefly using Equation (17), \(t++\), endwhile  Return the best firefly, Stop.
```  
**Algorithm 4**Firefly Algorithm