SlideShare a Scribd company logo
2
Most read
3
Most read
% --------------------------------------------------------------------%
% Flower pollenation algorithm (FPA), or flower algorithm %
% Programmed by Xin-She Yang @ May 2012 %
% --------------------------------------------------------------------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Notes: This demo program contains the very basic components of %
% the flower pollination algorithm (FPA), or flower algorithm (FA), %
% for single objective optimization. It usually works well for %
% unconstrained functions only. For functions/problems with %
% limits/bounds and constraints, constraint-handling techniques %
% should be implemented to deal with constrained problems properly. %
% %
% Citation details: %
%1)Xin-She Yang, Flower pollination algorithm for global optimization,%
% Unconventional Computation and Natural Computation, %
% Lecture Notes in Computer Science, Vol. 7445, pp. 240-249 (2012). %
%2)X. S. Yang, M. Karamanoglu, X. S. He, Multi-objective flower %
% algorithm for optimization, Procedia in Computer Science, %
% vol. 18, pp. 861-868 (2013). %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [best,fmin,N_iter]=fpa_demo(para)
% Default parameters
if nargin<1,
para=[20 0.8];
end
n=para(1); % Population size, typically 10 to 25
p=para(2); % probabibility switch
% Iteration parameters
N_iter=2000; % Total number of iterations
% Dimension of the search variables
d=3;
Lb=-2*ones(1,d);
Ub=2*ones(1,d);
% Initialize the population/solutions
for i=1:n,
Sol(i,:)=Lb+(Ub-Lb).*rand(1,d);
Fitness(i)=Fun(Sol(i,:));
end
% Find the current best
[fmin,I]=min(Fitness);
best=Sol(I,:);
S=Sol;
% Start the iterations -- Flower Algorithm
for t=1:N_iter,
% Loop over all bats/solutions
for i=1:n,
% Pollens are carried by insects and thus can move in
% large scale, large distance.
% This L should replace by Levy flights
% Formula: x_i^{t+1}=x_i^t+ L (x_i^t-gbest)
if rand>p,
%% L=rand;
L=Levy(d);
dS=L.*(Sol(i,:)-best);
S(i,:)=Sol(i,:)+dS;
% Check if the simple limits/bounds are OK
S(i,:)=simplebounds(S(i,:),Lb,Ub);
% If not, then local pollenation of neighbor flowers
else
epsilon=rand;
% Find random flowers in the neighbourhood
JK=randperm(n);
% As they are random, the first two entries also random
% If the flower are the same or similar species, then
% they can be pollenated, otherwise, no action.
% Formula: x_i^{t+1}+epsilon*(x_j^t-x_k^t)
S(i,:)=S(i,:)+epsilon*(Sol(JK(1),:)-Sol(JK(2),:));
% Check if the simple limits/bounds are OK
S(i,:)=simplebounds(S(i,:),Lb,Ub);
end
% Evaluate new solutions
Fnew=Fun(S(i,:));
% If fitness improves (better solutions found), update then
if (Fnew<=Fitness(i)),
Sol(i,:)=S(i,:);
Fitness(i)=Fnew;
end
% Update the current global best
if Fnew<=fmin,
best=S(i,:) ;
fmin=Fnew ;
end
end
% Display results every 100 iterations
if round(t/100)==t/100,
best
fmin
end
end
% Output/display
disp(['Total number of evaluations: ',num2str(N_iter*n)]);
disp(['Best solution=',num2str(best),' fmin=',num2str(fmin)]);
% Application of simple constraints
function s=simplebounds(s,Lb,Ub)
% Apply the lower bound
ns_tmp=s;
I=ns_tmp<Lb;
ns_tmp(I)=Lb(I);
% Apply the upper bounds
J=ns_tmp>Ub;
ns_tmp(J)=Ub(J);
% Update this new move
s=ns_tmp;
% Draw n Levy flight sample
function L=Levy(d)
% Levy exponent and coefficient
% For details, see Chapter 11 of the following book:
% Xin-She Yang, Nature-Inspired Optimization Algorithms, Elsevier, (2014).
beta=3/2;
sigma=(gamma(1+beta)*sin(pi*beta/2)/(gamma((1+beta)/2)*beta*2^((beta-
1)/2)))^(1/beta);
u=randn(1,d)*sigma;
v=randn(1,d);
step=u./abs(v).^(1/beta);
L=0.01*step;
% Objective function and here we used Rosenbrock's 3D function
function z=Fun(u)
z=(1-u(1))^2+100*(u(2)-u(1)^2)^2+100*(u(3)-u(2)^2)^2;

More Related Content

DOCX
Two Quadrant chopper
DOCX
Separation of losses in a dc shunt motor
PDF
Power Electronics Lab Manual ME PED
PPT
Introduction electrical field of a long straight conductor potential differen...
PDF
STATE-SPACE AVERAGING METHOD
PPTX
Presentation1
PPTX
3 phase half wave controlled converter with r Load
PPTX
SC Calculation (MVA Method) ETAP
Two Quadrant chopper
Separation of losses in a dc shunt motor
Power Electronics Lab Manual ME PED
Introduction electrical field of a long straight conductor potential differen...
STATE-SPACE AVERAGING METHOD
Presentation1
3 phase half wave controlled converter with r Load
SC Calculation (MVA Method) ETAP

What's hot (20)

PDF
BEC- 26 control systems_unit-II
PPSX
dc Generator Ppt
PDF
Unit 5 oscillators and voltage regulators
PDF
Speed checker on highway using 8051
PPTX
WATER LEVEL AUTOMATIC PUMP CONTROLLER
PPT
Week 10 part 1 pe 6282 Block Diagrams
PDF
EE6702 Protection and Switchgear notes R2013
PPTX
Put coin draw power
PPTX
Power electronics
PPTX
P, PI AND PID CONTROLLER
PDF
Lecture 17 me 176 (4th) 9 - design via root locus
PPTX
Inverter ppt
PPTX
SFG and Mason's Gain Formula
PPTX
Remote ac power control by android application with lcd display
PDF
Bao cao đồ án môn học
PPT
Introduction to Power Electronics
PPTX
Power System Control
PDF
Pid controller
PPTX
Auto selection of any aviliable phase
PPTX
Presentation on Over-/under-voltage protection of electrical appliance
BEC- 26 control systems_unit-II
dc Generator Ppt
Unit 5 oscillators and voltage regulators
Speed checker on highway using 8051
WATER LEVEL AUTOMATIC PUMP CONTROLLER
Week 10 part 1 pe 6282 Block Diagrams
EE6702 Protection and Switchgear notes R2013
Put coin draw power
Power electronics
P, PI AND PID CONTROLLER
Lecture 17 me 176 (4th) 9 - design via root locus
Inverter ppt
SFG and Mason's Gain Formula
Remote ac power control by android application with lcd display
Bao cao đồ án môn học
Introduction to Power Electronics
Power System Control
Pid controller
Auto selection of any aviliable phase
Presentation on Over-/under-voltage protection of electrical appliance
Ad

Viewers also liked (20)

PPTX
Whale optimizatio algorithm
PDF
Flower Pollination Algorithm: A Novel Approach for Multiobjective Optimization
PDF
Recent Advances in Flower Pollination Algorithm
PDF
Multi-objective Flower Algorithm for Optimization
PDF
Flower Pollination Algorithm for Global Optimization
PDF
A Comparison between FPPSO and B&B Algorithm for Solving Integer Programming ...
PPTX
Spider Monkey Optimization Algorithm
PPTX
Hiroshi sugimoto
PDF
L010225762
PDF
Multiobjective Firefly Algorithm for Continuous Optimization
PPTX
Firefly
PPTX
Bat algorithm
PDF
Particle Swarm Optimization Matlab code Using 50, 5000 Swarms
PDF
Firefly Algorithm, Stochastic Test Functions and Design Optimisation
PPTX
Fireflies 1
TXT
Firefly algorithm
PDF
Analysis of Nature-Inspried Optimization Algorithms
PDF
Multi-Objective Optimization in Rule-based Design Space Exploration (ASE 2014)
PPTX
A Comparative Study between Honeybee Foraging Behaviour Algorithm and Round ...
PPTX
Bat Algorithm
Whale optimizatio algorithm
Flower Pollination Algorithm: A Novel Approach for Multiobjective Optimization
Recent Advances in Flower Pollination Algorithm
Multi-objective Flower Algorithm for Optimization
Flower Pollination Algorithm for Global Optimization
A Comparison between FPPSO and B&B Algorithm for Solving Integer Programming ...
Spider Monkey Optimization Algorithm
Hiroshi sugimoto
L010225762
Multiobjective Firefly Algorithm for Continuous Optimization
Firefly
Bat algorithm
Particle Swarm Optimization Matlab code Using 50, 5000 Swarms
Firefly Algorithm, Stochastic Test Functions and Design Optimisation
Fireflies 1
Firefly algorithm
Analysis of Nature-Inspried Optimization Algorithms
Multi-Objective Optimization in Rule-based Design Space Exploration (ASE 2014)
A Comparative Study between Honeybee Foraging Behaviour Algorithm and Round ...
Bat Algorithm
Ad

Similar to Flower Pollination Algorithm (matlab code) (20)

PPTX
Flower pollination algorithm (Population based algorithm)
PDF
Flowerpollination 141114212025-conversion-gate02 (1)
PPTX
Firefly algorithm
PDF
Hybrid Gravitational Search Flower Pollination Algorithm for Combined Economi...
PPTX
Cuckoo Search & Firefly Algorithms
PPT
Artificial bee colony (abc)
PDF
Improved Firefly Algorithm for Unconstrained Optimization Problems
PPTX
Artificial Bee Colony (ABC) (Swarm Intelligence)
PPTX
Sunflower optimization algorithm
PPTX
seminar HBMO
PDF
Parallel hybrid chicken swarm optimization for solving the quadratic assignme...
PDF
Hybrid Data Clustering Approach Using K-Means and Flower Pollination Algorithm
PDF
HYBRID DATA CLUSTERING APPROACH USING K-MEANS AND FLOWER POLLINATION ALGORITHM
PDF
HYBRID DATA CLUSTERING APPROACH USING K-MEANS AND FLOWER POLLINATION ALGORITHM
PDF
Evaluation the efficiency of cuckoo
PDF
Optimal k-means clustering using artificial bee colony algorithm with variab...
PDF
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
PPTX
5. FIREFLY ALGORITHM OPTIMIZATION.pptx
PPT
Swarm intelligence algorithms
PDF
Optimization
Flower pollination algorithm (Population based algorithm)
Flowerpollination 141114212025-conversion-gate02 (1)
Firefly algorithm
Hybrid Gravitational Search Flower Pollination Algorithm for Combined Economi...
Cuckoo Search & Firefly Algorithms
Artificial bee colony (abc)
Improved Firefly Algorithm for Unconstrained Optimization Problems
Artificial Bee Colony (ABC) (Swarm Intelligence)
Sunflower optimization algorithm
seminar HBMO
Parallel hybrid chicken swarm optimization for solving the quadratic assignme...
Hybrid Data Clustering Approach Using K-Means and Flower Pollination Algorithm
HYBRID DATA CLUSTERING APPROACH USING K-MEANS AND FLOWER POLLINATION ALGORITHM
HYBRID DATA CLUSTERING APPROACH USING K-MEANS AND FLOWER POLLINATION ALGORITHM
Evaluation the efficiency of cuckoo
Optimal k-means clustering using artificial bee colony algorithm with variab...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
5. FIREFLY ALGORITHM OPTIMIZATION.pptx
Swarm intelligence algorithms
Optimization

More from Xin-She Yang (20)

PDF
Cuckoo Search Algorithm: An Introduction
PDF
Metaheuristic Algorithms: A Critical Analysis
PDF
Nature-Inspired Optimization Algorithms
PDF
A Biologically Inspired Network Design Model
TXT
Multiobjective Bat Algorithm (demo only)
TXT
Bat algorithm (demo)
PDF
Nature-Inspired Metaheuristic Algorithms
PDF
Metaheuristics and Optimiztion in Civil Engineering
PDF
A Biologically Inspired Network Design Model
PDF
Introduction to Computational Mathematics (2nd Edition, 2015)
PDF
Memetic Firefly algorithm for combinatorial optimization
PDF
Two-Stage Eagle Strategy with Differential Evolution
PDF
Accelerated Particle Swarm Optimization and Support Vector Machine for Busine...
PDF
Bat Algorithm for Multi-objective Optimisation
PDF
Are motorways rational from slime mould's point of view?
PDF
Review of Metaheuristics and Generalized Evolutionary Walk Algorithm
PDF
Test Problems in Optimization
PDF
Engineering Optimisation by Cuckoo Search
PDF
A New Metaheuristic Bat-Inspired Algorithm
PDF
Eagle Strategy Using Levy Walk and Firefly Algorithms For Stochastic Optimiza...
Cuckoo Search Algorithm: An Introduction
Metaheuristic Algorithms: A Critical Analysis
Nature-Inspired Optimization Algorithms
A Biologically Inspired Network Design Model
Multiobjective Bat Algorithm (demo only)
Bat algorithm (demo)
Nature-Inspired Metaheuristic Algorithms
Metaheuristics and Optimiztion in Civil Engineering
A Biologically Inspired Network Design Model
Introduction to Computational Mathematics (2nd Edition, 2015)
Memetic Firefly algorithm for combinatorial optimization
Two-Stage Eagle Strategy with Differential Evolution
Accelerated Particle Swarm Optimization and Support Vector Machine for Busine...
Bat Algorithm for Multi-objective Optimisation
Are motorways rational from slime mould's point of view?
Review of Metaheuristics and Generalized Evolutionary Walk Algorithm
Test Problems in Optimization
Engineering Optimisation by Cuckoo Search
A New Metaheuristic Bat-Inspired Algorithm
Eagle Strategy Using Levy Walk and Firefly Algorithms For Stochastic Optimiza...

Recently uploaded (20)

PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Welding lecture in detail for understanding
PPTX
Sustainable Sites - Green Building Construction
PPT
Mechanical Engineering MATERIALS Selection
PDF
Digital Logic Computer Design lecture notes
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
web development for engineering and engineering
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
PPT on Performance Review to get promotions
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Construction Project Organization Group 2.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
OOP with Java - Java Introduction (Basics)
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Welding lecture in detail for understanding
Sustainable Sites - Green Building Construction
Mechanical Engineering MATERIALS Selection
Digital Logic Computer Design lecture notes
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
web development for engineering and engineering
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPT on Performance Review to get promotions
Foundation to blockchain - A guide to Blockchain Tech
Construction Project Organization Group 2.pptx
Lecture Notes Electrical Wiring System Components
CH1 Production IntroductoryConcepts.pptx
OOP with Java - Java Introduction (Basics)
R24 SURVEYING LAB MANUAL for civil enggi
UNIT 4 Total Quality Management .pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx

Flower Pollination Algorithm (matlab code)

  • 1. % --------------------------------------------------------------------% % Flower pollenation algorithm (FPA), or flower algorithm % % Programmed by Xin-She Yang @ May 2012 % % --------------------------------------------------------------------% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Notes: This demo program contains the very basic components of % % the flower pollination algorithm (FPA), or flower algorithm (FA), % % for single objective optimization. It usually works well for % % unconstrained functions only. For functions/problems with % % limits/bounds and constraints, constraint-handling techniques % % should be implemented to deal with constrained problems properly. % % % % Citation details: % %1)Xin-She Yang, Flower pollination algorithm for global optimization,% % Unconventional Computation and Natural Computation, % % Lecture Notes in Computer Science, Vol. 7445, pp. 240-249 (2012). % %2)X. S. Yang, M. Karamanoglu, X. S. He, Multi-objective flower % % algorithm for optimization, Procedia in Computer Science, % % vol. 18, pp. 861-868 (2013). % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [best,fmin,N_iter]=fpa_demo(para) % Default parameters if nargin<1, para=[20 0.8]; end n=para(1); % Population size, typically 10 to 25 p=para(2); % probabibility switch % Iteration parameters N_iter=2000; % Total number of iterations % Dimension of the search variables d=3; Lb=-2*ones(1,d); Ub=2*ones(1,d); % Initialize the population/solutions for i=1:n, Sol(i,:)=Lb+(Ub-Lb).*rand(1,d); Fitness(i)=Fun(Sol(i,:)); end % Find the current best [fmin,I]=min(Fitness); best=Sol(I,:); S=Sol; % Start the iterations -- Flower Algorithm for t=1:N_iter, % Loop over all bats/solutions for i=1:n, % Pollens are carried by insects and thus can move in % large scale, large distance. % This L should replace by Levy flights % Formula: x_i^{t+1}=x_i^t+ L (x_i^t-gbest) if rand>p, %% L=rand; L=Levy(d); dS=L.*(Sol(i,:)-best); S(i,:)=Sol(i,:)+dS;
  • 2. % Check if the simple limits/bounds are OK S(i,:)=simplebounds(S(i,:),Lb,Ub); % If not, then local pollenation of neighbor flowers else epsilon=rand; % Find random flowers in the neighbourhood JK=randperm(n); % As they are random, the first two entries also random % If the flower are the same or similar species, then % they can be pollenated, otherwise, no action. % Formula: x_i^{t+1}+epsilon*(x_j^t-x_k^t) S(i,:)=S(i,:)+epsilon*(Sol(JK(1),:)-Sol(JK(2),:)); % Check if the simple limits/bounds are OK S(i,:)=simplebounds(S(i,:),Lb,Ub); end % Evaluate new solutions Fnew=Fun(S(i,:)); % If fitness improves (better solutions found), update then if (Fnew<=Fitness(i)), Sol(i,:)=S(i,:); Fitness(i)=Fnew; end % Update the current global best if Fnew<=fmin, best=S(i,:) ; fmin=Fnew ; end end % Display results every 100 iterations if round(t/100)==t/100, best fmin end end % Output/display disp(['Total number of evaluations: ',num2str(N_iter*n)]); disp(['Best solution=',num2str(best),' fmin=',num2str(fmin)]); % Application of simple constraints function s=simplebounds(s,Lb,Ub) % Apply the lower bound ns_tmp=s; I=ns_tmp<Lb; ns_tmp(I)=Lb(I); % Apply the upper bounds J=ns_tmp>Ub; ns_tmp(J)=Ub(J); % Update this new move s=ns_tmp; % Draw n Levy flight sample function L=Levy(d) % Levy exponent and coefficient % For details, see Chapter 11 of the following book: % Xin-She Yang, Nature-Inspired Optimization Algorithms, Elsevier, (2014). beta=3/2;