# Moth flame optimization

Moth-Flame Optimization (MFO) algorithm was proposed in 2016 [1] as one of the seminal attempt to simulate the navigation of moths in computer and propose an optimization algorithm. This algorithm has been widely used in science and industry.

## Inspiration

Moths are fancy insects, which are highly similar to the family of butterflies. Basically, there are over 160,000 various species of this insect in nature. They have two main milestones in their lifetime: larvae and adult. The larvae is converted to moth by cocoons. The most interesting fact about moths is their special navigation methods in night. They have been evolved to fly in night using the moon light. They utilized a mechanism called transverse orientation for navigation. In this method, a moth flies by maintaining a fixed angle with respect to the moon, a very effective mechanism for travelling long distances in a straight path [2]. Since the moon is far away from the moth, this mechanism guarantees flying in straight line. The same navigation method can be done by humans. Suppose that the moon is in the south side of the sky and a human wants to go the east. If he keeps moon of his left side when walking, he would be able to move toward the east on a straight line.

Despite the effectiveness of transverse orientation, we usually observe that moths fly spirally around the lights. In fact, moths are tricked by artificial lights and show such behaviours. This is due to the inefficiency of the transverse orientation, in which it is only helpful for moving in straight line when the light source is very far. When moths see a human-made artificial light, they try to maintain a similar angle with the light to fly in straight line. Since such a light is extremely close compared to the moon, however, maintaining a similar angle to the light source causes a useless or deadly spiral fly path for moths [3].

## MFO algorithm

In the MFO algorithm, it is assumed that the candidate solutions are moths and the problem’s variables are the position of moths in the space. Therefore, the moths can fly in 1-D, 2-D, 3-D, or hyper dimensional space with changing their position vectors. Since the MFO algorithm is a population-based algorithm.

It should be noted here that moths and flames are both solutions. The difference between them is the way we treat and update them in each iteration. The moths are actual search agents that move around the search space, whereas flames are the best position of moths that obtains so far. In other words, flames can be considered as flags or pins that are dropped by moths when searching the search space. Therefore, each moth searches around a flag (flame) and updates it in case of finding a better solution. With this mechanism, a moth never lose its best solution.

A logarithmic spiral has been chosen as the main update mechanism of moths in this paper. However, any types of spiral can be utilized here subject to the following conditions: Spiral’s initial point should start from the moth Spiral’s final point should be the position of the flame Fluctuation of the range of spiral should not exceed from the search space Considering these points, we define a logarithmic spiral for the MFO algorithm as follows:

${\displaystyle S(M_{i},F_{i})=D_{i}e^{bt}cos(2\pi t)+F_{j}}$

where ${\displaystyle d_{i}}$  indicates the distance of the ${\displaystyle i-th}$  moth for the ${\displaystyle j-th}$ flame, ${\displaystyle b}$  is a constant for defining the shape of the logarithmic spiral, and t is a random number in [-1,1].

D is calculated as follows:

${\displaystyle D_{i}=|F_{j}-M_{i}|}$

where ${\displaystyle M_{i}}$  indicate the ${\displaystyle i-th}$  moth,${\displaystyle F_{j}}$  indicates the ${\displaystyle j-th}$  flame, and ${\displaystyle D_{i}}$  indicates the distance of the ${\displaystyle i-th}$  moth for the ${\displaystyle j-th}$  flame.

${\displaystyle S(M_{i},F_{i})=D_{i}e^{bt}cos(2\pi t)+F_{j}}$  is where the spiral flying path of moths is simulated. As may be seen in this equation, the next position of a moth is defined with respect to a flame. The t parameter in the spiral equation defines how much the next position of the moth should be close to the flame (t = -1 is the closest position to the flame, while t = 1 shows the farthest). Therefore, a hyper ellipse can be assumed around the flame in all directions and the next position of the moth would be within this space. Spiral movement is the main component of the proposed method because it dictates how the moths update their positions around flames. The spiral equation allows a moth to fly “around” a flame and not necessarily in the space between them. Therefore, the exploration and exploitation of the search space can be guaranteed.

The proposed position updating procedure can guarantee the exploitation around the flames. In order to improve the probability of finding better solutions, we consider the best solutions obtained so far as the flames. So, the matrix F in the above equation always includes n recent best solutions obtained so far. The moths are required to update their positions with respect to this matrix during optimization. In order to further emphasize exploitation, we assume that t is a random number in [r,1] where r is linearly decreased from -1 to -2 over the course of iteration. Note that we name r as the convergence constant. With this method, moths tend to exploit their corresponding flames more accurately proportional to the number of iterations.

A question that may rise here is that the position updating only requires the moths to move towards a flame, yet it causes the MFO algorithm to be trapped in local optima quickly. In order to prevent this, each moth is obliged to update its position using only one of the flames. It each iteration and after updating the list of flames, the flames are sorted based on their fitness values. The moths then update their positions with respect to their corresponding flames. The first moth always updates its position with respect to the best flame, whereas the last moth updates its position with respect to the worst flame in the list.

It should be noted that this assumption is done for designing the MFO algorithm, while possibly it is not the actual behaviour of moths in nature. However, the transverse orientation is still done by the artificial moths. The reason that why a specific flame is assigned to each moth is to prevent local optimum stagnation. If all of the moths get attracted to a single flame, all of them converge to a point in the search spaces because they can only fly towards a flame and not outwards. Requiring them to move around different flames, however, causes higher exploration of the search space and lower probability of local optima stagnation.

Therefore, the exploration of the search space around the best locations obtained so far is guaranteed with this method due to the following reasons:

• Moths update their positions in hyper spheres around the best solutions obtained so far.
• The sequence of flames is changed based on the best solutions in each iteration, and the moths are required to update their positions with respect to the updated flames. Therefore, the position updating of moths may occur around different flames, a mechanism that causes sudden movement of moths in search space and promotes exploration.

Another concern here is that the position updating of moths with respect to n different locations in the search space may degrade the exploitation of the best promising solutions. To resolve this concern, an adaptive mechanism is proposed for the number of flames.

${\displaystyle FlameNumber=round(N-l\times {\frac {N-1}{T}})}$

where ${\displaystyle l}$  is the current number of iteration, ${\displaystyle N}$  is the maximum number of flames, and ${\displaystyle T}$  indicates the maximum number of iterations.

There is N number of flames in the initial steps of iterations. However, the moths update their positions only with respect to the best flame in the final steps of iterations. The gradual decrement in number of flames balances exploration and exploitation of the search space. After all, the general steps of the P function are as follows.

The pseudo code of the WOA algorithm is presented below:

Update the number of flames (FlameNumber)
Initialise the population of moths
Calculate the objective values

for all moths
for all paramters
update r and t
Calculate D with respect to the corresponding moth
Update the matrix M with respect to the corresponding moth
end
calculate the objective values
Update flames
end


## Applications

Forecast the electricity consumption of Inner Mongolia [4]

Multi-item EOQ model with nonlinear unit holding cost and partial backordering[5]

Training multi-layer perceptrons[6]

Optimal Power Flow [7]

Parameters extraction of the three diode model for the multi-crystalline solar cell/module[8]

Optimal Multi-Criteria Design of Hybrid Power Generation Systems[9]

Automatic mitosis detection in breast cancer histology images[10]

Tomato diseases detection[11]

Optimal power flow with voltage stability improvement and loss reduction in power system[12]

Optimal setting of STATCOM based on voltage stability improvement and power loss[13]

Terrorism detection[14]

Optimal Active and Reactive Power Dispatch Problem[15]

Price Penalty factors Based Approach for Combined Economic Emission Dispatch Problem[16]

Single level production planning in petrochemical industries[17]

Profit maximization with integration of wind farm in contingency constraint deregulated power market [18]

Annual power load forecasting[19]

Thermogram Breast Cancer Detection[20]

optimal bidding strategy under transmission congestion in deregulated power market[21]

Optimal power flow with non-parametric statistical evaluation validation[22]

Alzheimer's Disease Diagnosis[23]

Sharp MDFT Filter Banks [24]

Feature selection[25]

Controller Performance in Microgrid Frequency Deviation Enhancement[26]

Unit Commitment in Power System Operation Planning[27]

Multilevel Thresholding Image Segmentation[28]

Economic Load Dispatch problem with ramp rate limits and prohibited operating zones[29]

Harmonic elimination of multilevel inverters[30]

Multi area power system[31]

Facial emotion recognition [32]

Economic Load Dispatch Problems with Emission and Valve Point Loading Effect[33]

Multilevel thresholding for satellite image segmentation[34]

Load frequency control of AC microgrid interconnected thermal power system[35]

Automatic Test Generation[36]

Automatic generation control in competitive market conditions[37]

Optimal active and Reactive Power dispatch problem[38]

## References

1. Mirjalili, Seyedali. "Moth-flame optimization algorithm: A novel nature-inspired heuristic paradigm." Knowledge-Based Systems 89 (2015): 228-249.
2. Gaston, Kevin J., et al. "The ecological impacts of nighttime light pollution: a mechanistic appraisal." Biological reviews 88.4 (2013): 912-927.
3. Frank, Kenneth D. "Effects of artificial night lighting on moths." Ecological consequences of artificial night lighting (2006): 305-344.
4. MLA Zhao, Huiru, Haoran Zhao, and Sen Guo. "Using GM (1, 1) Optimized by MFO with rolling mechanism to forecast the electricity consumption of Inner Mongolia." Applied Sciences 6.1 (2016): 20.
5. Khalilpourazari, Soheyl, and Seyed Hamid Reza Pasandideh. "Multi-item EOQ model with nonlinear unit holding cost and partial backordering: moth-flame optimization algorithm." Journal of Industrial and Production Engineering 34.1 (2017): 42-51.
6. Yamany, Waleed, et al. "Moth-flame optimization for training multi-layer perceptrons." Computer Engineering Conference (ICENCO), 2015 11th International. IEEE, 2015.
7. Bentouati, Bachir, Lakhdar Chaib, and Saliha Chettih. "Optimal Power Flow using the Moth Flam Optimizer: A case study of the Algerian power system." Indonesian Journal of Electrical Engineering and Computer Science 1.3 (2016): 431-445.
8. Allam, Dalia, D. A. Yousri, and M. B. Eteiba. "Parameters extraction of the three diode model for the multi-crystalline solar cell/module using Moth-Flame Optimization Algorithm." Energy Conversion and Management 123 (2016): 535-548.
9. Algabalawy, M., et al. "Optimal Multi-Criteria Design of Hybrid Power Generation Systems: A New Contribution."
10. Sayed, Gehad Ismail, and Aboul Ella Hassanien. "Moth-flame swarm optimization with neutrosophic sets for automatic mitosis detection in breast cancer histology images." Applied Intelligence (2017): 1-12.
11. Hassanien, Aboul Ella, et al. "An improved moth flame optimization algorithm based on rough sets for tomato diseases detection." Computers and Electronics in Agriculture 136 (2017): 86-96.
12. Trivedi, Indrajit N., et al. "Optimal power flow with voltage stability improvement and loss reduction in power system using Moth-Flame Optimizer." Neural Computing and Applications: 1-16.
13. Ebeed, Mohamed, Salah Kamel, and Heba Youssef. "Optimal setting of STATCOM based on voltage stability improvement and power loss minimization using Moth-Flame algorithm." Power Systems Conference (MEPCON), 2016 Eighteenth International Middle East. IEEE, 2016.
14. Soliman, Ghada MA, Motaz MH Khorshid, and Tarek HM Abou-El-Enien. "MODIFIED MOTH-FLAME OPTIMIZATION ALGORITHMS FOR TERRORISM PREDICTION."
15. Trivedi, Indrajit N., et al. "Optimal Active and Reactive Power Dispatch Problem Solution using Moth-Flame Optimizer."
16. Jangir, Narottam, et al. "Price Penalty factors Based Approach for Combined Economic Emission Dispatch Problem Solution using Moth-flame Optimizer Algorithm."
17. Chauhan, Sandeep Singh, and Prakash Kotecha. "Single level production planning in petrochemical industries using Moth-flame optimization." Region 10 Conference (TENCON), 2016 IEEE. IEEE, 2016.
18. Gope, Sadhan, et al. "Profit maximization with integration of wind farm in contingency constraint deregulated power market using Moth Flame Optimization algorithm." Region 10 Conference (TENCON), 2016 IEEE. IEEE, 2016.
19. Li, Cunbin, Shuke Li, and Yunqi Liu. "A least squares support vector machine model optimized by moth-flame optimization algorithm for annual power load forecasting." Applied Intelligence 45.4 (2016): 1166-1178.
20. Sayed, Gehad Ismail, Mona Soliman, and Aboul Ella Hassanien. "Bio-inspired Swarm Techniques for Thermogram Breast Cancer Detection." Medical Imaging in Clinical Applications. Springer International Publishing, 2016. 487-506.
21. Gope, Sadhan, et al. "Moth Flame Optimization based optimal bidding strategy under transmission congestion in deregulated power market." Region 10 Conference (TENCON), 2016 IEEE. IEEE, 2016.
22. Buch, Hitarth, Indrajit N. Trivedi, and Pradeep Jangir. "Moth flame optimization to solve optimal power flow with non-parametric statistical evaluation validation." Cogent Engineering 4.1 (2017): 1286731.
23. Sayed, Gehad Ismail, et al. "Alzheimer’s Disease Diagnosis Based on Moth Flame Optimization." International Conference on Genetic and Evolutionary Computing. Springer International Publishing, 2016.
24. Yan, Yang, and Xu Pingping. "A Novel Design of Sharp MDFT Filter Banks with Low Complexity Based on DPSO-MFO Algorithm." Recent Developments in Intelligent Systems and Interactive Applications. Springer International Publishing, 2016. 424-430.
25. Zawbaa, Hossam M., et al. "Feature selection approach based on moth-flame optimization algorithm." Evolutionary Computation (CEC), 2016 IEEE Congress on. IEEE, 2016.
26. Houshyari, Maryam, Hossein Shayeghi, and Abdollah Younesi. "Comparison of PID Type Controller Performance in Microgrid Frequency Deviation Enhancement Using MFO Algorithm." The Book of Extended Abstracts (2016): 78.
27. Reddy, Srikanth, et al. "Solution to Unit Commitment in Power System Operation Planning Using Binary Coded Modified Moth Flame Optimization Algorithm (BMMFOA): A Flame Selection Based Computational Technique." Journal of Computational Science (2017).
28. El Aziz, Mohamed Abd, Ahmed A. Ewees, and Aboul Ella Hassanien. "Whale Optimization Algorithm and Moth-Flame Optimization for Multilevel Thresholding Image Segmentation." Expert Systems with Applications (2017).
29. Trivedi, I. N., et al. "Economic Load Dispatch problem with ramp rate limits and prohibited operating zones solve using Levy flight Moth-Flame optimizer." Energy Efficient Technologies for Sustainability (ICEETS), 2016 International Conference on. IEEE, 2016.
30. Ceylan, Oğuzhan. "Harmonic elimination of multilevel inverters by moth-flame optimization algorithm." Industrial Electronics (INDEL), International Symposium on. IEEE, 2016.
31. Lal, Deepak Kumar, Kiran Kumar Bhoi, and Ajit Kumar Barisal. "Performance evaluation of MFO algorithm for AGC of a multi area power system." transfer 1: 4.
32. Zhang, Li, et al. "Intelligent facial emotion recognition using moth-firefly optimization." Knowledge-Based Systems 111 (2016): 248-267.
33. Khana, Babar Sattar, Mohammad Iftikhar Khana, and Mohammad Asif Zahoor Rajab. "163. Novel Application of Moth Flame Optimization Algorithm for solving Economic Load Dispatch Problems with Emission and Valve Point Loading Effect." (2016).
34. Muangkote, Nipotepat, Khamron Sunat, and Sirapat Chiewchanwattana. "Multilevel thresholding for satellite image segmentation with moth-flame based optimization." Computer Science and Software Engineering (JCSSE), 2016 13th International Joint Conference on. IEEE, 2016.
35. Lal, Deepak Kumar, and Ajit Kumar Barisal. "Load frequency control of AC microgrid interconnected thermal power system." International Conference on Advanced Material Technologies (ICAMT). Vol. 2016. No. 27th. 2016.
36. Metwally, Aya S., et al. "WAP: A Novel Automatic Test Generation Technique Based on Moth Flame Optimization." Software Reliability Engineering (ISSRE), 2016 IEEE 27th International Symposium on. IEEE, 2016.
37. Raju, More, Lalit Chandra Saikia, and Debdeep Saha. "Automatic generation control in competitive market conditions with moth-flame optimization based cascade controller." Region 10 Conference (TENCON), 2016 IEEE. IEEE, 2016.
38. Parmar, Siddharth A., et al. "Optimal active and Reactive Power dispatch problem solution using Moth-Flame Optimizer algorithm." Energy Efficient Technologies for Sustainability (ICEETS), 2016 International Conference on. IEEE, 2016.