0% found this document useful (0 votes)
21 views

FFA Source Code

The document describes an optimization algorithm called Flies Optimization Algorithm (FOA) which is inspired by how fruit flies search for food. The algorithm uses a population of flies that randomly change their position in each iteration to estimate the distance from the origin and calculate a smell concentration value, which is then used in a fitness function to find the maximum value.

Uploaded by

HaleemaMalik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

FFA Source Code

The document describes an optimization algorithm called Flies Optimization Algorithm (FOA) which is inspired by how fruit flies search for food. The algorithm uses a population of flies that randomly change their position in each iteration to estimate the distance from the origin and calculate a smell concentration value, which is then used in a fitness function to find the maximum value.

Uploaded by

HaleemaMalik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

optimization without constraints: QP 

 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%% Pan's Original 2D‐FOA 
%% EMA Economic Department, Soochow University, Taipei,Taiwan 

% Copyright by W‐T Pan (2011) 
% Revised by W‐Y Lin (2011) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
%% Topic: How to find  the max value of a quadratic function 
 
% Clear the operating environment. 
tic 
clc 
clear 
 
% Randomize the initial Drosophila population positions. 
X_axis=10*rand(); 
Y_axis=10*rand(); 
 
% Set parameters 
maxgen=100;  % No.of iterations  
sizepop=20;  % Population size 
 
% Start the FOA: Flies use the sense of smell to find food 
 
for i=1:sizepop 
 
% The Drosophila uses its olfactory to search the food 
% by random direction and distance 
 
X(i)=X_axis+2*rand()‐1; 
Y(i)=Y_axis+2*rand()‐1; 
 
% Due to the fly cannot find the exact location of the prey, so we first estimate the distance from the origin (Dist).  
% And then calculate the flavor concentration determination value (S), it is the inverse of the distance. 
 
D(i)=(X(i)^2+Y(i)^2)^0.5; 
S(i)=1/D(i); 
 
% Concentration determination value (S) is substituted into the fitness function, i.e. the concentration of the flavor 
(Smelli) of the flies.  
 
Smell(i)=7‐S(i)^2; 
 
end 
 
% Identify the highest concentration values of this fruit fly Drosophila groups (find the maximum value). 

You might also like