Friday, September 26, 2014

FOA Source Codes of MATLAB



From now on, I am going to share the FOA source codes of MATLAB to all of you.

There are two topics:

One is optimization with/without constraints and the other one is (stochastic) optimal control with/without constraints.


1. Optimization without constraints.
2. Optimization with constraints.
3. Deterministic optimal control with/without constraints.
4. Stochastic optimal control with/without constraints.


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).

[bestSmell bestindex]=max(Smell);

% Retain the best  Concentration values and best x, y coordinates of the flies

X_axis=X(bestindex);
Y_axis=Y(bestindex);
Smellbest=bestSmell;

% Start the Drosophila iterative optimization

for g=1:maxgen   

 for i=1:sizepop

X(i)=X_axis+2*rand()-1;
Y(i)=Y_axis+2*rand()-1;
D(i)=(X(i)^2+Y(i)^2)^0.5;
S(i)=1/D(i);
Smell(i)=7-S(i)^2;

end

[bestSmell bestindex]=max(Smell);

% Determine whether the  concentration value is greater than the previous one.
% If so, the best value and its location of the fly is retained.
% Then all flies utilize their visual to find this best position.

if bestSmell>Smellbest
X_axis=X(bestindex);
Y_axis=Y(bestindex);
Smellbest=bestSmell;

end

% Record  the optimal Smell value of each generation to yy array.
% Record the coordinates of the optimal iterations

yy(g)=Smellbest;
Xbest(g)=X_axis;
Ybest(g)=Y_axis;

% *** Draw the optimal concentration values and flight path for every iteration

figure(1)
plot(yy)
grid  on;
title('Optimization process 7-X^2','fontsize',14)
xlabel('Iteration Number','fontsize',12);ylabel('Smell','fontsize',14);

figure(2)
plot(Xbest,Ybest,'b.');
grid on;
title('Fruit fly flying route 7-X^2','fontsize',14)
xlabel('X-axis','fontsize',12);ylabel('Y-axis','fontsize',12);
pause(0.5)
end
toc

Simulated results:

Here X>=0 (constraint), Optimal value (Smell) = 7.

Reference:

1. Pan, W.-T. (2011). Fruit Fly Optimization Algorithm. Taiwan: Tsang Hai Book  Publishing Co., ISBN 978-986-6184-70-3. (in chinese).

2. Nien Benjamin (2011) Application of Data Mining and Fruit Fly Optimization Algorithm to Construct  Financial Crisis Early Warning Model – A Case Study of Listed Companies in Taiwan, Master Thesis, Department of Economics, Soochow University, Taiwan (in chinese), Adviser: Wei-Yuan Lin.




Jing Si Aphorism:

Be honest and truthful in everything you do.
Be gentle and forgiving in your relationships with others

 
 


 Soochow University EMA
 

70 comments:

  1. hello
    i need source code of Fruit Fly Optimization Algorithm
    PLEASE ASAP
    best regards

    ReplyDelete
    Replies
    1. There is no such a thing like the free lunch.You have to work hard by yourself. Please do not ask others to send all the written programs unconditionally to you. Learn how to fish instead of receive fish free.

      Delete

  2. Dear sir,

    Iam a ph.d student i need the source for the fruit fly algorithm for constraint optimization and multi objective optimization
    please provide the code
    Thaks
    G Bala Murali
    Research scholar
    NIT rourkela
    Mail Id: bmgunji@gmail.com

    ReplyDelete
    Replies
    1. The fruit fly algorithm for constraint optimization and multi objective optimization are more complicated than the above code, it needs to add some constraints into the code or use the penalty function to deal with. Due to no response from the kind readers and malicious complaints, so I stopped to post my code in the past. Sorry to trouble some readers visiting my web. Deterministic optimal control with/without constraints and Stochastic optimal control with/without constraints can also be further worth exploring, and needs some domain knowlege of control theory. If you still have some problems you can post in the web or email to me with your real name and school (institution), Let us discuss and work together to deal with them.

      Delete
    2. For questions about the optimizing constraint application of FOA, please refer to Zhang Xueliang and Liu Liqin, “Intelligent Optimization Algorithms and Their Applications in Machine Engineering”, Chapter 6, September, 2012, National Defense Industry Press. (in chinese)

      Delete
  3. Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.

    big data training in chennai

    ReplyDelete
    Replies
    1. The fruit fly algorithm for constraint optimization and multi objective optimization are more complicated than the above code, it needs to add some constraints into the code or use the penalty function to deal with. Due to no response from the kind readers and malicious complaints, so I stopped to post my code in the past. Sorry to trouble some readers visiting my web. Deterministic optimal control with/without constraints and Stochastic optimal control with/without constraints can also be further worth exploring, and needs some domain knowlege of control theory. If you still have some problems you can post in the web or email to me with your real name and school (institution), Let us discuss and work together to deal with them.

      Delete
    2. There is no such a thing like the free lunch.You have to work hard by yourself. Please do not ask others to send all the written programs unconditionally to you. Learn how to fish instead of receive fish free.

      Delete
  4. Replies
    1. Thanks for your encouragement,I will share my idea in the web in the future.

      Delete
  5. Replies
    1. Thanks for your encouragement,I will share my idea in the web in the future.

      Delete
  6. Replies
    1. Thanks for your encouragement,I will share my idea in the web in the future.

      Delete
  7. This post is much helpful for us. This is really very massive value to all the readers and it will be the only reason for the post to get popular with great authority.
    Cloud computing Training Chennai
    Cloud computing Training centers in Chennai
    Cloud computing Training institutes in Chennai
    Best Cloud computing Training in Chennai
    Cloud computing institutes in Chennai

    ReplyDelete
    Replies
    1. Thanks for your encouragement,I will share my idea in the web in the future.

      Delete
  8. Nice Article,Great experience for me by reading this info.
    thanks for sharing the information with us.keep updating your ideas.
    Java Institutes in bangalore
    Java Courses in Chennai Anna Nagar
    Java Training in Vadapalani
    Java Training in Perungudi

    ReplyDelete
    Replies
    1. Thanks for your encouragement,I will share my idea in the web in the future.

      Delete
  9. Replies
    1. Thanks for your encouragement,I will share my idea in the web in the future.

      Delete
  10. Thanks for your encouragement,I will share my idea in the web in the future.

    ReplyDelete
  11. In the past, I found that the FOA algorithm of my student (Dr. Pan) had its limitations, because the fruit fly had no brain and could not think, so I had to use the more advanced method LFA (Leader and Follwers algorithm) to deal with these problem. We are going to publish related papers in the Famous Journals soon.

    ReplyDelete
  12. For questions about optimal control, you can visit the following website and ask them to provide the source code.

    ReplyDelete
  13. Thanks first of all for the useful info.
    the idea in this article is quite different and innovative please update more.
    AWS Certification Training
    AWS Training in Mogappair
    AWS Training in Vadapalani

    ReplyDelete
  14. It is a great post. Keep sharing such kind of useful information.

    Article submission sites
    Education

    ReplyDelete
  15. I am really enjoying reading your well written articles.
    It looks like you spend a lot of effort and time on your blog.
    I have bookmarked it and I am looking forward to reading new articles. Keep up the good work..
    Java Training in Bangalore
    Advanced Java Training Institute in Bangalore
    Best Institute For Java Course in Bangalore
    Java Training Classes in Bangalore
    Java Training Courses in Bangalore
    Best Institute For Java Training In Bangalore

    ReplyDelete
  16. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog.
    Keep update your blog.

    technocrawler
    Education

    ReplyDelete
  17. yet creative programming language to quality their sites and it makes into any working framework from when it is exceptionally recognized for its codes being quickly justifiable and dependable to blend in to a couple of programming utilized sideways from the detail that it is a publicly released programming which makes permitting more affordable. machine learning course in pune

    ReplyDelete
  18. iam master student .the above post is very clearly to explain the flow chart of fruit fly optimization algorithm...but awant to know how can use this code to use it in electronic application

    ReplyDelete
  19. The post is written in very a good manner and it entails many useful information for me. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. All the best
    oracle training in chennai

    oracle training in tambaram

    oracle dba training in chennai

    oracle dba training in tambaram

    ccna training in chennai

    ccna training in tambaram

    seo training in chennai

    seo training in tambaram

    ReplyDelete
  20. Atomic Email Hunter 15.20.0.485 Crack can be just a program specially intended for finding user names and email addresses that are included.Atomic Email Hunter Serial Number

    ReplyDelete
  21. Coolutils Total Excel Converter 6 Free Download includes all the necessary files to run perfectly on your system, uploaded program contains all latest and .Convert Wk4 To Excel

    ReplyDelete